Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cer committed Aug 20, 2018
1 parent 62aa45a commit 94ca6a3
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 10 deletions.
1 change: 1 addition & 0 deletions build-and-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ if [ -z "$ASSEMBLE_ONLY" ] ; then

# Component tests need to use the per-service database schema


SPRING_DATASOURCE_URL=jdbc:mysql://${DOCKER_HOST_IP?}/ftgoorderservice ./gradlew :ftgo-order-service:cleanComponentTest :ftgo-order-service:componentTest

# Reset the DB/messages
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
image: eventuateio/eventuateio-local-kafka:0.20.1.RELEASE
ports:
- 9092:9092
links:
depends_on:
- zookeeper
environment:
- ADVERTISED_HOST_NAME=${DOCKER_HOST_IP}
Expand Down
2 changes: 2 additions & 0 deletions dynamodblocal-init/create-dynamodb-tables.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /bin/bash -e

echo Initializing DynamoDB at endpoint ${AWS_DYNAMODB_ENDPOINT_URL}

if aws dynamodb --region us-west-1 --endpoint-url ${AWS_DYNAMODB_ENDPOINT_URL?} describe-table --table-name ftgo-order-history ; then
echo table exists
else
Expand Down
8 changes: 7 additions & 1 deletion eventuate-tram-spring-cloud-contract-support/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ dependencyManagement {
}

dependencies {
compile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
compile "io.eventuate.tram.core:eventuate-tram-messaging:$eventuateTramVersion"
compile "io.eventuate.tram.core:eventuate-tram-commands:$eventuateTramVersion"
compile "io.eventuate.tram.core:eventuate-tram-events:$eventuateTramVersion"

compile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
compile "org.springframework.cloud:spring-cloud-starter-contract-stub-runner"

compile "io.eventuate.util:eventuate-util-test:$eventuateUtilVersion"
}
5 changes: 0 additions & 5 deletions ftgo-api-gateway-graphql/src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ const typeDefs = gql`
consumerId : Int,
consumer: Consumer
restaurant: Restaurant
deliveryInfo : DeliveryInfo
# restaurant status
# payment status
}
type Restaurant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import net.chrisrichardson.ftgo.common.Money;
import net.chrisrichardson.ftgo.common.PersonName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Transactional
public class ConsumerService {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableJpaRepositories
@EnableAutoConfiguration
@Import({SagaParticipantConfiguration.class, TramEventsPublisherConfiguration.class, CommonConfiguration.class})
@EnableTransactionManagement
@ComponentScan
public class ConsumerServiceConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package net.chrisrichardson.ftgo.orderservice.domain;

import net.chrisrichardson.ftgo.orderservice.api.events.OrderState;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.support.TransactionTemplate;

import static net.chrisrichardson.ftgo.orderservice.OrderDetailsMother.CONSUMER_ID;
import static net.chrisrichardson.ftgo.orderservice.OrderDetailsMother.chickenVindalooLineItems;
import static net.chrisrichardson.ftgo.orderservice.RestaurantMother.AJANTA_ID;
import static net.chrisrichardson.ftgo.orderservice.RestaurantMother.AJANTA_RESTAURANT_MENU_ITEMS;
import static net.chrisrichardson.ftgo.orderservice.RestaurantMother.AJANTA_RESTAURANT_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = OrderJpaTestConfiguration.class)
public class RestaurantJpaTest {

@Autowired
private RestaurantRepository restaurantRepository;

@Autowired
private TransactionTemplate transactionTemplate;

@Test
public void shouldSaveRestaurant() {

transactionTemplate.execute((ts) -> {
Restaurant restaurant = new Restaurant(AJANTA_ID, AJANTA_RESTAURANT_NAME, AJANTA_RESTAURANT_MENU_ITEMS);
restaurantRepository.save(restaurant);
return null;
});
transactionTemplate.execute((ts) -> {
Restaurant restaurant = new Restaurant(AJANTA_ID, AJANTA_RESTAURANT_NAME, AJANTA_RESTAURANT_MENU_ITEMS);
restaurantRepository.save(restaurant);
return null;
});



}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
spring.application.name=ftgo-order-service

logging.level.root=INFO
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.springframework.cloud.contract=DEBUG
logging.level.io.eventuate=DEBUG
#logging.level.org.springframework.orm.jpa.JpaTransactionManager=TRACE

spring.jpa.generate-ddl=true

stubrunner.stream.enabled=false
stubrunner.integration.enabled=false
stubrunner.integration.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.chrisrichardson.ftgo.restaurantservice.events.RestaurantMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
Expand Down Expand Up @@ -158,11 +159,13 @@ public void confirmRevision(long orderId, OrderRevision revision) {
updateOrder(orderId, order -> order.confirmRevision(revision));
}

@Transactional(propagation = Propagation.MANDATORY)
public void createMenu(long id, String name, RestaurantMenu menu) {
Restaurant restaurant = new Restaurant(id, name, menu.getMenuItems());
restaurantRepository.save(restaurant);
}

@Transactional(propagation = Propagation.MANDATORY)
public void reviseMenu(long id, RestaurantMenu revisedMenu) {
restaurantRepository.findById(id).map(restaurant -> {
List<OrderDomainEvent> events = restaurant.reviseMenu(revisedMenu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.chrisrichardson.ftgo.restaurantservice.events.RestaurantCreated;
import net.chrisrichardson.ftgo.restaurantservice.events.RestaurantMenu;
import net.chrisrichardson.ftgo.restaurantservice.events.RestaurantMenuRevised;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;


public class OrderEventConsumer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ logging.level.org.springframework.cloud.contract=DEBUG
logging.level.io.eventuate=DEBUG
spring.jpa.generate-ddl=true
stubrunner.stream.enabled=false
stubrunner.integration.enabled=false
stubrunner.integration.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableJpaRepositories
@EnableTransactionManagement
@EntityScan
@Import({TramEventsPublisherConfiguration.class, CommonConfiguration.class})
public class RestaurantServiceDomainConfiguration {
Expand Down
2 changes: 1 addition & 1 deletion mysql-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ docker run $* \
--name mysqlterm --rm \
-e MYSQL_PORT_3306_TCP_ADDR=$DOCKER_HOST_IP -e MYSQL_PORT_3306_TCP_PORT=3306 -e MYSQL_ENV_MYSQL_ROOT_PASSWORD=rootpassword \
mysql:5.7.13 \
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -o eventuate'
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" '

0 comments on commit 94ca6a3

Please sign in to comment.