@Test(expected = ObjectNotFoundException.class) public void testProjectData_notFound() { projectAction.setProjectId(-1); expect(projectBusiness.getProjectData(-1)).andThrow(new ObjectNotFoundException()); replayAll(); projectAction.projectData(); verifyAll(); }
@Before public void setUp_dependencies() { projectAction = new ProjectAction(); projectAction.setProjectId(1); projectBusiness = createMock(ProjectBusiness.class); projectAction.setProjectBusiness(projectBusiness); }
@Test public void testRetrieve() { projectAction.setProjectId(1); expect(projectBusiness.retrieve(1)).andReturn(project); replayAll(); projectAction.retrieve(); assertEquals(project, projectAction.getProject()); verifyAll(); }
@Test public void testProjectData() { ProjectTO projTO = new ProjectTO(project); projectAction.setProjectId(project.getId()); expect(projectBusiness.getProjectData(project.getId())).andReturn(projTO); replayAll(); assertEquals(Action.SUCCESS, projectAction.projectData()); assertEquals(projTO, projectAction.getProject()); verifyAll(); }
@Test(expected = ObjectNotFoundException.class) public void testDelete_noSuchIteration() { projectAction.setProjectId(-1); projectBusiness.delete(-1); expect(projectBusiness.retrieve(-1)).andThrow(new ObjectNotFoundException()); replayAll(); projectAction.setConfirmationString("yes"); projectAction.delete(); verifyAll(); }
@Test public void testStore() { ProjectTO dummy = new ProjectTO(new Project()); projectAction.setProductId(313); projectAction.setProjectId(1); projectAction.setProject(project); expect(projectBusiness.store(1, 313, project, null)).andReturn(dummy); replayAll(); projectAction.store(); assertEquals(dummy, projectAction.getProject()); verifyAll(); }
@Test public void testProjectMetrics() { ProjectMetrics metrics = new ProjectMetrics(); projectAction.setProjectId(project.getId()); expect(projectBusiness.retrieve(project.getId())).andReturn(project); expect(projectBusiness.getProjectMetrics(project)).andReturn(metrics); replayAll(); assertEquals(Action.SUCCESS, projectAction.projectMetrics()); assertEquals(metrics, projectAction.getProjectMetrics()); verifyAll(); }