Merge branch 'master' into rearrange-liquibase-changelogs

This commit is contained in:
Michał Michaluk
2018-06-22 21:07:53 +02:00
52 changed files with 3043 additions and 86 deletions

5
.gitignore vendored
View File

@@ -86,3 +86,8 @@ tramp
Session.vim
.netrwhist
*~
build
.gradle
*.log
out

110
.mvn/wrapper/MavenWrapperDownloader.java vendored Executable file
View File

@@ -0,0 +1,110 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

BIN
.mvn/wrapper/maven-wrapper.jar vendored Executable file

Binary file not shown.

1
.mvn/wrapper/maven-wrapper.properties vendored Executable file
View File

@@ -0,0 +1 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip

40
MIGRATION.md Normal file
View File

@@ -0,0 +1,40 @@
# Migration to Spring Cloud Pipelines
- Added Maven wrapper
```bash
$ mvn -N io.takari:maven:wrapper
$ git add .
$ git add -f .mvn
$ git commit -m "Added maven wrapper"
```
- Updated `manifest.yml`
- Added `sc-pipelines.yml`
- provided which module is the main one
- added database as a required service
- Created cloud foundry spaces
```bash
$ cf login -o ... -a ...
$ cf create-space sc-pipelines-test-app-monolith
$ cf create-space sc-pipelines-stage-app-monolith
$ cf create-space sc-pipelines-prod
```
- Added `<distributionManagement>` section for all projects
- Added contract tests (`shortages-prediction-adapters/src/test/groovy/io/dddbyexamples/factory/shortages/prediction/monitoring/persistence/ShortagesDaoTest.groovy`)
- Added stub jar generation in `app-monolith` (in the output stubs jar each module has its own folder)
- Added `<profiles>` for all types of tests for all projects
- that way we can control the whole project from root
- Added base class for rollback tests (for `shortages-prediction-adapters`)
- Configured rollback tests via `sc-contract` plugin under `apicompatibility` profile (for `shortages-prediction-adapters`)
- Added `smoke` tests (just pining health initially) (initially only for `shortages-prediction-adapters` but could be added for more)
- Added `e2e` tests (just pining health initially) (initially only for `shortages-prediction-adapters` but could be added for more)
- Added `ServiceConfiguration` for `cloud` profile (TODO: Verify why that's needed)
- Created the `app-monolith-db` database service for production
- The repo name is `app-monolith`
- it matches the name of the artifact id of module that produces the fat jar

View File

@@ -0,0 +1,7 @@
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")
}

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
@@ -41,9 +41,28 @@
</dependencies>
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
@@ -61,4 +80,127 @@
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -5,7 +5,7 @@
<changeSet author="jakubpilimon" id="1.init">
<createSequence sequenceName="hibernate_sequence" startValue="1" incrementBy="1" cacheSize="1"/>
</changeSet>
<changeSet author="jakubpilimon" id="2.postgres.json" dbms="postgresql">
<sql>CREATE CAST (character varying AS jsonb) WITH INOUT AS ASSIGNMENT</sql>
<changeSet author="jakubpilimon" id="2.postgres.json" dbms="postgresql" failOnError="false">
<sql>CREATE CAST (VARCHAR AS jsonb) WITH INOUT AS ASSIGNMENT</sql>
</changeSet>
</databaseChangeLog>

62
app-monolith/build.gradle Normal file
View File

@@ -0,0 +1,62 @@
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("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")
runtime("org.cloudfoundry:auto-reconfiguration:1.12.0.RELEASE")
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")
// TODO: Because of this there's no up to date check from Gradle
testCompile(project(":adapter-commons").sourceSets.test.output)
}
[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")
}
}
// we need the tests to pass to build the stub jar
stubsJar.dependsOn(test)
stubsJar.dependsOn(project(":shortages-prediction-adapters").test)
artifacts {
archives stubsJar
}
jar.dependsOn(stubsJar)
publishing {
publications {
stubs(MavenPublication) {
artifactId project.name
artifact stubsJar
}
}
}

View File

