java10 compatibility

This commit is contained in:
Michał Michaluk
2018-06-28 00:08:54 +02:00
parent ef2adde225
commit 9a008dcbfe
43 changed files with 328 additions and 421 deletions

2
.gitattributes vendored
View File

@@ -4,4 +4,4 @@
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jpg binary

12
.gitignore vendored
View File

@@ -1,13 +1,17 @@
## travis-ci
!.travis.yml
!.codecov.yml
## maven
target/
target-test/
!.mvn
## linux
.*
!.git*
*~
## windows
@@ -20,7 +24,7 @@ Desktop.ini
$RECYCLE.BIN/
## osx
## macOS
.DS_Store
.AppleDouble
.LSOverride
@@ -85,9 +89,9 @@ tramp
*.un~
Session.vim
.netrwhist
*~
build
out/
build/
.gradle
*.log
out

View File

@@ -1,7 +1,9 @@
language: java
jdk:
- oraclejdk8
- openjdk8
- openjdk9
- openjdk10
after_success:
- bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"

View File

@@ -1,7 +1,12 @@
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.5")
compile("org.liquibase:liquibase-core:3.5.5")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.6")
compile("com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.6")
compile("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.6")
compile("org.liquibase:liquibase-core:3.6.1")
compile("javax.xml.bind:jaxb-api:2.3.0")
runtime("org.postgresql:postgresql:42.2.2")
testCompile("org.springframework.boot:spring-boot-starter-test")
}

View File

@@ -15,6 +15,11 @@
</parent>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -26,18 +31,34 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.8.5</version>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.8.12</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.5.5</version>
</dependency>
</dependencies>
<properties>
@@ -46,7 +67,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->

View File

@@ -1,11 +1,14 @@
package io.dddbyexamples.tools;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import javax.persistence.AttributeConverter;
import java.io.IOException;
@@ -20,6 +23,8 @@ public abstract class JsonConverter<T> implements AttributeConverter<T, String>
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule());
private final Class<T> type;

View File

@@ -1,18 +0,0 @@
package io.dddbyexamples.tools;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.annotation.AliasFor;
import org.springframework.test.context.ActiveProfiles;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@SpringBootTest
@ActiveProfiles
public @interface IntegrationTest {
@AliasFor(annotation = ActiveProfiles.class, attribute = "profiles") String[] activeProfiles() default {"test"};
}

View File

