@Test public void testValidatePlantPageDataWithOneArticleAndAlreadyPlantedTreesToFalse() { _dbInjecter.injectTreeToProject("wood", "Adam", 7, timeOfPlanting, "Project A"); Integer wantedToPlant = 4; Integer treesRemaining = 3; PlantBag plantBag = plantBagBuilder.initializeProjectDataAndAddToPlantBag("Project A").createPlantItemAndAddToPlantBag(wantedToPlant, 100, "wood", "Project A").build(); try { _plantBagValidator.validatePlantBag(plantBag); } catch (IpatException e) { List<IpatErrorInfo> errorInfos = e.getErrorInfos(); assertEquals(1, errorInfos.size()); IpatErrorInfo error = errorInfos.get(0); assertEquals(ErrorCodes.NOT_ENOUGH_TREES, error.getErrorCode()); assertEquals("Project A", error.getErrorParams()[0]); assertEquals("wood", error.getErrorParams()[1]); assertEquals(wantedToPlant.toString(), error.getErrorParams()[2]); assertEquals(treesRemaining.toString(), error.getErrorParams()[3]); } }
public void validatePlantBag(PlantBag plantBag) throws IpatException { Set<String> projectNames = plantBag.getProjects().keySet(); checkProjects(plantBag, projectNames); if (errorInfos.size() > 0) { List<IpatErrorInfo> returnedErrors = this.errorInfos; this.errorInfos = new ArrayList<IpatErrorInfo>(); throw new IpatException(returnedErrors); } }
PlantBagValidator extends AbstractPlantBagValidator { public void validatePlantBag(PlantBag plantBag) throws IpatException { Set<String> projectNames = plantBag.getProjects().keySet(); checkProjects(plantBag, projectNames); if (errorInfos.size() > 0) { List<IpatErrorInfo> returnedErrors = this.errorInfos; this.errorInfos = new ArrayList<IpatErrorInfo>(); throw new IpatException(returnedErrors); } } }
PlantBagValidator extends AbstractPlantBagValidator { public void validatePlantBag(PlantBag plantBag) throws IpatException { Set<String> projectNames = plantBag.getProjects().keySet(); checkProjects(plantBag, projectNames); if (errorInfos.size() > 0) { List<IpatErrorInfo> returnedErrors = this.errorInfos; this.errorInfos = new ArrayList<IpatErrorInfo>(); throw new IpatException(returnedErrors); } } @Autowired private  PlantBagValidator(TreeRepository treeRepository, ProjectArticleRepository projectArticleRepository, ProjectRepository projectRepository); }
PlantBagValidator extends AbstractPlantBagValidator { public void validatePlantBag(PlantBag plantBag) throws IpatException { Set<String> projectNames = plantBag.getProjects().keySet(); checkProjects(plantBag, projectNames); if (errorInfos.size() > 0) { List<IpatErrorInfo> returnedErrors = this.errorInfos; this.errorInfos = new ArrayList<IpatErrorInfo>(); throw new IpatException(returnedErrors); } } @Autowired private  PlantBagValidator(TreeRepository treeRepository, ProjectArticleRepository projectArticleRepository, ProjectRepository projectRepository); void validatePlantBag(PlantBag plantBag); }
PlantBagValidator extends AbstractPlantBagValidator { public void validatePlantBag(PlantBag plantBag) throws IpatException { Set<String> projectNames = plantBag.getProjects().keySet(); checkProjects(plantBag, projectNames); if (errorInfos.size() > 0) { List<IpatErrorInfo> returnedErrors = this.errorInfos; this.errorInfos = new ArrayList<IpatErrorInfo>(); throw new IpatException(returnedErrors); } } @Autowired private  PlantBagValidator(TreeRepository treeRepository, ProjectArticleRepository projectArticleRepository, ProjectRepository projectRepository); void validatePlantBag(PlantBag plantBag);  }