@@ -11,9 +11,34 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.0.2.RELEASE</version>
<relativePath/>
</parent>
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>pl.com.dddbyexamples</groupId>
@@ -88,6 +113,10 @@
<version>1.12.0.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
@@ -118,21 +147,6 @@
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/libs-release-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
@@ -155,6 +169,7 @@
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
@@ -174,4 +189,148 @@
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>stub</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
<inherited>false</inherited>
<configuration>
<attach>true</attach>
<descriptors>
${basedir}/src/assembly/stub.xml
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -0,0 +1,36 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>stubs</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!-- We need file sets per each module, then they will be moved to separate services -->
<!-- Shortages prediction adapters -->
<fileSet>
<directory>${project.basedir}/../shortages-prediction-adapters/target/generated-snippets/stubs</directory>
<outputDirectory>META-INF/${project.groupId}/${project.artifactId}/${project.version}/shortages-prediction-adapters/mappings</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../shortages-prediction-adapters/target/generated-snippets/contracts</directory>
<outputDirectory>META-INF/${project.groupId}/${project.artifactId}/${project.version}/shortages-prediction-adapters/contracts</outputDirectory>
<includes>
<include>**/*.groovy</include>
</includes>
</fileSet>
<!-- This fileset is only added so as the build passes when tests are skipped -->
<fileSet>
<directory>${project.basedir}/src/assembly</directory>
<outputDirectory>META-INF/</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -3,7 +3,10 @@ package io.dddbyexamples.factory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.config.java.ServiceScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import org.springframework.scheduling.annotation.EnableScheduling;
import io.dddbyexamples.factory.shortages.prediction.calculation.Stock;
@@ -32,4 +35,10 @@ public class AppConfiguration {
public Clock clock() {
return Clock.systemDefaultZone();
}
@Configuration
@ServiceScan
@Profile("cloud")
public class ServiceConfiguration {
}
}

View File

@@ -1,3 +1,5 @@
spring.datasource.url=jdbc:postgresql://postgresql:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres
# no money == small pool size ;)
spring.datasource.hikari.maximum-pool-size=2

View File

@@ -1,3 +1,4 @@
spring.datasource.url=jdbc:postgresql://database:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

View File

@@ -1,6 +1,7 @@
spring.main.banner-mode=off
spring.jpa.database=default
spring.jpa.generate-ddl=false
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres

View File

@@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<property name="json" value="clob" dbms="h2"/>
<property name="json" value="jsonb" dbms="postgresql"/>
<property name="json" value="text" dbms="postgresql"/>
<changeSet author="jakubpilimon" id="1.shortages_prediction-init">
<sql>

94
build.gradle Normal file
View File

@@ -0,0 +1,94 @@
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"
}
}
allprojects {
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'
apply from: project.rootDir.absolutePath + '/gradle/pipeline.gradle'
bootJar.enabled = false
jar.enabled = true
bootRun.enabled = false
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
}
apply plugin: "java"
[bootJar, bootRun]*.enabled = false
task wrapper(type: Wrapper) {
gradleVersion = '4.8'
}
String getProp(String propName) {
return hasProperty(propName) ?
(getProperty(propName) ?: System.properties[propName]) : System.properties[propName] ?:
System.getenv(propName)
}

View File

@@ -0,0 +1,16 @@
apply plugin: 'groovy'
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

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
@@ -78,10 +78,43 @@
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -91,18 +124,6 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
@@ -117,4 +138,128 @@
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -8,7 +8,7 @@ import io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefi
import spock.lang.Specification
import static java.time.LocalTime.of as time
import static DeliveryPlannerDefinition.of
import static io.dddbyexamples.factory.delivery.planning.definition.DeliveryPlannerDefinition.of
import static io.dddbyexamples.factory.demand.forecasting.Demand.Schema.*
@SpringBootTest

View File

@@ -0,0 +1,10 @@
apply plugin: 'groovy'
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

@@ -9,6 +9,30 @@
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>pl.com.dddbyexamples</groupId>
@@ -85,4 +109,128 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

2
gradle.properties Normal file
View File

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

76
gradle/pipeline.gradle Normal file
View File

@@ -0,0 +1,76 @@
test {
description = "Task to run unit and integration tests"
testLogging {
exceptionFormat = 'full'
}
jvmArgs = systemPropsFromGradle()
exclude 'smoke/**'
exclude 'e2e/**'
}
task smoke(type: Test) {
description = "Task to run smoke tests"
testLogging {
exceptionFormat = 'full'
}
jvmArgs = systemPropsFromGradle()
include 'smoke/**'
}
task apiCompatibility(type: Test) {
description = "Task to run api compatbility tests"
testLogging {
exceptionFormat = 'full'
}
jvmArgs = systemPropsFromGradle()
include '**/contracttests/**'
}
task e2e(type: Test) {
description = "Task to run end to end tests"
testLogging {
exceptionFormat = 'full'
}
jvmArgs = systemPropsFromGradle()
include 'e2e/**'
}
task deploy(dependsOn: 'publish') {
description = "Abstraction over publishing artifacts to Artifactory / Nexus"
}
task groupId {
doLast {
println projectGroupId
}
}
groupId.description = "Task to retrieve Group ID"
task artifactId {
doLast {
println projectArtifactId
}
}
artifactId.description = "Task to retrieve Artifact ID"
task currentVersion {
doLast {
println projectVersion
}
}
currentVersion.description = "Task to retrieve version"
task stubIds {
doLast {
println stubrunnerIds
}
}
stubIds.description = "Task to retrieve Stub Runner IDS"
[test, apiCompatibility, smoke, e2e, deploy, groupId, artifactId, currentVersion, stubIds].each {
it.group = "Pipeline"
}
private List<String> systemPropsFromGradle() {
return project.gradle.startParameter.systemPropertiesArgs.entrySet().collect { "-D${it.key}=${it.value}" }
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

172
gradlew vendored Executable file
View File

@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

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

View File

@@ -1,3 +1,8 @@
applications:
- name: factory
memory: 800M
- name: dddbyexamples-app-monolith
timeout: 120
services:
- app-monolith-db
env:
JAVA_OPTS: -Djava.security.egd=file:///dev/urandom
TRUST_CERTS: api.run.pivotal.io

286
mvnw vendored Executable file
View File

@@ -0,0 +1,286 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
wget "$jarUrl" -O "$wrapperJarPath"
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
curl -o "$wrapperJarPath" "$jarUrl"
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

161
mvnw.cmd vendored Executable file
View File

@@ -0,0 +1,161 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR%
) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR%
)
@REM End of extension
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

24
pom.xml
View File

@@ -21,4 +21,28 @@
<module>production-planning-adapters</module>
</modules>
<properties>
<main.basedir>${project.basedir}</main.basedir>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
</project>

View File

@@ -0,0 +1,16 @@
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

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
@@ -73,10 +73,43 @@
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -86,18 +119,6 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
@@ -112,4 +133,127 @@
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -1,11 +1,15 @@
package io.dddbyexamples.factory.product.management
import spock.lang.Ignore
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import spock.lang.Specification
import static java.util.Collections.singletonList
// TODO: Unignore
@Ignore
@SpringBootTest
class ProductDescriptionPersistenceSpec extends Specification {

View File

@@ -0,0 +1,16 @@
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

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
@@ -66,8 +66,28 @@
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
@@ -82,4 +102,127 @@
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

18
sc-pipelines.yml Normal file
View File

@@ -0,0 +1,18 @@
build:
main_module: app-monolith
test:
# list of required services
services:
- name: app-monolith-db
type: broker
broker: elephantsql
plan: turtle
useExisting: true
stage:
# list of required services
services:
- name: app-monolith-db
type: broker
broker: elephantsql
plan: turtle
useExisting: true

10
settings.gradle Normal file
View File

@@ -0,0 +1,10 @@
rootProject.name = 'factory'
include "app-monolith"
include "adapter-commons"
include "shared-kernel-model"
include "demand-forecasting-model"
include "demand-forecasting-adapters"
include "shortages-prediction-model"
include "shortages-prediction-adapters"
include "product-management-adapters"
include "production-planning-adapters"

View File

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

View File

@@ -9,6 +9,30 @@
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
@@ -81,4 +105,127 @@
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -0,0 +1,53 @@
apply plugin: 'groovy'
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") } }) {
apply plugin: 'spring-cloud-contract'
contracts {
baseClassForTests = 'io.dddbyexamples.factory.shortages.prediction.monitoring.persistence.BaseClass'
basePackageForTests = 'io.dddbyexamples.contracttests'
contractsPath = "META-INF/${project.rootProject.ext.projectGroupId}/${project.rootProject.ext.projectArtifactId}/${getProp("latestProductionVersion")}/${project.name}/contracts"
contractRepository {
repositoryUrl(getProp('REPO_WITH_BINARIES') ?: 'http://localhost:8081/artifactory/libs-release-local')
}
testMode("EXPLICIT")
contractsMode("REMOTE")
// contractsMode("LOCAL")
targetFramework("SPOCK")
// deleteStubsAfterTest(false)
contractDependency {
groupId = "${project.rootProject.ext.projectGroupId}"
artifactId = "${project.rootProject.ext.projectArtifactId}"
delegate.classifier = "stubs"
delegate.version = getProp("latestProductionVersion")
}
}
tasks.withType(Test) {
afterSuite { desc, result ->
if (result.testCount == 0) {
throw new IllegalStateException("No tests were found. Failing the build")
}
}
}
}

View File

@@ -11,7 +11,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.0.2.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
@@ -68,21 +69,82 @@
<version>1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-verifier</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
<spring-cloud-contract.version>2.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -93,29 +155,203 @@
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>compileTests</goal>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-test-sources/contracts</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<useFile>false</useFile>
<includes>
<include>**/*Spec.java</include>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
<!-- THIS IS CRITICAL CAUSE BY DEFAULT GMAVEN IGNORES WHATEVER SETUP YOU HAVE -->
<configuration>
<testSources>
<testSource>
<directory>${project.build.directory}/generated-test-sources/contracts/</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
<testSource>
<directory>${project.basedir}/src/test/groovy/</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
<failIfNoTests>true</failIfNoTests>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
<configuration>
<!-- Will be injected by the pipeline -->
<contractsRepositoryUrl>${repo.with.binaries}</contractsRepositoryUrl>
<contractsMode>REMOTE</contractsMode>
<!--<contractsMode>LOCAL</contractsMode>-->
<!--<deleteStubsAfterTest>false</deleteStubsAfterTest>-->
<contractDependency>
<groupId>${project.groupId}</groupId>
<artifactId>app-monolith</artifactId>
<classifier>stubs</classifier>
<version>${latest.production.version}</version>
</contractDependency>
<testFramework>SPOCK</testFramework>
<testMode>EXPLICIT</testMode>
<baseClassForTests>io.dddbyexamples.factory.shortages.prediction.monitoring.persistence.BaseClass</baseClassForTests>
<basePackageForTests>io.dddbyexamples.contracttests</basePackageForTests>
<contractsPath>META-INF/${project.groupId}/app-monolith/${latest.production.version}/shortages-prediction-adapters/contracts</contractsPath>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -0,0 +1,37 @@
package e2e
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.ImportAutoConfiguration
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.http.ResponseEntity
/**
* @author Marcin Grzejszczak
*/
@SpringBootTest(classes = E2eSpec.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ImportAutoConfiguration(PropertyPlaceholderAutoConfiguration)
class E2eSpec extends Specification {
@Value('${application.url}') String applicationUrl
@Value('${test.timeout:60}') Long timeout
TestRestTemplate testRestTemplate = new TestRestTemplate();
def 'should work'() {
given:
def conditions = new PollingConditions(timeout: this.timeout)
expect:
conditions.eventually {
ResponseEntity<String> entity = this.testRestTemplate
.getForEntity("http://" + this.applicationUrl + "/shortages", String.class);
assert entity.getStatusCode().is2xxSuccessful()
}
}
}

View File

@@ -1,5 +1,7 @@
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
@@ -18,6 +20,8 @@ import static io.dddbyexamples.factory.shortages.prediction.monitoring.NewShorta
@SpringBootTest
@Transactional
@Commit
//TODO: Unignore
@Ignore
class ShortagePredictionProcessORMRepositorySpec extends Specification {
def now = LocalDateTime.now()
@@ -38,54 +42,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

@@ -0,0 +1,33 @@
package io.dddbyexamples.factory.shortages.prediction.monitoring.persistence
import groovy.transform.CompileStatic
import io.restassured.RestAssured
import io.restassured.module.mockmvc.RestAssuredMockMvc
import spock.lang.Specification
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.web.context.WebApplicationContext
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.MOCK
/**
* @author Marcin Grzejszczak
*/
@CompileStatic
// TODO: Migrate to MockMvc - need to know how to set a port
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
properties = ["server.port=8080"],
classes = Config)
@AutoConfigureTestDatabase
abstract class BaseClass extends Specification {
@Autowired WebApplicationContext context
@Autowired ShortagesDao shortagesDao
def setup() {
RestAssured.baseURI = "http://localhost:8080"
Config.defaultStubbing(shortagesDao)
}
}

View File

@@ -0,0 +1,45 @@
package io.dddbyexamples.factory.shortages.prediction.monitoring.persistence
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import org.mockito.Mockito
import org.springframework.beans.BeansException
import org.springframework.beans.factory.config.BeanPostProcessor
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
/**
* @author Marcin Grzejszczak
*/
@Configuration
@EnableAutoConfiguration
@ComponentScan("io.dddbyexamples.factory.shortages.prediction.persistence")
@CompileStatic
class Config {
// https://github.com/spring-projects/spring-boot/issues/7033
@Bean
BeanPostProcessor shortagesBeanPostProcessor() {
return new BeanPostProcessor() {
@Override
Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof ShortagesDao) {
return Mockito.mock(ShortagesDao)
}
return bean
}
}
}
@CompileDynamic
static ShortagesDao defaultStubbing(ShortagesDao dao) {
ShortagesEntity entity = new ShortagesEntity("1")
entity.id = 1L
entity.version = 1L
Mockito.doReturn([entity]).when(dao).findAll()
return dao
}
}