@@ -1,45 +1,38 @@
apply plugin: 'groovy'
dependencies {
compile(project(":demand-forecasting-adapters"))
compile(project(":shortages-prediction-adapters"))
compile(project(":product-management-adapters"))
compile(project(":production-planning-adapters"))
compile(project(":adapter-commons"))
compile(project(":demand-forecasting-adapters"))
compile(project(":shortages-prediction-adapters"))
compile(project(":product-management-adapters"))
compile(project(":production-planning-adapters"))
compile(project(":adapter-commons"))
compile("org.projectlombok:lombok:1.16.18")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("org.springframework.data:spring-data-rest-hal-browser")
compile("org.springframework.boot:spring-boot-starter-cloud-connectors")
compile("org.liquibase:liquibase-core:3.5.5")
compile("net.bytebuddy:byte-buddy:1.7.9")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("org.springframework.data:spring-data-rest-hal-browser")
compile("org.springframework.boot:spring-boot-starter-cloud-connectors")
runtime("org.cloudfoundry:auto-reconfiguration:1.12.0.RELEASE")
runtime("org.postgresql:postgresql:42.1.4")
runtime("org.cloudfoundry:auto-reconfiguration:1.12.0.RELEASE")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
testCompile("org.spockframework:spock-spring:1.1-groovy-2.4")
testCompile("com.h2database:h2:1.4.194")
// TODO: Because of this there's no up to date check from Gradle
testCompile(project(":adapter-commons").sourceSets.test.output)
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-spring:1.1-groovy-2.4")
testCompile("com.h2database:h2:1.4.197")
}
[bootJar, bootRun]*.enabled = true
jar.enabled = false
task stubsJar(type: Jar) {
classifier = "stubs"
into("META-INF/${project.rootProject.ext.projectGroupId}/${project.rootProject.ext.projectArtifactId}/${project.rootProject.ext.projectVersion}/shortages-prediction-adapters/mappings") {
include('**/*.*')
from(project(":shortages-prediction-adapters").projectDir.absolutePath + "/target/generated-snippets/stubs")
}
into("META-INF/${project.rootProject.ext.projectGroupId}/${project.rootProject.ext.projectArtifactId}/${project.rootProject.ext.projectVersion}/shortages-prediction-adapters/contracts") {
include('**/*.groovy')
from(project(":shortages-prediction-adapters").projectDir.absolutePath + "/target/generated-snippets/contracts")
}
classifier = "stubs"
into("META-INF/${project.rootProject.ext.projectGroupId}/${project.rootProject.ext.projectArtifactId}/${project.rootProject.ext.projectVersion}/shortages-prediction-adapters/mappings") {
include('**/*.*')
from(project(":shortages-prediction-adapters").projectDir.absolutePath + "/target/generated-snippets/stubs")
}
into("META-INF/${project.rootProject.ext.projectGroupId}/${project.rootProject.ext.projectArtifactId}/${project.rootProject.ext.projectVersion}/shortages-prediction-adapters/contracts") {
include('**/*.groovy')
from(project(":shortages-prediction-adapters").projectDir.absolutePath + "/target/generated-snippets/contracts")
}
}
// we need the tests to pass to build the stub jar
@@ -47,16 +40,16 @@ stubsJar.dependsOn(test)
stubsJar.dependsOn(project(":shortages-prediction-adapters").test)
artifacts {
archives stubsJar
archives stubsJar
}
jar.dependsOn(stubsJar)
publishing {
publications {
stubs(MavenPublication) {
artifactId project.name
artifact stubsJar
}
}
}
publications {
stubs(MavenPublication) {
artifactId project.name
artifact stubsJar
}
}
}

View File

@@ -22,7 +22,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -60,7 +60,6 @@
<artifactId>production-planning-adapters</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>pl.com.dddbyexamples</groupId>
<artifactId>adapter-commons</artifactId>
@@ -74,12 +73,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -101,12 +94,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>auto-reconfiguration</artifactId>
@@ -117,11 +104,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
@@ -137,14 +119,9 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
<version>1.4.197</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.7.9</version>
</dependency>
</dependencies>
<build>
@@ -166,10 +143,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
<plugin>
@@ -187,7 +165,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<version>${maven-surefire.version}</version>
<configuration>
<useFile>false</useFile>
<includes>

View File

