@Test public void testValidatePlantPageDataWithNonExistingProject() { SimplePlantBag plantPageData = plantBagBuilder.createSimplePlantItemAndAddToSimplePlantBag(4, 100, "wood", "Project D").build(); boolean validation = _simplePlantPageDataValidator.isPlantPageDataValid(plantPageData); assertThat(validation).isFalse(); }
public boolean isPlantPageDataValid(SimplePlantBag plantPageData) { Set<String> projectNames = new HashSet<>(); for (SimplePlantPageItem plantItem : plantPageData.getPlantItems()) { projectNames.add(plantItem.getProjectName()); } return projectsExist(projectNames) && projectsAreActive(projectNames) && articlesExist(plantPageData) && areThereEnoughTreesRemaining(plantPageData); }
SimplePlantBagValidator extends AbstractPlantBagValidator { public boolean isPlantPageDataValid(SimplePlantBag plantPageData) { Set<String> projectNames = new HashSet<>(); for (SimplePlantPageItem plantItem : plantPageData.getPlantItems()) { projectNames.add(plantItem.getProjectName()); } return projectsExist(projectNames) && projectsAreActive(projectNames) && articlesExist(plantPageData) && areThereEnoughTreesRemaining(plantPageData); } }
SimplePlantBagValidator extends AbstractPlantBagValidator { public boolean isPlantPageDataValid(SimplePlantBag plantPageData) { Set<String> projectNames = new HashSet<>(); for (SimplePlantPageItem plantItem : plantPageData.getPlantItems()) { projectNames.add(plantItem.getProjectName()); } return projectsExist(projectNames) && projectsAreActive(projectNames) && articlesExist(plantPageData) && areThereEnoughTreesRemaining(plantPageData); } @Autowired private  SimplePlantBagValidator(TreeRepository treeRepository, ProjectArticleRepository projectArticleRepository, ProjectRepository projectRepository); }
SimplePlantBagValidator extends AbstractPlantBagValidator { public boolean isPlantPageDataValid(SimplePlantBag plantPageData) { Set<String> projectNames = new HashSet<>(); for (SimplePlantPageItem plantItem : plantPageData.getPlantItems()) { projectNames.add(plantItem.getProjectName()); } return projectsExist(projectNames) && projectsAreActive(projectNames) && articlesExist(plantPageData) && areThereEnoughTreesRemaining(plantPageData); } @Autowired private  SimplePlantBagValidator(TreeRepository treeRepository, ProjectArticleRepository projectArticleRepository, ProjectRepository projectRepository); boolean isPlantPageDataValid(SimplePlantBag plantPageData); }
SimplePlantBagValidator extends AbstractPlantBagValidator { public boolean isPlantPageDataValid(SimplePlantBag plantPageData) { Set<String> projectNames = new HashSet<>(); for (SimplePlantPageItem plantItem : plantPageData.getPlantItems()) { projectNames.add(plantItem.getProjectName()); } return projectsExist(projectNames) && projectsAreActive(projectNames) && articlesExist(plantPageData) && areThereEnoughTreesRemaining(plantPageData); } @Autowired private  SimplePlantBagValidator(TreeRepository treeRepository, ProjectArticleRepository projectArticleRepository, ProjectRepository projectRepository); boolean isPlantPageDataValid(SimplePlantBag plantPageData);  }