Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ nbdist/
.nb-gradle/

\.DS_Store

### Eclipse ###
bin/
42 changes: 38 additions & 4 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Mongo config
spring:
application:
name: tripmanagementquery
profiles: dev
data:
mongodb:
database: trip-management-query
host: ${MONGO_HOST:localhost}
port: ${MONGO_PORT:27017}
port: 27017
rabbitmq:
host: ${RABBIT_HOST:localhost}
port: 5672
Expand Down Expand Up @@ -45,7 +44,42 @@ logging:
---
spring:
profiles: test
data:
mongodb:
database: trip-management-query
host: ${DOCKER_MACHINE_IP:localhost}
port: 27017
rabbitmq:
host: ${DOCKER_MACHINE_IP:localhost}
port: 5672
username: guest
password: guest

eureka:
client:
enabled: false
serviceUrl:
defaultZone: http://DOCKER_MACHINE_IP:8761/eureka/

server:
port: ${APP_PORT:8080}

amqp:
events:
host: ${DOCKER_MACHINE_IP:localhost}
exchange-name: eventBus
queue-name: eventQueue
handlers: org.aitesting.microservices.tripmanagement.query.domain.eventhandlers

logging:
level:
root: INFO
org:
springframework:
security: DEBUG
web:
filter:
CommonsRequestLoggingFilter: DEBUG
hibernate: DEBUG
apache:
commons:
dbcp2: DEBUG
9 changes: 9 additions & 0 deletions src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spring:
application:
name: tripmanagementquery
profiles:
active: dev
cloud:
config:
uri: http://${CONFIGURATION_HOST:localhost}:8888
enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import java.util.Date;
import java.util.UUID;

import org.aitesting.microservices.tripmanagement.common.models.TripInvoice;