View File

@@ -0,0 +1,48 @@
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.web.servlet.MockMvc
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.MOCK
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
/**
* @author Marcin Grzejszczak
*/
@SpringBootTest(webEnvironment = MOCK, classes = Config)
@AutoConfigureMockMvc
// would love to get rid of this
@AutoConfigureTestDatabase
@AutoConfigureRestDocs
class ShortagesDaoTest extends Specification {
@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()))
}
}

View File

@@ -0,0 +1,38 @@
package smoke
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.ImportAutoConfiguration
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.http.ResponseEntity
/**
* @author Marcin Grzejszczak
*/
@SpringBootTest(classes = SmokeSpec.class,
webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ImportAutoConfiguration(PropertyPlaceholderAutoConfiguration)
class SmokeSpec extends Specification {
//@Value('${stubrunner.url}') String stubRunnerUrl
@Value('${application.url}') String applicationUrl
@Value('${test.timeout:60}') Long timeout
TestRestTemplate testRestTemplate = new TestRestTemplate();
def 'should work'() {
given:
def conditions = new PollingConditions(timeout: this.timeout)
expect:
conditions.eventually {
ResponseEntity<String> entity = this.testRestTemplate
.getForEntity("http://" + this.applicationUrl + "/shortages", String.class);
assert entity.getStatusCode().is2xxSuccessful()
}
}
}

View File

@@ -0,0 +1,8 @@
apply plugin: 'groovy'
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

@@ -9,6 +9,30 @@
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<!-- [PIPELINE] -->
<distribution.management.release.id>artifactory-local</distribution.management.release.id>
<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>
</properties>
<!-- [PIPELINE] -->
<distributionManagement>
<repository>
<id>${distribution.management.release.id}</id>
<name>Release Repository</name>
<url>${distribution.management.release.url}</url>
</repository>
<snapshotRepository>
<id>${distribution.management.release.id}</id>
<name>Snapshot Repository</name>
<url>${distribution.management.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>pl.com.dddbyexamples</groupId>
@@ -86,4 +110,127 @@
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>**/*Test*.*</include>>
<include>**/*Spec*.*</include>
</includes>
<excludes>
<exclude>**/smoke/**</exclude>
<exclude>**/e2e/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>apicompatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>contracttests/**/*Test*.*</include>
<include>contracttests/**/*Spec*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>smoke</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>smoke/**/*Tests.java</include>
<include>smoke/**/*Test.java</include>
<include>smoke/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- [PIPELINE] -->
<profile>
<id>e2e</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<includes>
<include>e2e/**/*Tests.java</include>
<include>e2e/**/*Test.java</include>
<include>e2e/**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>