Skip to content

Commit

Permalink
Fixed multiple contract files, checkstyle config, and other small things
Browse files Browse the repository at this point in the history
  • Loading branch information
R4il committed Mar 23, 2018
1 parent 5bcf72e commit 5254ef4
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 292 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD build/libs/trip-management-query-0.0.1-SNAPSHOT.jar app.jar
ADD build/libs/trip-management-query-0.0.1.jar app.jar
ENV JAVA_OPTS=""
ENV MONGO_HOST="mongo"
ENV MONGO_PORT="27017"
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ apply plugin: 'checkstyle'


group = 'org.aitesting.microservices'
version = '0.0.1-SNAPSHOT'
version = '0.0.1'
sourceCompatibility = 1.8

ext {
Expand Down Expand Up @@ -73,6 +73,7 @@ dependencies {
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${verifierVersion}"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ public ResponseEntity<List<Trip>> getTripByUser(@PathVariable("userId") UUID use
}

@GetMapping("trip/user/{userId}/status/{status}")
public ResponseEntity<List<Trip>> getTripByUserAndStatus(@PathVariable("userId") UUID userId, @PathVariable("status") String status) {
public ResponseEntity<List<Trip>> getTripByUserAndStatus(@PathVariable("userId") UUID userId,
@PathVariable("status") String status) {
logger.info(String.format("Request for trips from user: %s with status: %s", userId, status));
TripStatus tripStatus;
try {
tripStatus = TripStatus.valueOf(status.toUpperCase());
} catch(IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
logger.trace(String.format("Bad argument status: %s", status));
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
package tripmanagement.query

import org.springframework.cloud.contract.spec.*

Contract.make {
description("When a Get request for all the trips should get all the trips")
request {
method 'GET'
url '/api/v1/trips'
}
response {
status 200
body("""
[
{
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"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",
"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",
"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",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CANCELED"
}
]
"""
)
headers {
contentType(applicationJson())
[
Contract.make {
description("When a Get request for all the trips should get all the trips")
request {
method 'GET'
url '/api/v1/trips'
}
response {
status 200
body("""
[
{
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"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",
"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",
"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",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "CANCELED"
}
]
"""
)
headers {
contentType(applicationJson())
}
}
}
}

]
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,45 @@ package tripmanagement.query

import org.springframework.cloud.contract.spec.Contract

Contract.make {
description("When a GET request for api/trip/{id} with invalid id should return 400")
request {
method 'GET'
url '/api/v1/trip/badIdString'
}
response {
status 400
}
}

Contract.make {
description("When a GET request for api/trip/user/{userid} with invalid id should return 400")
request {
method 'GET'
url '/api/v1/trip/user/badIdString'
}
response {
status 400
}
}

Contract.make {
description("When a GET request for api/trip/user{id}/status/completed with invalid id should return 400")
request {
method 'GET'
url '/api/v1/trip/user/badIdString/status/completed'
}
response {
status 400
}
}

Contract.make {
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'
}
response {
status 400
}
}
[
Contract.make {
description("When a GET request for api/trip/{id} with invalid id should return 400")
request {
method 'GET'
url '/api/v1/trip/badIdString'
}
response {
status 400
}
},
Contract.make {
description("When a GET request for api/trip/user/{userid} with invalid id should return 400")
request {
method 'GET'
url '/api/v1/trip/user/badIdString'
}
response {
status 400
}
},
Contract.make {
description("When a GET request for api/trip/user{id}/status/completed with invalid id should return 400")
request {
method 'GET'
url '/api/v1/trip/user/badIdString/status/completed'
}
response {
status 400
}
},
Contract.make {
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'
}
response {
status 400
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@ package tripmanagement.query

import org.springframework.cloud.contract.spec.Contract


Contract.make {
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'
}
response {
status 404
}
}

Contract.make {
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'
}
response {
status 404
[
Contract.make {
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'
}
response {
status 404
}
},
Contract.make {
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'
}
response {
status 404
}
},
Contract.make {
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'
}
response {
status 404
}
}
}

Contract.make {
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'
}
response {
status 404
}
}

]
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package tripmanagement.query

import org.springframework.cloud.contract.spec.*

Contract.make {
description("When a Get request with a TripId is made, the corresponding trip is returned")
request {
method 'GET'
url '/api/v1/trip/f849769e-2534-84a6-d475-5c2d701343ab'
}
response {
status 200
body(
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "STARTED"
)
headers {
contentType(applicationJson())
[
Contract.make {
description("When a Get request with a TripId is made, the corresponding trip is returned")
request {
method 'GET'
url '/api/v1/trip/f849769e-2534-84a6-d475-5c2d701343ab'
}
response {
status 200
body(
"id": "f849769e-2534-84a6-d475-5c2d701343ab",
"userId": "123e4567-e89b-12d3-a456-426655440000",
"originAddress": "from some place over there",
"destinationAddress": "to this other place",
"status": "STARTED"
)
headers {
contentType(applicationJson())
}
}
}
}

]
Loading

0 comments on commit 5254ef4

Please sign in to comment.