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()));
}
Aggregations