public class TestConstants {
public static final UUID TRIP_ID1 = UUID.fromString("f849769e-2534-84a6-d475-5c2d701343ab");
public static final UUID TRIP_ID2 = UUID.fromString("5b842415-9447-4b9b-85c6-2e1075214cc4");
public static final UUID TRIP_ID3 = UUID.fromString("7a7d1e99-4823-4aa5-9d3b-2307e88cee0d");
public static final UUID TRIP_ID4 = UUID.fromString("7a7d1e99-4823-4aa5-9d3b-2307e88cee08");
public static final UUID USER_ID = UUID.fromString("123e4567-e89b-12d3-a456-426655440000");
public static final UUID USER_ID = UUID.fromString("4eaf29bc-3909-49d4-a104-3d17f68ba672");
public static final String FROM = "from some place over there";
public static final String TO = "to this other place";
public static final TripInvoice TRIP_INVOICE = new TripInvoice("1234 Address", "12343 address",
20.4, 34, 45.34, new Date());
public static final TripInvoice TRIP_INVOICE = new TripInvoice("1234 Address", "12343 address", 20.4, 34, 45.34,
new Date());
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
package org.aitesting.microservices.tests.provider;

import static org.aitesting.microservices.tests.helpers.TestConstants.*;
import static org.aitesting.microservices.tests.helpers.TestConstants.FROM;
import static org.aitesting.microservices.tests.helpers.TestConstants.TO;
import static org.aitesting.microservices.tests.helpers.TestConstants.TRIP_ID1;
import static org.aitesting.microservices.tests.helpers.TestConstants.TRIP_ID2;
import static org.aitesting.microservices.tests.helpers.TestConstants.TRIP_ID3;
import static org.aitesting.microservices.tests.helpers.TestConstants.TRIP_ID4;
import static org.aitesting.microservices.tests.helpers.TestConstants.TRIP_INVOICE;
import static org.aitesting.microservices.tests.helpers.TestConstants.USER_ID;

import io.restassured.module.mockmvc.RestAssuredMockMvc;

import org.aitesting.microservices.tripmanagement.common.events.TripStatus;
import org.aitesting.microservices.tripmanagement.query.TripManagementQueryApplication;
import org.aitesting.microservices.tripmanagement.query.domain.models.Trip;
import org.aitesting.microservices.tripmanagement.query.service.repositories.TripRepository;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.context.WebApplicationContext;

@RunWith(SpringRunner.class)
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = TripManagementQueryApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@Profile("test")
@SpringBootTest(classes = TripManagementQueryApplication.class)
public abstract class TripContractBase {

protected static final Logger log = LoggerFactory.getLogger(TripContractBase.class);

@Autowired
private WebApplicationContext webApplicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringRunner.class)
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = TripManagementQueryApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@Profile("test")
@SpringBootTest
public class TripManagementQueryApplicationTests {

protected static final Logger log = LoggerFactory.getLogger(TripManagementQueryApplicationTests.class);

@Test
public void contextLoads() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ import org.springframework.cloud.contract.spec.*
[
{
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "STARTED"
},
{
"id": "5b842415-9447-4b9b-85c6-2e1075214cc4",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CREATED"
},
{
"id": "7a7d1e99-4823-4aa5-9d3b-2307e88cee0d",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "COMPLETED"
},
{
"id": "7a7d1e99-4823-4aa5-9d3b-2307e88cee08",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CANCELED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import org.springframework.cloud.contract.spec.Contract
description("When a GET request for api/trip/{id} with invalid id should return 400")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440000/status/badIdString'
url '/api/v1/trip/user/4eaf29bc-3909-49d4-a104-3d17f68ba672/status/badIdString'
}
response {
status 400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.springframework.cloud.contract.spec.Contract
description("When a Get request with a TripID is made, but trip not in db, should return 404")
request {
method 'GET'
url '/api/v1/trip/123e4567-e89b-12d3-a456-426655440000'
url '/api/v1/trip/049769e-2534-84a6-d475-5c2d701343ab'
}
response {
status 404
Expand All @@ -17,7 +17,7 @@ import org.springframework.cloud.contract.spec.Contract
description("When a Get request with a UserID is made, but trip not in db, should return 404")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440001'
url '/api/v1/trip/user/0eaf29bc-3909-49d4-a104-3d17f68ba672'
}
response {
status 404
Expand All @@ -27,7 +27,7 @@ import org.springframework.cloud.contract.spec.Contract
description("When a Get request with a UserID is made, but trip not in db, should return 404")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440001/status/completed'
url '/api/v1/trip/user/0eaf29bc-3909-49d4-a104-3d17f68ba672/status/completed'
}
response {
status 404
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.springframework.cloud.contract.spec.*
status 200
body(
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "STARTED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ import org.springframework.cloud.contract.spec.*
description("When a Get request with a UserId is made, the corresponding trips are returned")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440000'
url '/api/v1/trip/user/4eaf29bc-3909-49d4-a104-3d17f68ba672'
}
response {
status 200
body("""
[
{
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "STARTED"
},
{
"id": "5b842415-9447-4b9b-85c6-2e1075214cc4",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CREATED"
},
{
"id": "7a7d1e99-4823-4aa5-9d3b-2307e88cee0d",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "COMPLETED"
},
{
"id": "7a7d1e99-4823-4aa5-9d3b-2307e88cee08",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CANCELED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import org.springframework.cloud.contract.spec.*
description("When a Get request with a UserId and Status=STARTED is made, the corresponding trip is returned")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440000/status/started'
url '/api/v1/trip/user/4eaf29bc-3909-49d4-a104-3d17f68ba672/status/started'
}
response {
status 200
body("""
[
{
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "STARTED"
Expand All @@ -31,15 +31,15 @@ import org.springframework.cloud.contract.spec.*
description("When a Get request with a UserId and Status=CREATED is made, the corresponding trip is returned")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440000/status/created'
url '/api/v1/trip/user/4eaf29bc-3909-49d4-a104-3d17f68ba672/status/created'
}
response {
status 200
body("""
[
{
"id": "5b842415-9447-4b9b-85c6-2e1075214cc4",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CREATED"
Expand All @@ -56,15 +56,15 @@ import org.springframework.cloud.contract.spec.*
description("When a Get request with a UserId and Status=COMPLETED is made, the corresponding trip is returned")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440000/status/completed'
url '/api/v1/trip/user/4eaf29bc-3909-49d4-a104-3d17f68ba672/status/completed'
}
response {
status 200
body("""
[
{
"id": "7a7d1e99-4823-4aa5-9d3b-2307e88cee0d",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "COMPLETED"
Expand All @@ -81,15 +81,15 @@ import org.springframework.cloud.contract.spec.*
description("When a Get request with a UserId and Status=CANCELLED is made, the corresponding trip is returned")
request {
method 'GET'
url '/api/v1/trip/user/123e4567-e89b-12d3-a456-426655440000/status/canceled'
url '/api/v1/trip/user/4eaf29bc-3909-49d4-a104-3d17f68ba672/status/canceled'
}
response {
status 200
body("""
[
{
"id": "7a7d1e99-4823-4aa5-9d3b-2307e88cee08",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"userId": "4eaf29bc-3909-49d4-a104-3d17f68ba672",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CANCELED"
Expand Down