@Test public void testDelete_deleteChoices_withChildren_deleteChildren() { Story child = new Story(); child.setBacklog(storyInIteration.getBacklog()); child.setIteration(iteration); child.setId(2333); child.setParent(storyInIteration); storyInIteration.getChildren().add(child); storyInIteration.setIteration(null); blheBusiness.updateHistory(child.getBacklog().getId()); iheBusiness.updateIterationHistory(iteration.getId()); hourEntryBusiness.deleteAll(child.getHourEntries()); hourEntryBusiness.deleteAll(storyInIteration.getHourEntries()); // storyRankBusiness.removeStoryRanks(child); // storyRankBusiness.removeStoryRanks(storyInIteration); // expect(storyDAO.get(2333)).andReturn(child); storyDAO.remove(child.getId()); storyDAO.remove(storyInIteration); replayAll(); storyBusiness.delete( storyInIteration, TaskHandlingChoice.DELETE, HourEntryHandlingChoice.DELETE, HourEntryHandlingChoice.DELETE, ChildHandlingChoice.DELETE); // assertNull(child.getParent()); assertTrue(storyInIteration.getChildren().isEmpty()); verifyAll(); }
@Test public void testStore_updateBacklogAndClearResponsibles() { this.store_createMockStoryBusiness(); Backlog newBacklog = new Project(); newBacklog.setId(123); Set<User> users = new HashSet<User>(Arrays.asList(new User(), new User())); storyInIteration.setResponsibles(users); expect(storyDAO.get(storyInIteration.getId())).andReturn(storyInIteration); expect(backlogBusiness.retrieve(newBacklog.getId())).andReturn(newBacklog); storyDAO.store(EasyMock.isA(Story.class)); blheBusiness.updateHistory(storyInIteration.getBacklog().getId()); replayAll(); Story actual = storyBusiness.store( storyInIteration.getId(), new Story(), newBacklog.getId(), new HashSet<Integer>(), false); verifyAll(); assertEquals(0, actual.getResponsibles().size()); assertTrue(storyBacklogUpdated); }
@Test public void testDeleteAndUpdateHistory() { expect(storyDAO.get(storyInIteration.getId())).andReturn(storyInIteration); // storyRankBusiness.removeStoryRanks(storyInIteration); storyDAO.remove(storyInIteration); blheBusiness.updateHistory(storyInIteration.getBacklog().getId()); iheBusiness.updateIterationHistory(storyInIteration.getIteration().getId()); replayAll(); storyBusiness.deleteAndUpdateHistory(storyInIteration.getId(), null, null, null, null); verifyAll(); }
@Test public void testStore_updateResponsibles() { this.store_createMockStoryBusiness(); Backlog backlog = storyInIteration.getBacklog(); User user1 = new User(); User user2 = new User(); Set<User> users = new HashSet<User>(Arrays.asList(user1, user2)); expect(storyDAO.get(storyInIteration.getId())).andReturn(storyInIteration); expect(userDAO.get(123)).andReturn(user1); expect(userDAO.get(222)).andReturn(user2); storyDAO.store(EasyMock.isA(Story.class)); Story dataItem = new Story(); dataItem.setName("Foo item"); dataItem.setDescription("Fubar"); dataItem.setStoryPoints(333); dataItem.setState(StoryState.PENDING); blheBusiness.updateHistory(storyInIteration.getBacklog().getId()); replayAll(); Story actual = storyBusiness.store( storyInIteration.getId(), dataItem, null, new HashSet<Integer>(Arrays.asList(123, 222)), false); verifyAll(); assertSame("The backlogs don't match", backlog, actual.getBacklog()); assertEquals("The responsibles don't match", users, actual.getResponsibles()); assertEquals(dataItem.getName(), actual.getName()); assertEquals(dataItem.getDescription(), actual.getDescription()); assertEquals(dataItem.getStoryPoints(), actual.getStoryPoints()); assertEquals(dataItem.getState(), actual.getState()); assertFalse(storyBacklogUpdated); }