Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/microservice-pattern…
Browse files Browse the repository at this point in the history
…s/ftgo-application into wip-micronaut
  • Loading branch information
dartartem committed Dec 17, 2019
2 parents a9eed36 + 9be99aa commit 7b80513
Show file tree
Hide file tree
Showing 45 changed files with 387 additions and 154 deletions.
13 changes: 10 additions & 3 deletions build-and-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

KEEP_RUNNING=
ASSEMBLE_ONLY=
USE_EXISTING_CONTAINERS=

DATABASE_SERVICES="dynamodblocal mysql dynamodblocal-init"
if [ -z "$DOCKER_COMPOSE" ] ; then
Expand All @@ -16,8 +17,11 @@ while [ ! -z "$*" ] ; do
"--assemble-only" )
ASSEMBLE_ONLY=yes
;;
"--use-existing-containers" )
USE_EXISTING_CONTAINERS=yes
;;
"--help" )
echo ./build-and-test-all.sh --keep-running --assemble-only
echo ./build-and-test-all.sh --keep-running --assemble-only --use-existing-containers
exit 0
;;
esac
Expand All @@ -32,9 +36,12 @@ echo KEEP_RUNNING=$KEEP_RUNNING

./gradlew buildContracts

./gradlew testClasses
./gradlew compileAll

if [ -z "$USE_EXISTING_CONTAINERS" ] ; then
${DOCKER_COMPOSE?} down --remove-orphans -v
fi

${DOCKER_COMPOSE?} down --remove-orphans -v
${DOCKER_COMPOSE?} up -d --build ${DATABASE_SERVICES?}

