/** This method test a few specila inquirey fields are set up properly. */ @Test public void testGetInquiryUrl() { Protocol protocol = initProtocol(); final KcPersonService kcPersonService = context.mock(KcPersonService.class); final String principalId = GlobalVariables.getUserSession().getPrincipalId(); context.checking( new Expectations() { { one(kcPersonService).getKcPersonByPersonId(principalId); will(returnValue(KcPerson.fromPersonId(principalId))); } }); protocolLookupableHelperServiceImpl.setKcPersonService(kcPersonService); HtmlData inquiryUrl = protocolLookupableHelperServiceImpl.getInquiryUrl(protocol, "leadUnitNumber"); assertEquals(((HtmlData.AnchorHtmlData) inquiryUrl).getHref(), UNIT_INQ_URL); inquiryUrl = protocolLookupableHelperServiceImpl.getInquiryUrl(protocol, "investigator"); assertEquals(((HtmlData.AnchorHtmlData) inquiryUrl).getHref(), PERSON_INQ_URL); ProtocolPerson protocolPerson = (ProtocolPerson) protocol.getProtocolPersons().get(0); protocolPerson.setPersonId(""); protocolPerson.setRolodexId(new Integer(1727)); protocol.getProtocolPersons().clear(); protocol.getProtocolPersons().add(protocolPerson); inquiryUrl = protocolLookupableHelperServiceImpl.getInquiryUrl(protocol, "investigator"); assertEquals(((HtmlData.AnchorHtmlData) inquiryUrl).getHref(), ROLODEX_INQ_URL); }
/* * * This method is to set up protocol for get inquiry url test * @return */ private Protocol initProtocol() { Protocol protocol = new Protocol(); protocol.setLeadUnitNumber("000001"); protocol.setPrincipalInvestigatorId("10000000001"); ProtocolPerson protocolPerson = new ProtocolPerson(); protocolPerson.setPersonId("10000000001"); protocol.getProtocolPersons().add(protocolPerson); protocolPerson.setProtocolPersonRoleId("PI"); return protocol; }