use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe in project microservice_framework by CJSCommonPlatform.
the class RecipeEventListener method recipeRenamed.
@Handles("example.recipe-renamed")
public void recipeRenamed(final JsonEnvelope event) {
final String recipeId = event.payloadAsJsonObject().getString(FIELD_RECIPE_ID);
final String recipeName = event.payloadAsJsonObject().getString("name");
LOGGER.trace("=============> Inside rename-recipe Event Listener. RecipeId: " + recipeId);
final Recipe recipe = recipeRepository.findBy(UUID.fromString(recipeId));
recipe.setName(recipeName);
recipeRepository.save(recipe);
}
use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe in project microservice_framework by CJSCommonPlatform.
the class RecipeServiceTest method shouldReturnNullWhenPhotoIdNull.
@Test
public void shouldReturnNullWhenPhotoIdNull() {
given(recipeRepository.findBy(RECIPE_ID)).willReturn(new Recipe(RECIPE_ID, NAME, GLUTEN_FREE, null));
assertNull(service.findRecipePhoto(RECIPE_ID.toString()));
}
use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe 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.persistence.entity.Recipe 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));
}
use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe in project microservice_framework by CJSCommonPlatform.
the class RecipeRepositoryTest method removeAndAssertRecipe.
private void removeAndAssertRecipe(UUID recipeId) {
Recipe foundRecipe = recipeRepository.findBy(recipeId);
recipeRepository.remove(foundRecipe);
Recipe recipeFound = recipeRepository.findBy(recipeId);
Assert.assertNull(recipeFound);
}
Aggregations