@Test public void testGetWhenDtoNameFilledThenProperGetCalled() { Recipe recipe = getRecipe(); when(recipeRepository.findByNameAndWorkspaceId(recipe.getName(), recipe.getWorkspace().getId())).thenReturn(Optional.of(recipe)); Recipe result = underTest.get(NameOrCrn.ofName(recipe.getName()), recipe.getWorkspace().getId()); assertEquals(recipe, result); verify(recipeRepository, times(1)).findByNameAndWorkspaceId(anyString(), anyLong()); verify(recipeRepository, times(1)).findByNameAndWorkspaceId(recipe.getName(), recipe.getWorkspace().getId()); }
public Recipe get(NameOrCrn recipeNameOrCrn, Long workspaceId) { return recipeNameOrCrn.hasName() ? super.getByNameForWorkspaceId(recipeNameOrCrn.getName(), workspaceId) : recipeRepository.findByResourceCrnAndWorkspaceId(recipeNameOrCrn.getCrn(), workspaceId) .orElseThrow(() -> new NotFoundException("No recipe found with crn: \"" + recipeNameOrCrn + "\"")); }
RecipeService extends AbstractArchivistService<Recipe> implements ResourceBasedCrnProvider { public Recipe get(NameOrCrn recipeNameOrCrn, Long workspaceId) { return recipeNameOrCrn.hasName() ? super.getByNameForWorkspaceId(recipeNameOrCrn.getName(), workspaceId) : recipeRepository.findByResourceCrnAndWorkspaceId(recipeNameOrCrn.getCrn(), workspaceId) .orElseThrow(() -> new NotFoundException("No recipe found with crn: \"" + recipeNameOrCrn + "\"")); } }
RecipeService extends AbstractArchivistService<Recipe> implements ResourceBasedCrnProvider { public Recipe get(NameOrCrn recipeNameOrCrn, Long workspaceId) { return recipeNameOrCrn.hasName() ? super.getByNameForWorkspaceId(recipeNameOrCrn.getName(), workspaceId) : recipeRepository.findByResourceCrnAndWorkspaceId(recipeNameOrCrn.getCrn(), workspaceId) .orElseThrow(() -> new NotFoundException("No recipe found with crn: \"" + recipeNameOrCrn + "\"")); }  }
RecipeService extends AbstractArchivistService<Recipe> implements ResourceBasedCrnProvider { public Recipe get(NameOrCrn recipeNameOrCrn, Long workspaceId) { return recipeNameOrCrn.hasName() ? super.getByNameForWorkspaceId(recipeNameOrCrn.getName(), workspaceId) : recipeRepository.findByResourceCrnAndWorkspaceId(recipeNameOrCrn.getCrn(), workspaceId) .orElseThrow(() -> new NotFoundException("No recipe found with crn: \"" + recipeNameOrCrn + "\"")); }  Recipe delete(NameOrCrn recipeNameOrCrn, Long workspaceId); @Override Set<Recipe> deleteMultipleByNameFromWorkspace(Set<String> names, Long workspaceId); Recipe get(NameOrCrn recipeNameOrCrn, Long workspaceId); Set<Recipe> getRecipesByNamesForWorkspace(Workspace workspace, Set<String> recipeNames); Recipe createForLoggedInUser(Recipe recipe, @Nonnull Long workspaceId, String accountId, String creator); Set<RecipeView> findAllViewByWorkspaceId(Long workspaceId); @Override WorkspaceResourceRepository<Recipe, Long> repository(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType(); }
RecipeService extends AbstractArchivistService<Recipe> implements ResourceBasedCrnProvider { public Recipe get(NameOrCrn recipeNameOrCrn, Long workspaceId) { return recipeNameOrCrn.hasName() ? super.getByNameForWorkspaceId(recipeNameOrCrn.getName(), workspaceId) : recipeRepository.findByResourceCrnAndWorkspaceId(recipeNameOrCrn.getCrn(), workspaceId) .orElseThrow(() -> new NotFoundException("No recipe found with crn: \"" + recipeNameOrCrn + "\"")); }  Recipe delete(NameOrCrn recipeNameOrCrn, Long workspaceId); @Override Set<Recipe> deleteMultipleByNameFromWorkspace(Set<String> names, Long workspaceId); Recipe get(NameOrCrn recipeNameOrCrn, Long workspaceId); Set<Recipe> getRecipesByNamesForWorkspace(Workspace workspace, Set<String> recipeNames); Recipe createForLoggedInUser(Recipe recipe, @Nonnull Long workspaceId, String accountId, String creator); Set<RecipeView> findAllViewByWorkspaceId(Long workspaceId); @Override WorkspaceResourceRepository<Recipe, Long> repository(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType();  }