use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe in project microservice_framework by CJSCommonPlatform.
the class RecipeServiceTest method shouldGetRecipePhoto.
@Test
public void shouldGetRecipePhoto() throws Exception {
given(recipeRepository.findBy(RECIPE_ID)).willReturn(new Recipe(RECIPE_ID, NAME, GLUTEN_FREE, PHOTO_ID));
final PhotoView recipePhoto = service.findRecipePhoto(RECIPE_ID.toString());
assertThat(recipePhoto.getFileId(), is(PHOTO_ID));
}
use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe 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.persistence.entity.Recipe in project microservice_framework by CJSCommonPlatform.
the class RecipeRepositoryTest method shouldFindRecipeById.
@Test
public void shouldFindRecipeById() {
Recipe recipe = recipeRepository.findBy(RECIPE_ID_A);
assertThat(recipe, is(notNullValue()));
assertThat(recipe.getId(), equalTo(RECIPE_ID_A));
assertThat(recipe.getName(), equalTo(RECIPE_NAME_A));
assertThat(recipe.isGlutenFree(), is(RECIPE_GLUTEN_FREE_A));
}
use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe in project microservice_framework by CJSCommonPlatform.
the class RecipeEventListener method recipeRemoved.
@Handles("example.recipe-removed")
public void recipeRemoved(final JsonEnvelope event) {
final String recipeId = event.payloadAsJsonObject().getString(FIELD_RECIPE_ID);
LOGGER.trace("=============> Inside remove-recipe Event Listener about to find recipeId: " + recipeId);
final Recipe recipeFound = recipeRepository.findBy(UUID.fromString(recipeId));
LOGGER.trace("=============> Found remove-recipe Event Listener. RecipeId: " + recipeFound);
recipeRepository.remove(recipeFound);
}
use of uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe in project microservice_framework by CJSCommonPlatform.
the class RecipeEventListener method recipePhotographAdded.
@Handles("example.recipe-photograph-added")
public void recipePhotographAdded(final JsonEnvelope event) {
final String recipeId = event.payloadAsJsonObject().getString(FIELD_RECIPE_ID);
final String photoId = event.payloadAsJsonObject().getString(FIELD_PHOTO_ID);
LOGGER.trace("=============> Inside recipe-photograph-added Event Listener. RecipeId: " + recipeId);
final Recipe recipe = recipeRepository.findBy(UUID.fromString(recipeId));
recipe.setPhotoId(UUID.fromString(photoId));
recipeRepository.save(recipe);
}
Aggregations