Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
dartartem committed Dec 6, 2017
1 parent 6150ad1 commit 90faddd
Show file tree
Hide file tree
Showing 55 changed files with 274 additions and 67 deletions.
4 changes: 3 additions & 1 deletion _build-and-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ set -e

docker-compose -f docker-compose-${DATABASE?}.yml down -v

docker-compose -f docker-compose-${DATABASE?}.yml up -d --build zookeeper ${DATABASE?} kafka cdcservice
docker-compose -f docker-compose-${DATABASE?}.yml up -d --build zookeeper ${DATABASE?} kafka

./wait-for-${DATABASE?}.sh

docker-compose -f docker-compose-${DATABASE?}.yml up -d --build cdcservice

./wait-for-services.sh $DOCKER_HOST_IP "8099"

./gradlew -x :end-to-end-tests:test build
Expand Down
5 changes: 0 additions & 5 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@ dependencies {

compile "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion"
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
compile 'javax.el:javax.el-api:2.2.5'

compile "com.fasterxml.jackson.core:jackson-core:2.4.3"
compile "com.fasterxml.jackson.core:jackson-databind:2.4.3"
}

5 changes: 5 additions & 0 deletions customer-backend/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies {
compile project(":common")
compile project(":customer-api")
compile project(":common-swagger")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerCommandHandler;
import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerService;
import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web.CustomerWebConfiguration;
import io.eventuate.tram.commands.consumer.CommandDispatcher;
import io.eventuate.tram.sagas.participant.SagaCommandDispatcher;
import io.eventuate.tram.sagas.participant.SagaLockManager;
Expand All @@ -14,7 +13,7 @@
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@Configuration
@Import({SagaParticipantConfiguration.class, CustomerWebConfiguration.class})
@Import(SagaParticipantConfiguration.class)
@EnableJpaRepositories
@EnableAutoConfiguration
public class CustomerConfiguration {
Expand Down
22 changes: 0 additions & 22 deletions customer-common/build.gradle

This file was deleted.

5 changes: 1 addition & 4 deletions customer-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
dependencies {
compile project(":common")
compile project(":common-swagger")
compile project(":customer-common")

compile project(":customer-web")

compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers;

import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web.CustomerWebConfiguration;
import io.eventuate.jdbckafka.TramJdbcKafkaConfiguration;
import io.eventuate.tram.commands.common.ChannelMapping;
import io.eventuate.tram.commands.common.DefaultChannelMapping;
Expand All @@ -16,6 +17,7 @@
@SpringBootApplication
@Configuration
@Import({CustomerConfiguration.class,
CustomerWebConfiguration.class,
TramEventsPublisherConfiguration.class,
TramCommandProducerConfiguration.class,
SagaOrchestratorConfiguration.class,
Expand Down
3 changes: 3 additions & 0 deletions customer-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM java:openjdk-8u111-alpine
CMD java ${JAVA_OPTS} -jar customer-service-*.jar
COPY build/libs/customer-service-*.jar .
4 changes: 4 additions & 0 deletions customer-web/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
compile project(":common-swagger")
compile project(":customer-backend")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web;

import io.eventuate.examples.tram.sagas.ordersandcustomers.commondomain.Money;

public class CreateCustomerRequest {
private String name;
private Money creditLimit;

public CreateCustomerRequest() {
}

public CreateCustomerRequest(String name, Money creditLimit) {

this.name = name;
this.creditLimit = creditLimit;
}


public String getName() {
return name;
}

public Money getCreditLimit() {
return creditLimit;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web;


public class CreateCustomerResponse {
private Long customerId;

public CreateCustomerResponse() {
}

public CreateCustomerResponse(Long customerId) {
this.customerId = customerId;
}

public Long getCustomerId() {
return customerId;
}

public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web;

import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.domain.Customer;
import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CustomerController {

private CustomerService customerService;

@Autowired
public CustomerController(CustomerService customerService) {
this.customerService = customerService;
}

@RequestMapping(value = "/customers", method = RequestMethod.POST)
public CreateCustomerResponse createCustomer(@RequestBody CreateCustomerRequest createCustomerRequest) {
Customer customer = customerService.createCustomer(createCustomerRequest.getName(), createCustomerRequest.getCreditLimit());
return new CreateCustomerResponse(customer.getId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.customers.web;

import io.eventuate.examples.tram.sagas.ordersandcustomers.commonswagger.CommonSwaggerConfiguration;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

@Configuration
@ComponentScan
@Import(CommonSwaggerConfiguration.class)
public class CustomerWebConfiguration {

@Bean
public HttpMessageConverters customConverters() {
HttpMessageConverter<?> additional = new MappingJackson2HttpMessageConverter();
return new HttpMessageConverters(additional);
}
}
5 changes: 2 additions & 3 deletions end-to-end-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
dependencies {
compile project(":customer-common")
compile project(":order-common")
compile project(":customer-web")
compile project(":order-web")

testCompile "io.eventuate.tram.core:eventuate-tram-in-memory:$eventuateTramVersion"
testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
}

4 changes: 2 additions & 2 deletions integration-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
compile project(":customer-common")
compile project(":order-common")
compile project(":customer-backend")
compile project(":order-backend")

testCompile "io.eventuate.tram.core:eventuate-tram-in-memory:$eventuateTramVersion"
testCompile "io.eventuate.tram.sagas:eventuate-tram-sagas-in-memory:$eventuateTramSagasVersion"
Expand Down
6 changes: 6 additions & 0 deletions order-backend/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
compile project(":customer-api")
compile project(":common-swagger")
}


23 changes: 0 additions & 23 deletions order-common/build.gradle

This file was deleted.

4 changes: 1 addition & 3 deletions order-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
dependencies {
compile project(":common")
compile project(":common-swagger")
compile project(":order-common")
compile project(":order-web")

compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"

Expand Down
3 changes: 3 additions & 0 deletions order-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM java:openjdk-8u111-alpine
CMD java ${JAVA_OPTS} -jar order-service-*.jar
COPY build/libs/order-service-*.jar .
6 changes: 6 additions & 0 deletions order-web/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
compile project(":common-swagger")
compile project(":order-backend")
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web;


import io.eventuate.examples.tram.sagas.ordersandcustomers.commondomain.Money;

public class CreateOrderRequest {
private Money orderTotal;
private Long customerId;

public CreateOrderRequest() {
}

public CreateOrderRequest(Long customerId, Money orderTotal) {
this.customerId = customerId;
this.orderTotal = orderTotal;
}

public Money getOrderTotal() {
return orderTotal;
}

public Long getCustomerId() {
return customerId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web;


public class CreateOrderResponse {
private Long orderId;

public CreateOrderResponse() {
}

public CreateOrderResponse(Long orderId) {
this.orderId = orderId;
}

public Long getOrderId() {
return orderId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web;


import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.domain.OrderState;

public class GetOrderResponse {
private Long orderId;
private OrderState orderState;

public GetOrderResponse() {
}

public GetOrderResponse(Long orderId, OrderState orderState) {
this.orderId = orderId;
this.orderState = orderState;
}

public Long getOrderId() {
return orderId;
}

public void setOrderId(Long orderId) {
this.orderId = orderId;
}

public OrderState getOrderState() {
return orderState;
}

public void setOrderState(OrderState orderState) {
this.orderState = orderState;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.eventuate.examples.tram.sagas.ordersandcustomers.orders.web;

import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.common.OrderDetails;
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.domain.Order;
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.domain.OrderRepository;
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderController {

private OrderService orderService;
private OrderRepository orderRepository;

@Autowired
public OrderController(OrderService orderService, OrderRepository orderRepository) {
this.orderService = orderService;
this.orderRepository = orderRepository;
}

@RequestMapping(value = "/orders", method = RequestMethod.POST)
public CreateOrderResponse createOrder(@RequestBody CreateOrderRequest createOrderRequest) {
Order order = orderService.createOrder(new OrderDetails(createOrderRequest.getCustomerId(), createOrderRequest.getOrderTotal()));
return new CreateOrderResponse(order.getId());
}

@RequestMapping(value="/orders/{orderId}", method= RequestMethod.GET)
public ResponseEntity<GetOrderResponse> getOrder(@PathVariable Long orderId) {

Order order = orderRepository.findOne(orderId);

if (order == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} else {
return new ResponseEntity<>(new GetOrderResponse(order.getId(), order.getState()), HttpStatus.OK);
}
}
}
Loading

0 comments on commit 90faddd

Please sign in to comment.