Search in sources :

Example 1 with Recipe

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));
}
Also used : PhotoView(uk.gov.justice.services.example.cakeshop.query.view.response.PhotoView) Recipe(uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe) Test(org.junit.Test)

Example 2 with Recipe

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));
}
Also used : Recipe(uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe) RecipeView(uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView) Test(org.junit.Test)

Example 3 with Recipe

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));
}
Also used : Recipe(uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe) Test(org.junit.Test) BaseTransactionalTest(uk.gov.justice.services.test.utils.persistence.BaseTransactionalTest)

Example 4 with Recipe

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);
}
Also used : Recipe(uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe) Handles(uk.gov.justice.services.core.annotation.Handles)

Example 5 with Recipe

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);
}
Also used : Recipe(uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe) Handles(uk.gov.justice.services.core.annotation.Handles)

Aggregations

Recipe (uk.gov.justice.services.example.cakeshop.persistence.entity.Recipe)12 Test (org.junit.Test)8 Handles (uk.gov.justice.services.core.annotation.Handles)3 RecipeView (uk.gov.justice.services.example.cakeshop.query.view.response.RecipeView)3 RecipesView (uk.gov.justice.services.example.cakeshop.query.view.response.RecipesView)2 BaseTransactionalTest (uk.gov.justice.services.test.utils.persistence.BaseTransactionalTest)2 UUID (java.util.UUID)1 Ingredient (uk.gov.justice.services.example.cakeshop.domain.Ingredient)1 RecipeAdded (uk.gov.justice.services.example.cakeshop.domain.event.RecipeAdded)1 PhotoView (uk.gov.justice.services.example.cakeshop.query.view.response.PhotoView)1