Search in sources :

Example 11 with ApiResponse

use of uk.gov.justice.services.example.cakeshop.it.util.ApiResponse in project microservice_framework by CJSCommonPlatform.

the class CakeShopIT method shouldReturn400WhenInvalidBooleanParamPassed.

@Test
public void shouldReturn400WhenInvalidBooleanParamPassed() {
    final ApiResponse response = recipesQueryResult(asList(new BasicNameValuePair("pagesize", "30"), new BasicNameValuePair("glutenFree", "invalid")));
    assertThat(response.httpCode(), is(BAD_REQUEST));
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ApiResponse(uk.gov.justice.services.example.cakeshop.it.util.ApiResponse) Test(org.junit.Test)

Example 12 with ApiResponse

use of uk.gov.justice.services.example.cakeshop.it.util.ApiResponse in project microservice_framework by CJSCommonPlatform.

the class CakeShopIT method shouldFilterRecipesUsingPageSize.

@Test
public void shouldFilterRecipesUsingPageSize() {
    // adding 2 recipes
    final String recipeId = "263af847-effb-46a9-96bc-32a0f7526e44";
    addRecipe(recipeId, "Absolutely cheesy cheese cake");
    final String recipeId2 = "263af847-effb-46a9-96bc-32a0f7526e55";
    addRecipe(recipeId2, "Chocolate muffin");
    await().until(() -> recipesQueryResult().body().contains(recipeId));
    final ApiResponse response = recipesQueryResult(asList(new BasicNameValuePair("pagesize", "1")));
    assertThat(response.httpCode(), is(OK));
    with(response.body()).assertThat("$.recipes[?(@.id=='" + recipeId2 + "')]", emptyCollection()).assertThat("$.recipes[?(@.id=='" + recipeId + "')].name", hasItem("Absolutely cheesy cheese cake"));
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ApiResponse(uk.gov.justice.services.example.cakeshop.it.util.ApiResponse) Test(org.junit.Test)

Aggregations

ApiResponse (uk.gov.justice.services.example.cakeshop.it.util.ApiResponse)12 Test (org.junit.Test)10 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)6 Response (javax.ws.rs.core.Response)3 HttpResponse (org.apache.http.HttpResponse)3 UUID (java.util.UUID)2 UUID.randomUUID (java.util.UUID.randomUUID)2 URISyntaxException (java.net.URISyntaxException)1 MessageProducer (javax.jms.MessageProducer)1 Session (javax.jms.Session)1 TextMessage (javax.jms.TextMessage)1 Topic (javax.jms.Topic)1 JsonObject (javax.json.JsonObject)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)1