Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ dependencies {
compile 'org.springframework.boot:spring-boot-starter-webflux'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'mysql:mysql-connector-java'
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.5'

compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
Expand All @@ -50,5 +51,7 @@ dependencies {
annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.0.Final'

testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'
testCompile group: 'org.testcontainers', name: 'postgresql', version: '1.11.1'
testCompile "org.testcontainers:junit-jupiter:1.11.1"
testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.3.0'
}
46 changes: 13 additions & 33 deletions devops/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,20 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_DATABASE=timecoder
postgresql:
image: postgres
volumes:
- "./mycustom.cnf:/etc/mysql/conf.d/custom.cnf"
timecoder-api:
image: spirogov/timecoder:1.3
container_name: timecoder
depends_on:
- mysql
- "db-data:/var/lib/postgresql/data"
- "./init.sql:/docker-entrypoint-initdb.d/init.sql"
environment:
- SPRING_PROFILES_ACTIVE=prod
links:
- mysql
timecoder-patrons:
image: spirogov/timecoder-patrons:1.4.0
container_name: timecoder-patrons
environment:
- accessToken=9rhhc4gNwwP6paXH2VPiO81VB0HoIKjjzKozvuRunXI
timecoder-gateway:
image: spirogov/timecoder-gateway:1.5.3
container_name: timecoder-gateway
depends_on:
- mysql
ports:
- 8086:5000
environment:
- SPRING_PROFILES_ACTIVE=prod
links:
- timecoder-api
ui:
image: spirogov/timecoder-ui:1.3.4
container_name: timecoder-ui
POSTGRES_PASSWORD: admin
ports:
- 80:80
volumes:
- "./nginx.conf:/etc/nginx/conf.d/default.conf"
links:
- timecoder-gateway
- 5432:5432
adminer:
image: adminer
restart: always
ports:
- 8088:8080

volumes:
db-data:
1 change: 1 addition & 0 deletions devops/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE timecoder;
4 changes: 0 additions & 4 deletions devops/mycustom.cnf

This file was deleted.

46 changes: 0 additions & 46 deletions devops/nginx.conf

This file was deleted.

24 changes: 17 additions & 7 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ spring:
spring:
profiles: dev
datasource:
username: root
username: postgres
password: admin
url: jdbc:mysql://localhost:3306/timecoder?useUnicode=yes&characterEncoding=UTF-8
url: jdbc:postgresql://localhost:5432/timecoder
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQL9Dialect
jdbc:
lob:
non_contextual_creation: true
hibernate:
ddl-auto: update
database: mysql

---
spring:
profiles: prod
datasource:
username: root
username: postgres
password: admin
url: jdbc:mysql://mysql:3306/timecoder?useUnicode=yes&characterEncoding=UTF-8
url: jdbc:postgresql://postgresql:5432/timecoder
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQL9Dialect
jdbc:
lob:
non_contextual_creation: true
hibernate:
ddl-auto: update
database: mysql
ddl-auto: update
53 changes: 53 additions & 0 deletions src/test/java/com/timecoder/test/EpisodeControllerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.timecoder.test;

import com.timecoder.TimecoderApplication;
import com.timecoder.dto.EpisodeDto;
import io.restassured.RestAssured;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

@ContextConfiguration(classes = TimecoderApplication.class)
@Testcontainers
@TestPropertySource(value={"classpath:application.properties"})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class EpisodeControllerTest {

@Value("${server.port}")
int port;

@Container
private final PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer()
.withDatabaseName("timecoder")
.withUsername("root")
.withPassword("admin");

@BeforeEach
void setUp() {
int port = postgreSQLContainer.getFirstMappedPort();
System.setProperty("spring.datasource.url", String.format("jdbc:postgresql://loca:%d/postgres", postgreSQLContainer.getFirstMappedPort()));
RestAssured.port = port;
}

@Test
void testCanCreateEpisode() {
EpisodeDto episodeDto = new EpisodeDto();
episodeDto.setName("#1");

RestAssured.given()
.body(episodeDto)
.when()
.post("/episodes")
.then()
.statusCode(200)
.body("status", Matchers.equalTo(""));
}
}