public void testAddWhenValidationFails() {
// TODO comment tester unitairement la construction de l'objet à l'aide de la factory ???
Story story = new StoryImpl();
BusinessValue businessValue = new BusinessValueImpl();
businessValue.setId(1);
RiskLevel riskLevel = new RiskLevelImpl();
riskLevel.setId(2);
story.setPersistanceId(1);
story.setBusinessValue(businessValue);
story.setRiskLevel(riskLevel);
Project project = new ProjectImpl();
project.setPersistanceId(5);
story.setProject(project);
story.setShortDescription("titi");
story.setDescription("toto");
story.setDaysEstimated(2);
//MockCore.startBlock();
// recherche bu basicProject
EasyMock.expect(mockProjectRepository.findByPersistanceId(story.getProject().getPersistanceId())).andReturn(project);
// recherche des business value et risk level
EasyMock.expect(mockBusinessValueRepository.findById(story.getBusinessValue().getId())).andReturn(businessValue);
EasyMock.expect(mockRiskLevelRepository.findById(story.getRiskLevel().getId())).andReturn(riskLevel);
//MockCore.endBlock();
// validation
errors.reject("code");
EasyMock.expect(mockStoryValidator.validate(EasyMock.isA(Story.class))).andReturn(errors);
// set mock in replay mode
mocksControl.replay();
Errors errorsFromService = storyService.add(story.getProject().getPersistanceId(), story.getShortDescription(), story.getDescription(), story.getDaysEstimated(), story.getBusinessValue().getId(), story.getRiskLevel().getId());
// Vérification des appels
mocksControl.verify();
// les erreurs sont retournées