./gradlew waitForMySql
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ apply plugin: WaitForMySqlPlugin
subprojects {

apply plugin: "java"
apply plugin: 'pmd'

// TODO apply plugin: 'pmd'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'
Expand Down Expand Up @@ -51,3 +52,7 @@ subprojects {
task buildContracts(type: GradleBuild) {
tasks = subprojects.collect { it.name }.findAll { it.endsWith("-contracts") }.collect { ":" + it + ":publish"}
}

task compileAll(type: GradleBuild) {
tasks = ["testClasses", "compileIntegrationTestJava", "compileComponentTestJava"]
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/groovy/ComponentTestsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class ComponentTestsPlugin implements Plugin<Project> {

@Override
void apply(Project project) {

project.apply(plugin: 'eclipse')

project.sourceSets {
componentTest {
java {
Expand All @@ -28,7 +28,7 @@ class ComponentTestsPlugin implements Plugin<Project> {
project.eclipse.classpath.plusConfigurations << project.configurations.componentTestCompile

project.task("componentTest", type: Test) {
testClassesDir = project.sourceSets.componentTest.output.classesDir
testClassesDirs = project.sourceSets.componentTest.output.classesDirs
classpath = project.sourceSets.componentTest.runtimeClasspath
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/IntegrationTestsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class IntegrationTestsPlugin implements Plugin<Project> {
}

project.task("integrationTest", type: Test) {
testClassesDir = project.sourceSets.integrationTest.output.classesDir
testClassesDirs = project.sourceSets.integrationTest.output.classesDirs
classpath = project.sourceSets.integrationTest.runtimeClasspath
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
terminationGracePeriodSeconds: 10
containers:
- name: ftgo-kafka
image: eventuateio/eventuateio-local-kafka:0.14.0
image: eventuateio/eventuate-kafka:0.3.0.RELEASE
env:
- name: KAFKA_HEAP_OPTS
value: -Xmx320m -Xms320m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
terminationGracePeriodSeconds: 10
containers:
- name: ftgo-zookeeper
image: eventuateio/eventuateio-local-zookeeper:0.14.0
image: eventuateio/eventuate-zookeeper:0.4.0.RELEASE
ports:
- containerPort: 2181
volumeMounts:
Expand Down
3 changes: 2 additions & 1 deletion ftgo-accounting-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ dependencies {


compile "io.eventuate.client.java:eventuate-client-java-spring:$eventuateClientVersion"
compile "io.eventuate.client.java:eventuate-client-java-jdbc-spring:$eventuateClientVersion"
compile "io.eventuate.local.java:eventuate-local-java-jdbc-spring:${eventuateLocalVersion}"

compile('org.apache.kafka:kafka-clients:2.3.0') {
force = true
}

testCompile "io.eventuate.client.java:eventuate-client-java-jdbc-spring:$eventuateClientVersion"
testCompile "io.eventuate.tram.core:eventuate-tram-in-memory-spring:$eventuateTramVersion"
testCompile "io.eventuate.util:eventuate-util-test:$eventuateUtilVersion"
testCompile "io.eventuate.tram.core:eventuate-tram-test-util:$eventuateTramVersion"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.eventuate.tram.commands.consumer.CommandDispatcher;
import io.eventuate.tram.commands.consumer.CommandDispatcherFactory;
import io.eventuate.tram.commands.spring.consumer.TramCommandConsumerConfiguration;
import io.eventuate.tram.consumer.common.DuplicateMessageDetector;
import io.eventuate.tram.consumer.jdbc.spring.TransactionalNoopDuplicateMessageDetectorConfiguration;
import io.eventuate.tram.events.spring.subscriber.TramEventSubscriberConfiguration;
import io.eventuate.tram.events.subscriber.DomainEventDispatcher;
import io.eventuate.tram.events.subscriber.DomainEventDispatcherFactory;
Expand All @@ -20,7 +20,7 @@

@Configuration
@EnableEventHandlers
@Import({AccountServiceConfiguration.class, CommonConfiguration.class, TramEventSubscriberConfiguration.class, TramCommandConsumerConfiguration.class})
@Import({AccountServiceConfiguration.class, CommonConfiguration.class, TramEventSubscriberConfiguration.class, TramCommandConsumerConfiguration.class, TransactionalNoopDuplicateMessageDetectorConfiguration.class})
public class AccountingMessagingConfiguration {

@Bean
Expand All @@ -45,11 +45,6 @@ public CommandDispatcher commandDispatcher(AccountingServiceCommandHandler targe
return commandDispatcherFactory.make(data.getCommandDispatcherId(), target.commandHandlers());
}

@Bean
public DuplicateMessageDetector duplicateMessageDetector() {
return new NoopDuplicateMessageDetector();
}

@Bean
public AccountServiceChannelConfiguration accountServiceChannelConfiguration() {
return new AccountServiceChannelConfiguration("accountCommandDispatcher", "accountCommandChannel");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ logging.level.org.springframework.orm.jpa=INFO
logging.level.org.hibernate.SQL=DEBUG
logging.level.io.eventuate=DEBUG
logging.level.net.chrisrichardson.ftgo=DEBUG
logging.level.io.eventuate.tram=TRACE
logging.level.io.eventuate.tram=DEBUG
spring.datasource.url=jdbc:mysql://${DOCKER_HOST_IP:localhost}/ftgo_accounting_service
spring.datasource.username=ftgo_accounting_service_user
spring.datasource.password=ftgo_accounting_service_password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import io.eventuate.tram.commands.spring.producer.TramCommandProducerConfiguration;
import io.eventuate.tram.events.publisher.DomainEventPublisher;
import io.eventuate.tram.events.spring.publisher.TramEventsPublisherConfiguration;
import io.eventuate.tram.inmemory.spring.TramInMemoryConfiguration;
import io.eventuate.tram.sagas.common.SagaCommandHeaders;
import io.eventuate.tram.sagas.inmemory.TramSagaInMemoryConfiguration;
import io.eventuate.tram.testutil.TestMessageConsumer;
import io.eventuate.tram.testutil.TestMessageConsumerFactory;
import io.eventuate.util.test.async.Eventually;
import net.chrisrichardson.ftgo.accountingservice.domain.Account;
import net.chrisrichardson.ftgo.accountingservice.domain.AccountCommand;
import net.chrisrichardson.ftgo.accountservice.api.AccountingServiceChannels;
import net.chrisrichardson.ftgo.accountservice.api.AuthorizeCommand;
import net.chrisrichardson.ftgo.common.Money;
import net.chrisrichardson.ftgo.consumerservice.domain.ConsumerCreated;
import io.eventuate.util.test.async.Eventually;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -25,17 +25,11 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.test.context.junit4.SpringRunner;

import javax.sql.DataSource;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = AccountingServiceCommandHandlerTest.AccountingServiceCommandHandlerTestConfiguration.class)
Expand All @@ -47,25 +41,13 @@ public class AccountingServiceCommandHandlerTest {
TramCommandProducerConfiguration.class,
EmbeddedTestAggregateStoreConfiguration.class,
TramEventsPublisherConfiguration.class, // TODO
TramInMemoryConfiguration.class})
TramSagaInMemoryConfiguration.class})
static public class AccountingServiceCommandHandlerTestConfiguration {

@Bean
public TestMessageConsumerFactory testMessageConsumerFactory() {
return new TestMessageConsumerFactory();
}

@Bean
public DataSource dataSource() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
return builder.setType(EmbeddedDatabaseType.H2)
.addScript("eventuate-tram-embedded-schema.sql")
.addScript("eventuate-tram-sagas-embedded.sql")
.addScript("eventuate-embedded-schema.sql")
.build();
}


}

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"swagger": "2.0",
"info": {
"description": "Api Documentation",
"version": "1.0",
"title": "Api Documentation",
"termsOfService": "urn:tos",
"contact": {},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
},
"host": "localhost:8081",
"basePath": "/",
"tags": [
{
"name": "consumer-controller",
"description": "Consumer Controller"
}
],
"paths": {
"/consumers": {
"post": {
"tags": [
"consumer-controller"
],
"summary": "create",
"operationId": "createUsingPOST",
"consumes": [
"application/json"
],
"produces": [
"*/*"
],
"parameters": [
{
"in": "body",
"name": "request",
"description": "request",
"required": true,
"schema": {
"$ref": "#/definitions/CreateConsumerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/CreateConsumerResponse"
}
}
}
}
},
"/consumers/{consumerId}": {
"get": {
"tags": [
"consumer-controller"
],
"summary": "get",
"operationId": "getUsingGET",
"produces": [
"*/*"
],
"parameters": [
{
"name": "consumerId",
"in": "path",
"description": "consumerId",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/GetConsumerResponse"
}
}
}
}
}
},
"definitions": {
"CreateConsumerRequest": {
"type": "object",
"properties": {
"name": {
"$ref": "#/definitions/PersonName"
}
},
"title": "CreateConsumerRequest"
},
"CreateConsumerResponse": {
"type": "object",
"properties": {
"consumerId": {
"type": "integer",
"format": "int64"
}
},
"title": "CreateConsumerResponse"
},
"GetConsumerResponse": {
"type": "object",
"properties": {
"consumerId": {
"type": "integer",
"format": "int64"
},
"name": {
"$ref": "#/definitions/PersonName"
}
},
"title": "GetConsumerResponse"
},
"PersonName": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
}
},
"required" : ["lastName", "firstName"],
"additionalProperties": true,
"title": "PersonName"
}
}
}
5 changes: 5 additions & 0 deletions ftgo-consumer-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ dependencies {
testCompile "io.eventuate.util:eventuate-util-test:$eventuateUtilVersion"
testCompile "io.eventuate.tram.core:eventuate-tram-test-util:$eventuateTramVersion"

testCompile "io.eventuate.tram.core:eventuate-tram-in-memory-spring:$eventuateTramVersion"
testCompile "io.eventuate.tram.sagas:eventuate-tram-sagas-in-memory-spring:$eventuateTramSagasVersion"
testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
testCompile "com.jayway.jsonpath:json-path:2.3.0"
testCompile "org.hamcrest:hamcrest:2.1"

testCompile "com.atlassian.oai:swagger-request-validator-springmvc:${swaggerRequestValidatorVersion}"
testCompile 'io.rest-assured:spring-mock-mvc:3.0.6'

}
Loading

0 comments on commit 7b80513

Please sign in to comment.