Skip to content

Commit

Permalink
Merge pull request microservices-patterns#108 from dartartem/development
Browse files Browse the repository at this point in the history
Upgraded eventuate dependencies
  • Loading branch information
cer authored May 26, 2021
2 parents a835e23 + 7ccd9a1 commit 38bd5c3
Show file tree
Hide file tree
Showing 28 changed files with 91 additions and 90 deletions.
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ This can take a while.

Use the services Swagger UIs to invoke the services.

* Create consumer - `http://localhost:8081/swagger-ui.html`
* Create a restaurant - `http://localhost:8084/swagger-ui.html`
* Create an order - `http://localhost:8082/swagger-ui.html`
* View the order - `http://localhost:8082/swagger-ui.html`
* View the order history - `http://localhost:8086/swagger-ui.html`
* Create consumer - `http://localhost:8081/swagger-ui/index.html`
* Create a restaurant - `http://localhost:8084/swagger-ui/index.html`
* Create an order - `http://localhost:8082/swagger-ui/index.html`
* View the order - `http://localhost:8082/swagger-ui/index.html`
* View the order history - `http://localhost:8086/swagger-ui/index.html`

You can also access the application via the `API Gateway` at `http://localhost:8087`.
However, currently it doesn't have a Swagger UI so you will have to use `curl`, for example.
Expand Down
9 changes: 1 addition & 8 deletions common-swagger/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
dependencies {
compile ("io.springfox:springfox-swagger2:2.8.0") {
exclude group: "org.springframework"
}
compile ("io.springfox:springfox-swagger-ui:2.8.0"){
exclude group: "org.springframework"
}
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compile project(":ftgo-common")
compile "io.eventuate.util:eventuate-util-spring-swagger:$eventuateUtilVersion"
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
package net.chrisrichardson.eventstore.examples.customersandorders.commonswagger;

import com.fasterxml.classmate.TypeResolver;
import net.chrisrichardson.ftgo.common.Money;
import org.springframework.beans.factory.annotation.Autowired;
import io.eventuate.util.spring.swagger.EventuateSwaggerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.WildcardType;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.concurrent.CompletableFuture;

import static springfox.documentation.schema.AlternateTypeRules.newRule;

@Configuration
@EnableSwagger2
public class CommonSwaggerConfiguration {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("net.chrisrichardson.ftgo"))
.build()
.pathMapping("/")
.genericModelSubstitutes(ResponseEntity.class, CompletableFuture.class)
.alternateTypeRules(
newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class)),
newRule(Money.class, String.class)
)
.useDefaultResponseMessages(false)
;
public EventuateSwaggerConfig eventuateSwaggerConfig() {
return () -> "net.chrisrichardson.ftgo";
}