@@ -1,5 +1,10 @@
package io.dddbyexamples.factory.integration
import io.dddbyexamples.factory.AppConfiguration
import io.dddbyexamples.factory.ProductTrait
import io.dddbyexamples.factory.demand.forecasting.persistence.DocumentEntity
import io.dddbyexamples.factory.demand.forecasting.projection.CurrentDemandEntity
import io.dddbyexamples.factory.product.management.ProductDescriptionEntity
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
@@ -9,12 +14,7 @@ import org.springframework.core.ParameterizedTypeReference
import org.springframework.hateoas.Resources
import org.springframework.http.HttpMethod
import org.springframework.http.ResponseEntity
import io.dddbyexamples.factory.AppConfiguration
import io.dddbyexamples.factory.ProductTrait
import io.dddbyexamples.factory.demand.forecasting.persistence.DocumentEntity
import io.dddbyexamples.factory.demand.forecasting.projection.CurrentDemandEntity
import io.dddbyexamples.factory.product.management.ProductDescriptionEntity
import io.dddbyexamples.tools.IntegrationTest
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification
import java.time.Clock
@@ -24,28 +24,29 @@ import static java.time.Instant.from
import static java.time.ZoneId.systemDefault
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
@IntegrationTest
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = [AppConfiguration, TestConfiguration])
class CallOffDocumentIntegrationSpec extends Specification implements ProductTrait {
public static final String PRODUCT_REF_NO = "3009000"
public static final LocalDate ANY_DATE = LocalDate.now()
@Autowired TestRestTemplate restTemplate
@Autowired
TestRestTemplate restTemplate
def 'receiving call off document should create new product demands for subsequent days'() {
given:
productDescriptionIsSuccessfullyCreated(PRODUCT_REF_NO)
productDescriptionIsSuccessfullyCreated(PRODUCT_REF_NO)
when:
callOffDocumentIsSuccessfullyRequested(PRODUCT_REF_NO, ANY_DATE, 100, 200, 300)
callOffDocumentIsSuccessfullyRequested(PRODUCT_REF_NO, ANY_DATE, 100, 200, 300)
and:
Collection<CurrentDemandEntity> demands =
demandsForProductStartingFromDateAreRequested(PRODUCT_REF_NO, ANY_DATE.minusDays(1))
Collection<CurrentDemandEntity> demands =
demandsForProductStartingFromDateAreRequested(PRODUCT_REF_NO, ANY_DATE.minusDays(1))
then:
demands.size() == 3
thereIsDemand(demands, ANY_DATE, 100)
thereIsDemand(demands, ANY_DATE.plusDays(1), 200)
thereIsDemand(demands, ANY_DATE.plusDays(2), 300)
demands.size() == 3
thereIsDemand(demands, ANY_DATE, 100)
thereIsDemand(demands, ANY_DATE.plusDays(1), 200)
thereIsDemand(demands, ANY_DATE.plusDays(2), 300)
}
void productDescriptionIsSuccessfullyCreated(String refNo) {

View File

@@ -5,6 +5,7 @@ import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import org.springframework.core.ParameterizedTypeReference
import org.springframework.hateoas.Resources
import org.springframework.http.HttpMethod
@@ -17,7 +18,7 @@ import io.dddbyexamples.factory.demand.forecasting.command.DemandAdjustmentEntit
import io.dddbyexamples.factory.demand.forecasting.persistence.DocumentEntity
import io.dddbyexamples.factory.demand.forecasting.projection.CurrentDemandEntity
import io.dddbyexamples.factory.product.management.ProductDescriptionEntity
import io.dddbyexamples.tools.IntegrationTest
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification
import java.time.Clock
@@ -27,7 +28,7 @@ import static java.time.Instant.from
import static java.time.ZoneId.systemDefault
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
@IntegrationTest
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = [AppConfiguration, TestConfiguration])
class DemandAdjustmentIntegrationSpec extends Specification implements ProductTrait {

View File

@@ -1,14 +1,5 @@
package io.dddbyexamples.factory.integration
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.ParameterizedTypeReference
import org.springframework.hateoas.Resource
import org.springframework.http.HttpMethod
import org.springframework.http.ResponseEntity
import io.dddbyexamples.factory.AppConfiguration
import io.dddbyexamples.factory.ProductTrait
import io.dddbyexamples.factory.demand.forecasting.Adjustment
@@ -19,7 +10,16 @@ import io.dddbyexamples.factory.product.management.ProductDescriptionEntity
import io.dddbyexamples.factory.shortages.prediction.calculation.Stock
import io.dddbyexamples.factory.shortages.prediction.monitoring.persistence.ShortagesEntity
import io.dddbyexamples.factory.warehouse.WarehouseService
import io.dddbyexamples.tools.IntegrationTest
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.ParameterizedTypeReference
import org.springframework.hateoas.Resource
import org.springframework.http.HttpMethod
import org.springframework.http.ResponseEntity
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification
import java.time.Clock
@@ -29,7 +29,7 @@ import static java.time.Instant.from
import static java.time.ZoneId.systemDefault
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
@IntegrationTest
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = [AppConfiguration, TestConfiguration])
class ShortageIntegrationSpec extends Specification implements ProductTrait {
@@ -37,17 +37,18 @@ class ShortageIntegrationSpec extends Specification implements ProductTrait {
public static final LocalDate ANY_DATE = LocalDate.now()
public static final int PRODUCT_STOCK_LEVEL = 100
@Autowired TestRestTemplate restTemplate
@Autowired
TestRestTemplate restTemplate
def 'adjustment that exceeds current stock level should result in shortage'() {
given:
productDescriptionIsSuccessfullyCreated(PRODUCT_REF_NO)
productDescriptionIsSuccessfullyCreated(PRODUCT_REF_NO)
when:
callOffDocumentIsSuccessfullyRequested(PRODUCT_REF_NO, ANY_DATE, PRODUCT_STOCK_LEVEL)
callOffDocumentIsSuccessfullyRequested(PRODUCT_REF_NO, ANY_DATE, PRODUCT_STOCK_LEVEL)
and:
adjustmentIsSuccessfullyRequested(ANY_DATE.plusDays(1), 200)
adjustmentIsSuccessfullyRequested(ANY_DATE.plusDays(1), 200)
then:
thereIsShortage(PRODUCT_REF_NO, ANY_DATE.plusDays(1), 200)
thereIsShortage(PRODUCT_REF_NO, ANY_DATE.plusDays(1), 200)
}

View File

@@ -1,94 +1,105 @@
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE"
// TODO: Snapshots are used only for testing purposes
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:2.0.0.BUILD-SNAPSHOT"
}
repositories {
mavenCentral()
mavenLocal()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE"
// TODO: Snapshots are used only for testing purposes
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:2.0.0.BUILD-SNAPSHOT"
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven-publish'
group = 'pl.com.dddbyexamples'
version = getProp('newVersion') ?: '1.0-SNAPSHOT'
group = 'pl.com.dddbyexamples'
version = getProp('newVersion') ?: '1.0-SNAPSHOT'
apply from: project.rootDir.absolutePath + '/gradle/pipeline.gradle'
apply from: project.rootDir.absolutePath + '/gradle/pipeline.gradle'
bootJar.enabled = false
jar.enabled = true
bootRun.enabled = false
bootJar.enabled = false
jar.enabled = true
bootRun.enabled = false
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${BOM_VERSION}"
}
}
compileJava.options.compilerArgs << '-parameters'
compileTestJava.options.compilerArgs << '-parameters'
repositories {
mavenCentral()
mavenLocal()
if (getProp("M2_LOCAL")) {
maven {
url getProp("M2_LOCAL")
}
}
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/release" }
}
dependencies {
compileOnly('org.projectlombok:lombok:1.18.0')
annotationProcessor('org.projectlombok:lombok:1.18.0')
publishing {
repositories {
maven {
url getProp('REPO_WITH_BINARIES_FOR_UPLOAD') ?:
getProp('REPO_WITH_BINARIES') ?: 'http://localhost:8081/artifactory/libs-release-local'
credentials {
username getProp('M2_SETTINGS_REPO_USERNAME') ?: 'admin'
password getProp('M2_SETTINGS_REPO_PASSWORD') ?: 'password'
}
}
}
publications {
mavenJava(MavenPublication) {
artifactId project.name
from components.java
}
}
}
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
testCompile("net.bytebuddy:byte-buddy:1.8.12")
}
tasks.withType(Test) {
testLogging {
events "started", "passed", "skipped", "failed"
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${BOM_VERSION}"
}
}
repositories {
mavenCentral()
mavenLocal()
if (getProp("M2_LOCAL")) {
maven {
url getProp("M2_LOCAL")
}
}
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/release" }
}
publishing {
repositories {
maven {
url getProp('REPO_WITH_BINARIES_FOR_UPLOAD') ?:
getProp('REPO_WITH_BINARIES') ?: 'http://localhost:8081/artifactory/libs-release-local'
credentials {
username getProp('M2_SETTINGS_REPO_USERNAME') ?: 'admin'
password getProp('M2_SETTINGS_REPO_PASSWORD') ?: 'password'
}
}
}
publications {
mavenJava(MavenPublication) {
artifactId project.name
from components.java
}
}
}
tasks.withType(Test) {
testLogging {
events "started", "passed", "skipped", "failed"
}
}
}
ext {
projectGroupId = project.group
// In a multi-module env we can specify which project is the one that produces the fat-jar
projectArtifactId = "app-monolith"
projectVersion = project.version
projectGroupId = project.group
// In a multi-module env we can specify which project is the one that produces the fat-jar
projectArtifactId = "app-monolith"
projectVersion = project.version
}
apply plugin: "java"
[bootJar, bootRun]*.enabled = false
task wrapper(type: Wrapper) {
gradleVersion = '4.8'
gradleVersion = '4.8'
}
String getProp(String propName) {
return hasProperty(propName) ?
(getProperty(propName) ?: System.properties[propName]) : System.properties[propName] ?:
System.getenv(propName)
}
return hasProperty(propName) ?
(getProperty(propName) ?: System.properties[propName]) : System.properties[propName] ?:
System.getenv(propName)
}

