use of uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView in project microservice_framework by CJSCommonPlatform.
the class RecipeServiceTest method shouldReturnRecipeById.
@Test
public void shouldReturnRecipeById() {
given(recipeRepository.findBy(RECIPE_ID)).willReturn(new Recipe(RECIPE_ID, NAME, GLUTEN_FREE, PHOTO_ID));
RecipeView foundPerson = service.findRecipe(RECIPE_ID.toString());
assertThat(foundPerson.getId(), equalTo(RECIPE_ID));
assertThat(foundPerson.getName(), equalTo(NAME));
}
use of uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView in project microservice_framework by CJSCommonPlatform.
the class RecipesQueryViewTest method shouldReturnResponseWithMetadataWhenQueryingForRecipe.
@Test
public void shouldReturnResponseWithMetadataWhenQueryingForRecipe() {
final UUID recipeId = randomUUID();
final String recipeName = "some recipe name";
when(service.findRecipe(recipeId.toString())).thenReturn(new RecipeView(recipeId, recipeName, false));
final Envelope<JsonObject> envelope = envelopeFrom(metadataWithDefaults(), createObjectBuilder().add("recipeId", recipeId.toString()).build());
final Envelope<RecipeView> response = queryView.findRecipe(envelope);
final RecipeView payload = response.payload();
assertThat(payload.getName(), is(response.payload().getName()));
assertThat(payload.getId(), is(response.payload().getId()));
}
use of uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView 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()));
}
use of uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView in project microservice_framework by CJSCommonPlatform.
the class RecipeServiceTest method shouldGetRecipes2.
@Test
public void shouldGetRecipes2() {
int pageSize = 10;
Optional<String> nameQueryParam = Optional.of("other name");
Optional<Boolean> glutenFreeQueryParam = Optional.empty();
given(recipeRepository.findBy(pageSize, nameQueryParam, glutenFreeQueryParam)).willReturn(singletonList(new Recipe(RECIPE_ID, NAME, GLUTEN_FREE, PHOTO_ID)));
RecipesView recipes = service.getRecipes(pageSize, nameQueryParam, glutenFreeQueryParam);
List<RecipeView> firstRecipe = recipes.getRecipes();
assertThat(firstRecipe, hasSize(1));
assertThat(firstRecipe.get(0).getId(), equalTo(RECIPE_ID));
assertThat(firstRecipe.get(0).getName(), equalTo(NAME));
assertThat(firstRecipe.get(0).isGlutenFree(), is(GLUTEN_FREE));
}
use of uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView in project microservice_framework by CJSCommonPlatform.
the class RecipeServiceTest method shouldGetRecipes.
@Test
public void shouldGetRecipes() {
int pageSize = 20;
Optional<String> nameQueryParam = Optional.of("name123");
Optional<Boolean> glutenFreeQueryParam = Optional.of(false);
given(recipeRepository.findBy(pageSize, nameQueryParam, glutenFreeQueryParam)).willReturn(singletonList(new Recipe(RECIPE_ID, NAME, GLUTEN_FREE, PHOTO_ID)));
RecipesView recipes = service.getRecipes(pageSize, nameQueryParam, glutenFreeQueryParam);
List<RecipeView> firstRecipe = recipes.getRecipes();
assertThat(firstRecipe, hasSize(1));
assertThat(firstRecipe.get(0).getId(), equalTo(RECIPE_ID));
assertThat(firstRecipe.get(0).getName(), equalTo(NAME));
assertThat(firstRecipe.get(0).isGlutenFree(), is(GLUTEN_FREE));
}
Aggregations