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-development-with-micronaut-libraries
  • Loading branch information
dartartem committed Mar 13, 2020
2 parents c21c100 + 55cd590 commit 7f25e72
Show file tree
Hide file tree
Showing 75 changed files with 978 additions and 206 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Expand Up @@ -9,6 +9,7 @@ buildscript {
classpath "com.avast.gradle:gradle-docker-compose-plugin:$dockerComposePluginVersion"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:$springCloudContractDependenciesVersion"
classpath "com.avast.gradle:gradle-docker-compose-plugin:$dockerComposePluginVersion"
classpath "io.spring.gradle:dependency-management-plugin:$springDependencyManagementPluginVersion"
}

}
Expand Down Expand Up @@ -38,7 +39,7 @@ subprojects {
jcenter()

maven {
url 'https://repo.spring.io/libs-milestone'
url 'https://jitpack.io'
}

maven {
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/build.gradle
Expand Up @@ -2,6 +2,10 @@ test.enabled=false

repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}

dependencies {
Expand All @@ -10,4 +14,6 @@ dependencies {
compile 'commons-lang:commons-lang:2.6'

compile 'org.jsonschema2pojo:jsonschema2pojo-core:1.0.1'

compile "gradle.plugin.org.hidetake:gradle-swagger-generator-plugin:2.18.1"
}
12 changes: 11 additions & 1 deletion buildSrc/src/main/groovy/FtgoApiDependencyResolverPlugin.groovy
@@ -1,5 +1,6 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency

class FtgoApiDependencyResolverPlugin implements Plugin<Project> {

Expand All @@ -12,10 +13,19 @@ class FtgoApiDependencyResolverPlugin implements Plugin<Project> {

project.configurations.implementation.extendsFrom(c)

project.task("ftgoResolveAPIDependencies",
def resolveTask = project.task("ftgoResolveAPIDependencies",
type: FtgoResolveAPIDependencies,
group: 'build setup',
description: "fetch API dependencies")

project.afterEvaluate {
project.configurations.ftgoApiSpecification.allDependencies.each {
if (it instanceof DefaultProjectDependency) {
def buildTask = it.dependencyProject.tasks.getByPath("build")
resolveTask.dependsOn(buildTask)
}
}
}
}

}
22 changes: 22 additions & 0 deletions buildSrc/src/main/groovy/FtgoOpenApiCodeGenPlugin.groovy
@@ -0,0 +1,22 @@
import org.gradle.api.Plugin
import org.gradle.api.Project

class FtgoOpenApiCodeGenPlugin implements Plugin<Project> {

@Override
void apply(Project project) {
project.pluginManager.apply("org.hidetake.swagger.generator")
project.apply(plugin: FtgoApiDependencyResolverPlugin)

project.afterEvaluate {
project.swaggerSources.each {
def name = it.name
project.swaggerSources[name].code.dependsOn(project.tasks.getByPath("ftgoResolveAPIDependencies"))
project.compileJava.dependsOn(project.swaggerSources[name].code)
project.sourceSets.main.java.srcDir "${project.swaggerSources[name].code.outputDir}/src/main/java"
project.sourceSets.main.resources.srcDir "${project.swaggerSources[name].code.outputDir}/src/main/resources"
}
}

}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/FtgoServicePlugin.groovy
Expand Up @@ -25,7 +25,7 @@ class FtgoServicePlugin implements Plugin<Project> {
project.dependencies {
compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
compile 'org.springframework.cloud:spring-cloud-starter-zipkin'
compile 'io.zipkin.brave:brave-bom:4.17.1'
compile "io.zipkin.brave:brave-bom:4.17.1"

compile "io.eventuate.tram.core:eventuate-tram-spring-cloud-sleuth-integration:${project.ext.eventuateTramVersion}"
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Expand Up @@ -23,7 +23,7 @@ services:
- MYSQL_USER=mysqluser
- MYSQL_PASSWORD=mysqlpw
cdc-service:
image: eventuateio/eventuate-cdc-service:0.6.0.RC2
image: eventuateio/eventuate-cdc-service:0.6.0.RC3
ports:
- "8099:8080"
depends_on:
Expand Down
12 changes: 0 additions & 12 deletions ftgo-accounting-service-contracts/build.gradle
@@ -1,15 +1,3 @@
buildscript {
dependencies {
// if using Stub Runner (consumer side) only remove this dependency
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:$springCloudContractDependenciesVersion"
}
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
}

apply plugin: 'spring-cloud-contract'
apply plugin: 'maven-publish'
Expand Down
20 changes: 3 additions & 17 deletions ftgo-api-gateway/build.gradle
@@ -1,14 +1,3 @@
buildscript {
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:$springDependencyManagementPluginVersion"
}
}
}


apply plugin: "io.spring.dependency-management"

Expand All @@ -29,9 +18,6 @@ configurations.all {

repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven {
url 'http://oss.jfrog.org/oss-snapshot-local/'
}
Expand All @@ -47,9 +33,9 @@ dependencies {
compile 'org.springframework.cloud:spring-cloud-starter-gateway'
compile "org.apache.commons:commons-lang3:3.6"

// compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
//compile 'org.springframework.cloud:spring-cloud-starter-zipkin'
// compile 'io.zipkin.brave:brave-bom:4.17.1'
compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
compile 'org.springframework.cloud:spring-cloud-starter-zipkin'
compile "io.zipkin.brave:brave-bom:4.17.1"

compile "io.micrometer:micrometer-registry-prometheus:$micrometerVersion"
compile "org.springframework.boot:spring-boot-starter-actuator"
Expand Down
1 change: 0 additions & 1 deletion ftgo-api-gateway/src/main/resources/application.properties
Expand Up @@ -7,6 +7,5 @@ logging.level.com.github.tomakehurst.wiremock=TRACE
management.endpoints.web.exposure.include=health,prometheus

spring.sleuth.sampler.probability=1.0
spring.sleuth.web.skipPattern=(^health.*)

# routes
12 changes: 0 additions & 12 deletions ftgo-consumer-service-contracts/build.gradle
@@ -1,15 +1,3 @@
buildscript {
dependencies {
// if using Stub Runner (consumer side) only remove this dependency
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:$springCloudContractDependenciesVersion"
}
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
}

apply plugin: 'spring-cloud-contract'
apply plugin: 'maven-publish'
Expand Down
9 changes: 4 additions & 5 deletions ftgo-consumer-service/build.gradle
Expand Up @@ -2,10 +2,9 @@

apply plugin: FtgoServicePlugin

repositories {
maven {
url 'https://jitpack.io'
}
configurations.all {
// Out of date, conflicting JSON library
exclude group: "com.vaadin.external.google"
}

dependencies {
Expand Down Expand Up @@ -41,6 +40,6 @@ dependencies {

testCompile "com.atlassian.oai:swagger-request-validator-springmvc:${swaggerRequestValidatorVersion}"
testCompile 'io.rest-assured:spring-mock-mvc:3.0.6'
testCompile "com.github.everit-org.json-schema:org.everit.json.schema:1.12.0"
testCompile project(":ftgo-test-util-json-schema")

}
Expand Up @@ -2,11 +2,11 @@

import net.chrisrichardson.ftgo.common.CommonJsonMapperInitializer;
import net.chrisrichardson.ftgo.common.Money;
import org.junit.Test;

import net.chrisrichardson.ftgo.testutil.jsonschema.ValidatingJSONMapper;
import org.json.JSONObject;
import org.junit.Test;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

public class ValidateOrderByConsumerTest {

Expand Down
16 changes: 16 additions & 0 deletions ftgo-delivery-service/build.gradle
Expand Up @@ -7,8 +7,11 @@ apply plugin: 'docker-compose'

apply plugin: IntegrationTestsPlugin
apply plugin: ComponentTestsPlugin
apply plugin: FtgoJSONSchema2PojoPlugin

dependencies {
ftgoApiSpecification project(":ftgo-restaurant-service-api-spec")

compile project(":ftgo-delivery-service-api")
compile project(":ftgo-kitchen-service-api")
compile project(":ftgo-restaurant-service-api")
Expand Down Expand Up @@ -49,3 +52,16 @@ dockerCompose {

componentTestsComposeUp.dependsOn(assemble)
dockerCompose.componentTests.isRequiredBy(componentTest)

ftgoJsonSchema2Pojo {

ftgoRestaurantService {
source = files("${ftgoApiSpecsDir}/ftgo-restaurant-service-api-spec/messages")
targetPackage = "net.chrisrichardson.ftgo.restaurantservice.events"
includeAdditionalProperties = false
generateBuilders = true
useLongIntegers = true
}

}

Expand Up @@ -12,7 +12,6 @@
import net.chrisrichardson.ftgo.orderservice.api.events.OrderCreatedEvent;
import net.chrisrichardson.ftgo.orderservice.api.events.OrderDetails;
import net.chrisrichardson.ftgo.restaurantservice.RestaurantServiceChannels;
import net.chrisrichardson.ftgo.restaurantservice.events.RestaurantCreated;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -21,7 +20,6 @@
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Collections;
Expand Down Expand Up @@ -120,7 +118,8 @@ private void createOrder() {
private void createRestaurant() {
restaurantId = System.currentTimeMillis();

domainEventPublisher.publish(RestaurantServiceChannels.RESTAURANT_EVENT_CHANNEL, restaurantId, Collections.singletonList(new RestaurantCreated("Delicious Indian", DeliveryServiceTestData.PICKUP_ADDRESS, null)));
domainEventPublisher.publish(RestaurantServiceChannels.RESTAURANT_EVENT_CHANNEL, restaurantId,
Collections.singletonList(RestaurantEventMother.makeRestaurantCreated()));

eventually(() -> assertTrue(restaurantRepository.findById(restaurantId).isPresent()));
}
Expand Down
Expand Up @@ -8,7 +8,6 @@
import net.chrisrichardson.ftgo.orderservice.api.events.OrderCreatedEvent;
import net.chrisrichardson.ftgo.orderservice.api.events.OrderDetails;
import net.chrisrichardson.ftgo.restaurantservice.RestaurantServiceChannels;
import net.chrisrichardson.ftgo.restaurantservice.events.RestaurantCreated;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,7 +23,8 @@

import static com.jayway.restassured.RestAssured.given;
import static io.eventuate.util.test.async.Eventually.eventually;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = DeliveryServiceOutOfProcessComponentTest.Config.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
Expand Down Expand Up @@ -106,7 +106,7 @@ private void createOrder() {
private void createRestaurant() {
restaurantId = System.currentTimeMillis();

domainEventPublisher.publish(RestaurantServiceChannels.RESTAURANT_EVENT_CHANNEL, restaurantId, Collections.singletonList(new RestaurantCreated("Delicious Indian", DeliveryServiceTestData.PICKUP_ADDRESS, null)));
domainEventPublisher.publish(RestaurantServiceChannels.RESTAURANT_EVENT_CHANNEL, restaurantId, Collections.singletonList(RestaurantEventMother.makeRestaurantCreated()));

sleep();
}
Expand Down
@@ -0,0 +1,13 @@
package net.chrisrichardson.ftgo.deliveryservice;

import net.chrisrichardson.ftgo.deliveryservice.domain.DeliveryServiceTestData;
import net.chrisrichardson.ftgo.deliveryservice.messaging.RestaurantEventMapper;
import net.chrisrichardson.ftgo.restaurantservice.events.RestaurantCreated;

public class RestaurantEventMother {
static RestaurantCreated makeRestaurantCreated() {
return new RestaurantCreated()
.withName("Delicious Indian")
.withAddress(RestaurantEventMapper.fromAddress(DeliveryServiceTestData.PICKUP_ADDRESS)).withMenu(null);
}
}
Expand Up @@ -36,7 +36,7 @@ public DomainEventHandlers domainEventHandlers() {
}

public void handleRestaurantCreated(DomainEventEnvelope<RestaurantCreated> dee) {
Address address = dee.getEvent().getAddress();
Address address = RestaurantEventMapper.toAddress(dee.getEvent().getAddress());
deliveryService.createRestaurant(Long.parseLong(dee.getAggregateId()), dee.getEvent().getName(), address);
}

Expand Down
@@ -0,0 +1,15 @@
package net.chrisrichardson.ftgo.deliveryservice.messaging;

import net.chrisrichardson.ftgo.common.Address;

public class RestaurantEventMapper {

public static Address toAddress(net.chrisrichardson.ftgo.restaurantservice.events.Address address) {
return new Address(address.getStreet1(), address.getStreet2(), address.getCity(), address.getState(), address.getZip());
}

public static net.chrisrichardson.ftgo.restaurantservice.events.Address fromAddress(net.chrisrichardson.ftgo.common.Address a) {
return new net.chrisrichardson.ftgo.restaurantservice.events.Address().withStreet1(a.getStreet1()).withStreet2(a.getStreet2()).withCity(a.getCity()).withZip(a.getZip());
}

}
26 changes: 14 additions & 12 deletions ftgo-end-to-end-tests/build.gradle
@@ -1,9 +1,12 @@
apply plugin: FtgoOpenApiCodeGenPlugin

/*
plugins {
id 'org.hidetake.swagger.generator' version '2.18.1'
}
*/

apply plugin: 'docker-compose'
apply plugin: FtgoApiDependencyResolverPlugin

dependencies {
swaggerCodegen 'org.openapitools:openapi-generator-cli:3.3.4' // or OpenAPI Generator
Expand All @@ -19,20 +22,19 @@ swaggerSources {
// Supports additionalProperties: https://github.com/swagger-api/swagger-codegen#to-generate-a-sample-client-library
}
}
restaurantService {
inputFile = file("${ftgoApiSpecsDir}/ftgo-restaurant-service-api-spec/web/ftgo-restaurant-service-swagger.json")
code {
language = 'java'
configFile = file('swagger-codegen-config/restaurant-service.json')
components = ['models']
}
}
}

swaggerSources.consumerService.code.dependsOn ftgoResolveAPIDependencies

compileJava.dependsOn swaggerSources.consumerService.code

sourceSets.main.java.srcDir "${swaggerSources.consumerService.code.outputDir}/src/main/java"

// This is unnecessary

sourceSets.main.resources.srcDir "${swaggerSources.consumerService.code.outputDir}/src/main/resources"

dependencies {
ftgoApiSpecification project(":ftgo-consumer-service-api-spec")
ftgoApiSpecification project(":ftgo-restaurant-service-api-spec")

compile project(":ftgo-accounting-service-api")
compile project(":ftgo-consumer-service-api")
Expand All @@ -53,7 +55,7 @@ dependencies {
}

dockerCompose {

projectName = null
}

test.dependsOn(composeUp)

0 comments on commit 7f25e72

Please sign in to comment.