View File

@@ -4,13 +4,7 @@ dependencies {
compile(project(":demand-forecasting-model"))
compile(project(":adapter-commons"))
compile("org.projectlombok:lombok:1.16.18")
runtime("org.postgresql:postgresql:42.1.4")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
testCompile("org.spockframework:spock-spring:1.1-groovy-2.4")
testCompile("com.h2database:h2:1.4.194")
testCompile(project(":adapter-commons").sourceSets.test.output)
}
}

View File

@@ -33,23 +33,11 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
@@ -62,12 +50,6 @@
<version>1.1-groovy-2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -83,7 +65,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -118,15 +100,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<version>2.22.0</version>
<configuration>
<useFile>false</useFile>
<includes>

View File

@@ -1,5 +1,6 @@
package io.dddbyexamples.factory.delivery.planning;
import io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefinition;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefinitionDao;
@@ -17,6 +18,7 @@ public class DeliveryAutoPlannerORMRepository {
return new DeliveryAutoPlanner(refNo,
dao.findById(refNo)
.map(DeliveryPlannerDefinitionEntity::getDefinition)
.filter(def -> !def.isDisabled())
.map(x -> x.map(DeliveriesSuggestion::timesAndFractions))
.orElse(Collections.emptyMap()));
}

View File

@@ -18,6 +18,7 @@ import java.util.stream.Collectors;
public class DeliveryPlannerDefinition {
@Singular
private final Map<Demand.Schema, Map<LocalTime, Double>> definitions;
private final boolean disabled;
public static Map<LocalTime, Double> of(LocalTime time, Double fraction) {
return Collections.singletonMap(time, fraction);

View File

@@ -5,12 +5,15 @@ import org.springframework.boot.test.context.SpringBootTest
import io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefinition
import io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefinitionDao
import io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefinitionEntity
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.TestPropertySource
import spock.lang.Specification
import static java.time.LocalTime.of as time
import static io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefinition.of
import static io.dddbyexamples.factory.demand.forecasting.Demand.Schema.*
@ActiveProfiles("test")
@SpringBootTest
class DeliveryPlannerDefinitionSpec extends Specification {

View File

@@ -1,24 +1,22 @@
package io.dddbyexamples.factory.demand.forecasting
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.annotation.Commit
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
import io.dddbyexamples.factory.demand.forecasting.persistence.DemandDao
import io.dddbyexamples.factory.demand.forecasting.persistence.DemandEntity
import io.dddbyexamples.factory.demand.forecasting.persistence.ProductDemandDao
import io.dddbyexamples.factory.demand.forecasting.persistence.ProductDemandEntity
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification
import javax.persistence.EntityManager
import javax.transaction.Transactional
import java.time.Clock
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
@SpringBootTest
@Transactional
@Commit
@ActiveProfiles("test")
@DataJpaTest
class ProductDemandORMRepositorySpec extends Specification {
def clock = Clock.fixed(Instant.now(), ZoneId.systemDefault())

View File

@@ -1,10 +1,6 @@
apply plugin: 'groovy'
apply plugin: "jacoco"
dependencies {
compile(project(":shared-kernel-model"))
compile(project(":adapter-commons"))
compile("org.projectlombok:lombok:1.16.18")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
}
}

View File

@@ -16,7 +16,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -42,7 +42,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -72,6 +72,7 @@
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
@@ -79,7 +80,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<version>2.22.0</version>
<configuration>
<useFile>false</useFile>
<includes>
@@ -91,7 +92,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<version>0.8.1</version>
<executions>
<execution>
<goals>

View File

@@ -12,14 +12,6 @@ class DemandsFake extends Demands {
fetch = { date -> nothingDemanded(date) }
}
DailyDemand nothingDemanded(LocalDate date) {
def demand = builder.reset()
.date(date)
.build()
fetched.put(date, demand)
demand
}
DailyDemand demanded(LocalDate date, long level) {
def demand = builder.date(date)
.demandedLevels(level)
@@ -48,4 +40,11 @@ class DemandsFake extends Demands {
fetched.put(date, demand)
demand
}
private DailyDemand nothingDemanded(LocalDate date) {
def demand = builder.reset()
.date(date)
.build()
demand
}
}

View File

@@ -1,2 +1,2 @@
org.gradle.daemon=false
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT

View File

@@ -1,3 +1,2 @@
config.stopBubbling=true
lombok.addLombokGeneratedAnnotation=true
#lombok.anyConstructor.addConstructorProperties=true

View File

@@ -5,4 +5,4 @@ applications:
- app-monolith-db
env:
JAVA_OPTS: -Djava.security.egd=file:///dev/urandom
TRUST_CERTS: api.run.pivotal.io
TRUST_CERTS: api.run.pivotal.io

View File

@@ -28,7 +28,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->

View File

@@ -3,14 +3,7 @@ apply plugin: 'groovy'
dependencies {
compile(project(":adapter-commons"))
compile("org.projectlombok:lombok:1.16.18")
compile("net.bytebuddy:byte-buddy:1.7.9")
runtime("org.postgresql:postgresql:42.1.4")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
testCompile("org.spockframework:spock-spring:1.1-groovy-2.4")
testCompile("com.h2database:h2:1.4.194")
testCompile(project(":adapter-commons").sourceSets.test.output)
}
}

View File

@@ -28,12 +28,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@@ -42,7 +36,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4</version>
<version>42.2.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -60,7 +54,7 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.7.9</version>
<version>1.8.12</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
@@ -78,7 +72,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -113,15 +107,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<version>2.22.0</version>
<configuration>
<useFile>false</useFile>
<includes>

View File

@@ -1,5 +1,6 @@
package io.dddbyexamples.factory.product.management
import org.springframework.test.context.ActiveProfiles
import spock.lang.Ignore
import org.springframework.beans.factory.annotation.Autowired
@@ -8,9 +9,8 @@ import spock.lang.Specification
import static java.util.Collections.singletonList
// TODO: Unignore
@Ignore
@SpringBootTest
@ActiveProfiles("test")
class ProductDescriptionPersistenceSpec extends Specification {
@Autowired

View File

@@ -3,14 +3,7 @@ apply plugin: 'groovy'
dependencies {
compile(project(":adapter-commons"))
compile("org.projectlombok:lombok:1.16.18")
compile("net.bytebuddy:byte-buddy:1.7.9")
runtime("org.postgresql:postgresql:42.1.4")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
testCompile("org.spockframework:spock-spring:1.1-groovy-2.4")
testCompile("com.h2database:h2:1.4.194")
testCompile(project(":adapter-commons").sourceSets.test.output)
}
}

View File

@@ -28,23 +28,11 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
@@ -57,11 +45,6 @@
<version>1.1-groovy-2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.7.9</version>
</dependency>
</dependencies>
<properties>
@@ -71,7 +54,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -93,10 +76,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
</plugins>

View File

@@ -15,4 +15,4 @@ stage:
type: broker
broker: elephantsql
plan: turtle
useExisting: true
useExisting: true

View File

@@ -7,4 +7,4 @@ include "demand-forecasting-adapters"
include "shortages-prediction-model"
include "shortages-prediction-adapters"
include "product-management-adapters"
include "production-planning-adapters"
include "production-planning-adapters"

View File

@@ -1,7 +1,5 @@
apply plugin: 'groovy'
apply plugin: "jacoco"
dependencies {
compile("org.projectlombok:lombok:1.16.18")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
}
}

View File

@@ -16,7 +16,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -37,8 +37,8 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>compile</scope>
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
@@ -67,6 +67,7 @@
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
@@ -74,7 +75,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<version>2.22.0</version>
<configuration>
<useFile>false</useFile>
<includes>
@@ -86,7 +87,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<version>0.8.1</version>
<executions>
<execution>
<goals>

View File

@@ -4,18 +4,12 @@ dependencies {
compile(project(":shortages-prediction-model"))
compile(project(":adapter-commons"))
compile("org.projectlombok:lombok:1.16.18")
runtime("org.postgresql:postgresql:42.1.4")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
testCompile("org.spockframework:spock-spring:1.1-groovy-2.4")
testCompile("org.springframework.cloud:spring-cloud-starter-contract-stub-runner")
testCompile("org.springframework.cloud:spring-cloud-starter-contract-verifier")
testCompile("org.springframework.restdocs:spring-restdocs-mockmvc")
testCompile("com.h2database:h2:1.4.194")
testCompile(project(":adapter-commons").sourceSets.test.output)
}
if (gradle.startParameter.taskRequests.any { it.args.any { it.contains("apiCompatibility") } }) {
@@ -50,4 +44,4 @@ if (gradle.startParameter.taskRequests.any { it.args.any { it.contains("apiCompa
}
}
}
}

View File

@@ -34,23 +34,11 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
@@ -63,12 +51,6 @@
<version>1.1-groovy-2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
@@ -113,7 +95,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -148,10 +130,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
<plugin>

View File

@@ -44,26 +44,24 @@ class ShortagePredictionProcessORMRepository implements ShortagePredictionProces
.flatMap(dao::findById)
.orElseGet(() -> dao.save(new ShortagesEntity(refNo.getRefNo())));
entity.setShortage(event.getShortage());
events.emit(event);
}
private void delete(ShortageSolved event) {
TechnicalId.get(event.getRefNo())
.ifPresent(dao::deleteById);
events.emit(event);
}
}
private class EventsHandler implements ShortageEvents {
@Override
public void emit(NewShortage event) {
save(event);
events.emit(event);
}
@Override
public void emit(ShortageSolved event) {
delete(event);
events.emit(event);
}
}
}

