@Test public void testEnter_NoSubinvestigatorId() { action.setPersonAssociation(null); thrown.expect(NullPointerException.class); thrown.expectMessage("No Person Association selected for removal."); action.enter(); }
@Test public void testEnter_NoProfile() { action.setProfile(null); thrown.expect(NullPointerException.class); thrown.expectMessage( "User Profile does not exist! You must create a user profile before editing an person."); action.enter(); }
private void checkRegistrationInJson(SubInvestigatorRegistration registration, String json) { assertTrue(json.contains(registration.getId().toString())); assertTrue(json.contains(registration.getProtocol().getProtocolTitle())); InvestigatorRegistration primaryRegistration = registration.getPrimaryRegistration(); assertTrue(json.contains(primaryRegistration.getStatus().getDisplay())); if (primaryRegistration.isLockedForInvestigator() || primaryRegistration.getStatus() == RegistrationStatus.RETURNED) { assertTrue(json.contains(action.getText("label.no"))); } else { assertTrue(json.contains(action.getText("label.yes"))); } }
@Before @Override public void setUp() throws Exception { super.setUp(); action.setServletRequest(getMockRequest()); subInvestigator = profile.addSubInvestigator(person); subInvestigator.setId(ValueGenerator.getUniqueLong()); action.setProfile(profile); action.setPersonAssociationId(subInvestigator.getId()); action.setPersonAssociation(subInvestigator); when(mockPersonAssociationService.getSubInvestigatorById(subInvestigator.getId())) .thenReturn(subInvestigator); }
@Test public void testGetSubinvestigatorRegistrationsJson() throws JSONException { SubInvestigatorRegistration inProgressReg = createSubInvestigatorRegistration(RegistrationStatus.IN_PROGRESS); SubInvestigatorRegistration returnedReg = createSubInvestigatorRegistration(RegistrationStatus.RETURNED); SubInvestigatorRegistration submittedReg = createSubInvestigatorRegistration(RegistrationStatus.SUBMITTED); when(mockRegistrationService.getSubinvestigatorRegistrations(profile, person)) .thenReturn(Lists.newArrayList(inProgressReg, returnedReg, submittedReg)); String json = action.getSubinvestigatorRegistrationsJson(); checkRegistrationInJson(inProgressReg, json); checkRegistrationInJson(returnedReg, json); checkRegistrationInJson(submittedReg, json); }
@Test public void testRemovePersonAssociation() { assertEquals(FirebirdUIConstants.RETURN_CLOSE_DIALOG, action.removePersonAssociation()); verify(mockProfileService).deleteAssociatedSubInvestigator(profile, subInvestigator); }
@Test public void testEnter_SubInvestigator() { assertEquals(ActionSupport.SUCCESS, action.enter()); }
@Test public void testPrepare() { action.setPersonAssociation(null); action.prepare(); assertSame(subInvestigator, action.getPersonAssociation()); }