diff --git a/.gitignore b/.gitignore index fc4bd9f..1697335 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ nbdist/ .nb-gradle/ \.DS_Store + +### Eclipse ### +bin/ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f8fb7a6..0d2653e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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 @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..267e88d --- /dev/null +++ b/src/main/resources/bootstrap.yml @@ -0,0 +1,9 @@ +spring: + application: + name: tripmanagementquery + profiles: + active: dev + cloud: + config: + uri: http://${CONFIGURATION_HOST:localhost}:8888 + enabled: true diff --git a/src/test/java/org/aitesting/microservices/tests/helpers/TestConstants.java b/src/test/java/org/aitesting/microservices/tests/helpers/TestConstants.java index 60f0a16..c5d3091 100644 --- a/src/test/java/org/aitesting/microservices/tests/helpers/TestConstants.java +++ b/src/test/java/org/aitesting/microservices/tests/helpers/TestConstants.java @@ -2,6 +2,7 @@ import java.util.Date; import java.util.UUID; + import org.aitesting.microservices.tripmanagement.common.models.TripInvoice; public class TestConstants { @@ -9,9 +10,9 @@ public class TestConstants { 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()); } diff --git a/src/test/java/org/aitesting/microservices/tests/provider/TripContractBase.java b/src/test/java/org/aitesting/microservices/tests/provider/TripContractBase.java index bde88b0..c4dadef 100644 --- a/src/test/java/org/aitesting/microservices/tests/provider/TripContractBase.java +++ b/src/test/java/org/aitesting/microservices/tests/provider/TripContractBase.java @@ -1,8 +1,16 @@ 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; @@ -10,16 +18,21 @@ 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; diff --git a/src/test/java/org/aitesting/microservices/tripmanagement/query/TripManagementQueryApplicationTests.java b/src/test/java/org/aitesting/microservices/tripmanagement/query/TripManagementQueryApplicationTests.java index 54dd77b..8f29455 100644 --- a/src/test/java/org/aitesting/microservices/tripmanagement/query/TripManagementQueryApplicationTests.java +++ b/src/test/java/org/aitesting/microservices/tripmanagement/query/TripManagementQueryApplicationTests.java @@ -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() { } + } \ No newline at end of file diff --git a/src/test/resources/contracts/tripmanagement/query/ShouldGetAllTrips.groovy b/src/test/resources/contracts/tripmanagement/query/ShouldGetAllTrips.groovy index 8ebdd79..0adc5b7 100644 --- a/src/test/resources/contracts/tripmanagement/query/ShouldGetAllTrips.groovy +++ b/src/test/resources/contracts/tripmanagement/query/ShouldGetAllTrips.groovy @@ -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" diff --git a/src/test/resources/contracts/tripmanagement/query/ShouldGetBadRequest.groovy b/src/test/resources/contracts/tripmanagement/query/ShouldGetBadRequest.groovy index c4d526f..2de0e10 100644 --- a/src/test/resources/contracts/tripmanagement/query/ShouldGetBadRequest.groovy +++ b/src/test/resources/contracts/tripmanagement/query/ShouldGetBadRequest.groovy @@ -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 diff --git a/src/test/resources/contracts/tripmanagement/query/ShouldGetNotFound.groovy b/src/test/resources/contracts/tripmanagement/query/ShouldGetNotFound.groovy index d9a4faf..276341c 100644 --- a/src/test/resources/contracts/tripmanagement/query/ShouldGetNotFound.groovy +++ b/src/test/resources/contracts/tripmanagement/query/ShouldGetNotFound.groovy @@ -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 @@ -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 @@ -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 diff --git a/src/test/resources/contracts/tripmanagement/query/ShouldGetTrip.groovy b/src/test/resources/contracts/tripmanagement/query/ShouldGetTrip.groovy index beec52e..1e59968 100644 --- a/src/test/resources/contracts/tripmanagement/query/ShouldGetTrip.groovy +++ b/src/test/resources/contracts/tripmanagement/query/ShouldGetTrip.groovy @@ -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" diff --git a/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserId.groovy b/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserId.groovy index e21bf79..4a2f9a0 100644 --- a/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserId.groovy +++ b/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserId.groovy @@ -6,7 +6,7 @@ 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 @@ -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" diff --git a/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserIdAndStatus.groovy b/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserIdAndStatus.groovy index 23ce173..66c4763 100644 --- a/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserIdAndStatus.groovy +++ b/src/test/resources/contracts/tripmanagement/query/ShouldGetTripByUserIdAndStatus.groovy @@ -6,7 +6,7 @@ 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 @@ -14,7 +14,7 @@ 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" @@ -31,7 +31,7 @@ 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 @@ -39,7 +39,7 @@ import org.springframework.cloud.contract.spec.* [ { "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" @@ -56,7 +56,7 @@ 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 @@ -64,7 +64,7 @@ import org.springframework.cloud.contract.spec.* [ { "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" @@ -81,7 +81,7 @@ 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 @@ -89,7 +89,7 @@ import org.springframework.cloud.contract.spec.* [ { "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"