View File

@@ -1,27 +1,21 @@
package io.dddbyexamples.factory.shortages.prediction.monitoring
import spock.lang.Ignore
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.annotation.Commit
import io.dddbyexamples.factory.product.management.RefNoId
import io.dddbyexamples.factory.shortages.prediction.Shortage
import io.dddbyexamples.factory.shortages.prediction.calculation.ShortageForecasts
import io.dddbyexamples.factory.shortages.prediction.monitoring.persistence.ShortagesDao
import io.dddbyexamples.factory.shortages.prediction.monitoring.persistence.ShortagesEntity
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification
import javax.transaction.Transactional
import java.time.LocalDateTime
import static io.dddbyexamples.factory.shortages.prediction.monitoring.NewShortage.After.DemandChanged
@SpringBootTest
@Transactional
@Commit
//TODO: Unignore
@Ignore
@DataJpaTest
@ActiveProfiles("test")
class ShortagePredictionProcessORMRepositorySpec extends Specification {
def now = LocalDateTime.now()
@@ -42,54 +36,54 @@ class ShortagePredictionProcessORMRepositorySpec extends Specification {
def "provides process instance when no shortage persisted"() {
when:
def process = fetchProcess()
def process = fetchProcess()
then:
shortagesCurrentlyKnownBy(process) == noShortages()
shortagesCurrentlyKnownBy(process) == noShortages()
}
def "provides process instance with last known shortage"() {
given:
persistedShortage(someShortages())
persistedShortage(someShortages())
when:
def process = fetchProcess()
def process = fetchProcess()
then:
shortagesCurrentlyKnownBy(process) == someShortages()
shortagesCurrentlyKnownBy(process) == someShortages()
}
def "persists first shortage"() {
when:
def process = fetchProcess()
processEmitsNewShortage(process, someShortages())
def process = fetchProcess()
processEmitsNewShortage(process, someShortages())
then:
shortagesCurrentlyPersisted() == someShortages()
shortagesCurrentlyPersisted() == someShortages()
}
def "updates previous shortage"() {
given:
persistedShortage(someOldShortages())
persistedShortage(someOldShortages())
when:
def process = fetchProcess()
processEmitsNewShortage(process, someShortages())
def process = fetchProcess()
processEmitsNewShortage(process, someShortages())
then:
shortagesCurrentlyPersisted() == someShortages()
shortagesCurrentlyPersisted() == someShortages()
}
def "deletes solved shortage"() {
given:
persistedShortage(someShortages())
persistedShortage(someShortages())
when:
def process = fetchProcess()
processEmitsShortageSolved(process)
def process = fetchProcess()
processEmitsShortageSolved(process)
then:
noShortagesPersisted()
noShortagesPersisted()
}
def persistedShortage(Shortage shortages) {

View File

@@ -1,24 +1,16 @@
package io.dddbyexamples.factory.shortages.prediction.monitoring.persistence
import groovy.transform.CompileStatic
import org.mockito.Mockito
import spock.lang.Specification
import org.springframework.beans.BeansException
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.BeanPostProcessor
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.cloud.contract.wiremock.restdocs.SpringCloudContractRestDocs
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
import spock.lang.Specification
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.MOCK
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
@@ -31,18 +23,21 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
// would love to get rid of this
@AutoConfigureTestDatabase
@AutoConfigureRestDocs
class ShortagesDaoTest extends Specification {
@ActiveProfiles("test")
class ShortagesDaoSpec extends Specification {
@Autowired ShortagesDao shortagesDao
@Autowired MockMvc mockMvc
@Autowired
ShortagesDao shortagesDao
@Autowired
MockMvc mockMvc
def "should find ref by no"() {
given:
Config.defaultStubbing(shortagesDao)
expect:
mockMvc.perform(get("/shortages?refNo=1"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("find_ref_by_no",
SpringCloudContractRestDocs.dslContract()))
}
def "should find ref by no"() {
given:
Config.defaultStubbing(shortagesDao)
expect:
mockMvc.perform(get("/shortages?refNo=1"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("find_ref_by_no",
SpringCloudContractRestDocs.dslContract()))
}
}

View File

@@ -1,8 +1,6 @@
apply plugin: 'groovy'
apply plugin: "jacoco"
dependencies {
compile(project(":shared-kernel-model"))
compile("org.projectlombok:lombok:1.16.18")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4")
}
}

View File

@@ -16,7 +16,7 @@
<distribution.management.release.url>http://localhost:8081/artifactory/libs-release-local</distribution.management.release.url>
<distribution.management.snapshot.url>http://localhost:8081/artifactory/libs-snapshot-local</distribution.management.snapshot.url>
<repo.with.binaries>http://localhost:8081/artifactory/libs-release-local</repo.with.binaries>
<maven-surefire.version>2.21.0</maven-surefire.version>
<maven-surefire.version>2.22.0</maven-surefire.version>
</properties>
<!-- [PIPELINE] -->
@@ -42,7 +42,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<version>1.18.0</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -72,6 +72,7 @@
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
@@ -79,7 +80,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<version>2.22.0</version>
<configuration>
<useFile>false</useFile>
<includes>
@@ -91,7 +92,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<version>0.8.1</version>
<executions>
<execution>
<goals>