@Autowired
private TypeResolver typeResolver;

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.eventuate.tram.sagas.spring.inmemory.TramSagaInMemoryConfiguration;
import io.eventuate.tram.testutil.TestMessageConsumer;
import io.eventuate.tram.testutil.TestMessageConsumerFactory;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import io.eventuate.util.test.async.Eventually;
import net.chrisrichardson.ftgo.accountingservice.domain.Account;
import net.chrisrichardson.ftgo.accountingservice.domain.AccountCommand;
Expand All @@ -36,7 +37,7 @@
public class AccountingServiceCommandHandlerTest {

@Configuration
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({AccountingMessagingConfiguration.class,
TramCommandProducerConfiguration.class,
EmbeddedTestAggregateStoreConfiguration.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.eventuate.tram.spring.inmemory.TramInMemoryConfiguration;
import io.eventuate.tram.testutil.TestMessageConsumer;
import io.eventuate.tram.testutil.TestMessageConsumerFactory;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.common.Money;
import net.chrisrichardson.ftgo.common.PersonName;
import net.chrisrichardson.ftgo.consumerservice.api.ValidateOrderByConsumer;
Expand All @@ -17,6 +18,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -42,6 +44,7 @@ public class ConsumerServiceInMemoryIntegrationTest {
@Import({ConsumerWebConfiguration.class,
TramCommandProducerConfiguration.class,
TramInMemoryConfiguration.class})
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
public static class TestConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package net.chrisrichardson.ftgo.deliveryservice;

import io.eventuate.common.spring.jdbc.EventuateTransactionTemplateConfiguration;
import io.eventuate.tram.events.publisher.DomainEventPublisher;
import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration;
import io.eventuate.tram.spring.inmemory.TramInMemoryConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.deliveryservice.domain.DeliveryRepository;
import net.chrisrichardson.ftgo.deliveryservice.domain.DeliveryServiceTestData;
import net.chrisrichardson.ftgo.deliveryservice.domain.RestaurantRepository;
Expand Down Expand Up @@ -37,11 +39,12 @@ public class DeliveryServiceInProcessComponentTest {
private long orderId;

@Configuration
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({DeliveryServiceMessagingConfiguration.class,
DeliveryServiceWebConfiguration.class,
TramInMemoryConfiguration.class,
TramEventsPublisherConfiguration.class
TramEventsPublisherConfiguration.class,
EventuateTransactionTemplateConfiguration.class
})
public static class Config {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.eventuate.tram.events.publisher.DomainEventPublisher;
import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration;
import io.eventuate.tram.spring.jdbckafka.TramJdbcKafkaConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.deliveryservice.domain.DeliveryServiceTestData;
import net.chrisrichardson.ftgo.orderservice.api.OrderServiceChannels;
import net.chrisrichardson.ftgo.orderservice.api.events.OrderCreatedEvent;
Expand Down Expand Up @@ -33,7 +34,7 @@ public class DeliveryServiceOutOfProcessComponentTest {

@Configuration
@EnableJpaRepositories
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({TramJdbcKafkaConfiguration.class, TramEventsPublisherConfiguration.class
})
public static class Config {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.chrisrichardson.ftgo.deliveryservice.domain;

import io.eventuate.tram.spring.consumer.jdbc.TramConsumerJdbcAutoConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -22,7 +23,7 @@ public class CourierJpaTest {

@Configuration
@EnableJpaRepositories
@EnableAutoConfiguration(exclude = TramConsumerJdbcAutoConfiguration.class)
@EnableAutoConfiguration(exclude = {TramConsumerJdbcAutoConfiguration.class, CommonSwaggerConfiguration.class})
public static class Config {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.chrisrichardson.ftgo.deliveryservice.domain;

import io.eventuate.tram.spring.consumer.jdbc.TramConsumerJdbcAutoConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -18,7 +19,7 @@ public class DeliveryJpaTest {

@Configuration
@EnableJpaRepositories
@EnableAutoConfiguration(exclude = TramConsumerJdbcAutoConfiguration.class)
@EnableAutoConfiguration(exclude = {TramConsumerJdbcAutoConfiguration.class, CommonSwaggerConfiguration.class})
public static class Config {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.chrisrichardson.ftgo.deliveryservice.domain;

import io.eventuate.tram.spring.consumer.jdbc.TramConsumerJdbcAutoConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -19,7 +20,7 @@ public class RestaurantJpaTest {

@Configuration
@EnableJpaRepositories
@EnableAutoConfiguration(exclude = TramConsumerJdbcAutoConfiguration.class)
@EnableAutoConfiguration(exclude = {TramConsumerJdbcAutoConfiguration.class, CommonSwaggerConfiguration.class})
public static class Config {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jayway.restassured.config.ObjectMapperConfig;
import com.jayway.restassured.config.RestAssuredConfig;
import io.eventuate.common.json.mapper.JSonMapper;
import io.eventuate.util.test.async.UrlTesting;
import net.chrisrichardson.ftgo.apis.model.consumerservice.CreateConsumerRequest;
import net.chrisrichardson.ftgo.apis.model.consumerservice.PersonName;
import net.chrisrichardson.ftgo.apis.model.restaurantservice.CreateRestaurantRequest;
Expand All @@ -23,6 +24,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Collections;

Expand Down Expand Up @@ -146,6 +148,17 @@ public void shouldDeliverOrder() {

}

@Test
public void testSwaggerUiUrls() throws IOException {
testSwaggerUiUrl(8081);
testSwaggerUiUrl(8082);
testSwaggerUiUrl(8084);
testSwaggerUiUrl(8086);
}

private void testSwaggerUiUrl(int port) throws IOException {
UrlTesting.assertUrlStatusIsOk("localhost", port, "/swagger-ui/index.html");
}

private void reviseOrder() {
reviseOrder(orderId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.chrisrichardson.ftgo.kitchenservice.contract;

import io.eventuate.common.spring.jdbc.EventuateTransactionTemplateConfiguration;
import io.eventuate.tram.events.publisher.DomainEventPublisher;
import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration;
import io.eventuate.tram.spring.inmemory.TramInMemoryConfiguration;
import io.eventuate.tram.spring.cloudcontractsupport.EventuateContractVerifierConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.common.CommonJsonMapperInitializer;
import net.chrisrichardson.ftgo.kitchenservice.api.TicketDetails;
import net.chrisrichardson.ftgo.kitchenservice.api.events.TicketAcceptedEvent;
Expand Down Expand Up @@ -32,8 +34,8 @@ public abstract class DeliveryserviceMessagingBase {
}

@Configuration
@EnableAutoConfiguration
@Import({EventuateContractVerifierConfiguration.class, TramEventsPublisherConfiguration.class, TramInMemoryConfiguration.class})
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({EventuateContractVerifierConfiguration.class, TramEventsPublisherConfiguration.class, TramInMemoryConfiguration.class, EventuateTransactionTemplateConfiguration.class})
public static class TestConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package net.chrisrichardson.ftgo.kitchenservice.contract;

import io.eventuate.tram.spring.cloudcontractsupport.EventuateContractVerifierConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.kitchenservice.api.TicketDetails;
import net.chrisrichardson.ftgo.kitchenservice.domain.KitchenService;
import net.chrisrichardson.ftgo.kitchenservice.domain.Ticket;
import net.chrisrichardson.ftgo.kitchenservice.messagehandlers.KitchenServiceMessageHandlersConfiguration;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier;
Expand All @@ -30,6 +32,7 @@
public abstract class MessagingBase {

@Configuration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({KitchenServiceMessageHandlersConfiguration.class, EventuateContractVerifierConfiguration.class})
public static class TestConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.eventuate.tram.sagas.spring.inmemory.TramSagaInMemoryConfiguration;
import io.eventuate.tram.testutil.TestMessageConsumer;
import io.eventuate.tram.testutil.TestMessageConsumerFactory;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.common.Money;
import net.chrisrichardson.ftgo.kitchenservice.api.CreateTicket;
import net.chrisrichardson.ftgo.kitchenservice.api.TicketDetails;
Expand Down Expand Up @@ -40,7 +41,7 @@ public class KitchenServiceInMemoryIntegrationTest {
private int port;

@Configuration
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({KitchenServiceWebConfiguration.class, KitchenServiceMessageHandlersConfiguration.class,
TramCommandProducerConfiguration.class,
TramSagaInMemoryConfiguration.class})
Expand Down
1 change: 0 additions & 1 deletion ftgo-order-history-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ dependencies {

dockerCompose {

startedServices = ['not-used']

integrationTests {
startedServices = ["dynamodblocal", "dynamodblocal-init"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.chrisrichardson.ftgo.cqrs.orderhistory.dynamodb;

import io.eventuate.common.json.mapper.JSonMapper;
import io.eventuate.common.spring.jdbc.EventuateTransactionTemplateConfiguration;
import io.eventuate.tram.spring.inmemory.TramInMemoryConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.common.Money;
import net.chrisrichardson.ftgo.cqrs.orderhistory.OrderHistory;
import net.chrisrichardson.ftgo.cqrs.orderhistory.OrderHistoryDao;
Expand Down Expand Up @@ -35,9 +37,9 @@
public class OrderHistoryDaoDynamoDbTest {

@Configuration
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@ComponentScan
@Import({OrderHistoryDynamoDBConfiguration.class, TramInMemoryConfiguration.class})
@Import({OrderHistoryDynamoDBConfiguration.class, TramInMemoryConfiguration.class, EventuateTransactionTemplateConfiguration.class})
static public class OrderHistoryDaoDynamoDbTestConfiguration {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.eventuate.tram.messaging.common.ChannelMapping;
import io.eventuate.tram.messaging.common.DefaultChannelMapping;
import io.eventuate.tram.spring.cloudcontractsupport.EventuateContractVerifierConfiguration;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import net.chrisrichardson.ftgo.cqrs.orderhistory.OrderHistoryDao;
import net.chrisrichardson.ftgo.cqrs.orderhistory.dynamodb.Order;
import net.chrisrichardson.ftgo.cqrs.orderhistory.dynamodb.SourceEvent;
Expand Down Expand Up @@ -43,7 +44,7 @@
public class OrderHistoryEventHandlersTest {

@Configuration
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({OrderHistoryServiceMessagingConfiguration.class,
TramCommandProducerConfiguration.class,
TramInMemoryCommonConfiguration.class,
Expand Down
1 change: 0 additions & 1 deletion ftgo-order-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ componentTest.dependsOn(assemble)

dockerCompose {

startedServices = [ 'not-used']

integrationTests {
startedServices = [ 'mysql']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.eventuate.tram.sagas.testing.SagaParticipantStubManager;
import io.eventuate.tram.sagas.spring.testing.SagaParticipantStubManagerConfiguration;
import io.eventuate.tram.testing.MessageTracker;
import io.eventuate.util.spring.swagger.CommonSwaggerConfiguration;
import io.restassured.response.Response;
import net.chrisrichardson.ftgo.accountservice.api.AuthorizeCommand;
import net.chrisrichardson.ftgo.common.CommonJsonMapperInitializer;
Expand Down Expand Up @@ -67,7 +68,7 @@ protected String baseUrl(String path) {
}

@Configuration
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = CommonSwaggerConfiguration.class)
@Import({TramJdbcKafkaConfiguration.class, SagaParticipantStubManagerConfiguration.class})
@EnableJpaRepositories(basePackageClasses = RestaurantRepository.class) // Need to verify that the restaurant has been created. Replace with verifyRestaurantCreatedInOrderService
@EntityScan(basePackageClasses = Order.class)
Expand Down
Loading

0 comments on commit 38bd5c3

Please sign in to comment.