Search in sources :

Example 1 with SearchRecipes

use of uk.gov.justice.services.example.cakeshop.query.view.request.SearchRecipes in project microservice_framework by CJSCommonPlatform.

the class RecipesQueryViewTest method shouldReturnRecipesForQuery.

@Test
public void shouldReturnRecipesForQuery() throws Exception {
    final UUID recipeId = randomUUID();
    final UUID recipeId2 = randomUUID();
    final String recipeName = "some recipe name";
    final String recipeName2 = "some other recipe name";
    final int pagesize = 5;
    when(service.getRecipes(pagesize, Optional.of(recipeName), Optional.of(false))).thenReturn(new RecipesView(asList(new RecipeView(recipeId, recipeName, false), new RecipeView(recipeId2, recipeName2, false))));
    final SearchRecipes searchRecipes = new SearchRecipes(pagesize);
    searchRecipes.setName(recipeName);
    searchRecipes.setGlutenFree(false);
    final Envelope<SearchRecipes> envelope = envelopeFrom(metadataWithDefaults(), searchRecipes);
    final Envelope<RecipesView> response = queryView.queryRecipes(envelope);
    final RecipesView payload = response.payload();
    assertThat(payload.getRecipes().get(0).getName(), is(searchRecipes.getName()));
}
Also used : SearchRecipes(uk.gov.justice.services.example.cakeshop.query.view.request.SearchRecipes) RecipesView(uk.gov.justice.services.example.cakeshop.query.view.response.RecipesView) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) RecipeView(uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)1 UUID.randomUUID (java.util.UUID.randomUUID)1 Test (org.junit.Test)1 SearchRecipes (uk.gov.justice.services.example.cakeshop.query.view.request.SearchRecipes)1 RecipeView (uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView)1 RecipesView (uk.gov.justice.services.example.cakeshop.query.view.response.RecipesView)1