FactoryBaseValidator { protected void validateModules(Factory factory) throws ApiException { if (factory.getProject() != null && !factory.getProject().getModules().isEmpty()) { for (ProjectModule module : factory.getProject().getModules()) { String path = emptyToNull(module.getPath()); String type = emptyToNull(module.getType()); if (path == null) { throw new ConflictException("Module path cannot be empty."); } else if (type == null) { throw new ConflictException("Module type cannot be empty"); } } } } FactoryBaseValidator(AccountDao accountDao,
                                UserDao userDao,
                                PreferenceDao preferenceDao);   }
@Test(expectedExceptions = ApiException.class) public void shouldNotValidateIfNoModulePath() throws ApiException, ParseException { ProjectModule module = DtoFactory.newDto(ProjectModule.class).withType("maven"); NewProject newProject = DtoFactory.newDto(NewProject.class).withModules(Arrays.asList(module)); Factory localFactory = DtoFactory.getInstance().clone(factory).withProject(newProject); validator.validateModules(localFactory); }
@Test(expectedExceptions = ApiException.class) public void shouldNotValidateIfNoModuleType() throws ApiException, ParseException { ProjectModule module = DtoFactory.newDto(ProjectModule.class).withPath("/module/path"); NewProject newProject = DtoFactory.newDto(NewProject.class).withModules(Arrays.asList(module)); Factory localFactory = DtoFactory.getInstance().clone(factory).withProject(newProject); validator.validateModules(localFactory); }