use of uk.gov.justice.services.example.cakeshop.it.util.ApiResponse in project microservice_framework by CJSCommonPlatform.
the class CakeShopIT method shouldReturnOrderWithUTCOrderDate.
@Test
public void shouldReturnOrderWithUTCOrderDate() {
final UUID orderId = randomUUID();
final Response commandResponse = sendTo(ORDERS_RESOURCE_URI + orderId.toString()).request().post(entity(jsonObject().add("recipeId", randomUUID().toString()).add("deliveryDate", "2016-01-21T23:42:03.522+07:00").build().toString(), ORDER_CAKE_MEDIA_TYPE));
assertThat(commandResponse.getStatus(), is(ACCEPTED));
await().until(() -> queryForOrder(orderId.toString()).httpCode() == OK);
final ApiResponse queryResponse = queryForOrder(orderId.toString());
with(queryResponse.body()).assertThat("$.orderId", equalTo(orderId.toString())).assertThat("$.deliveryDate", equalTo("2016-01-21T16:42:03.522Z"));
}
use of uk.gov.justice.services.example.cakeshop.it.util.ApiResponse in project microservice_framework by CJSCommonPlatform.
the class CakeShopIT method shouldReturnRecipeOfGivenId.
@Test
public void shouldReturnRecipeOfGivenId() {
final String recipeId = "163af847-effb-46a9-96bc-32a0f7526f22";
final String recipeName = "Cheesy cheese cake";
addRecipe(recipeId, recipeName);
await().until(() -> queryForRecipe(recipeId).httpCode() == OK);
final ApiResponse response = queryForRecipe(recipeId);
with(response.body()).assertThat("$.id", equalTo(recipeId)).assertThat("$.name", equalTo(recipeName));
}
use of uk.gov.justice.services.example.cakeshop.it.util.ApiResponse in project microservice_framework by CJSCommonPlatform.
the class CakeShopIT method shouldFilterGlutenFreeRecipes.
@Test
public void shouldFilterGlutenFreeRecipes() {
// adding 2 recipes
final String recipeId = "163af847-effb-46a9-96bc-32a0f7526e66";
sendTo(RECIPES_RESOURCE_URI + recipeId).request().post(recipeEntity("Muffin", false));
final String recipeId2 = "163af847-effb-46a9-96bc-32a0f7526e77";
sendTo(RECIPES_RESOURCE_URI + recipeId2).request().post(recipeEntity("Oat cake", true));
await().until(() -> recipesQueryResult().body().contains(recipeId2));
final ApiResponse response = recipesQueryResult(asList(new BasicNameValuePair("pagesize", "30"), new BasicNameValuePair("glutenFree", "true")));
assertThat(response.httpCode(), is(OK));
with(response.body()).assertThat("$.recipes[?(@.id=='" + recipeId + "')]", emptyCollection()).assertThat("$.recipes[?(@.id=='" + recipeId2 + "')].name", hasItem("Oat cake"));
}
use of uk.gov.justice.services.example.cakeshop.it.util.ApiResponse in project microservice_framework by CJSCommonPlatform.
the class CakeShopIT method shouldReturnRecipes.
@Test
public void shouldReturnRecipes() {
// adding 2 recipes
final String recipeId = "163af847-effb-46a9-96bc-32a0f7526e14";
addRecipe(recipeId, "Cheesy cheese cake");
final String recipeId2 = "163af847-effb-46a9-96bc-32a0f7526e15";
addRecipe(recipeId2, "Chocolate muffin");
await().until(() -> {
final String responseBody = recipesQueryResult(singletonList(new BasicNameValuePair("pagesize", "30"))).body();
return responseBody.contains(recipeId) && responseBody.contains(recipeId2);
});
final ApiResponse response = recipesQueryResult();
assertThat(response.httpCode(), is(OK));
with(response.body()).assertThat("$.recipes[?(@.id=='" + recipeId + "')].name", hasItem("Cheesy cheese cake")).assertThat("$.recipes[?(@.id=='" + recipeId2 + "')].name", hasItem("Chocolate muffin"));
}
use of uk.gov.justice.services.example.cakeshop.it.util.ApiResponse in project microservice_framework by CJSCommonPlatform.
the class CakeShopIT method recipesQueryResult.
private ApiResponse recipesQueryResult(final List<NameValuePair> queryParams) {
try {
final URIBuilder uri = new URIBuilder(RECIPES_RESOURCE_QUERY_URI);
uri.addParameters(queryParams);
final Response jaxrRsResponse = sendTo(uri.toString()).request().accept(QUERY_RECIPES_MEDIA_TYPE).get();
return ApiResponse.from(jaxrRsResponse);
} catch (URISyntaxException e) {
fail(e.getMessage());
return null;
}
}
Aggregations