PixServiceImpl implements PixService { @Override public String getEid(String mrn) { String eid = null; PixManagerBean pixManagerBean = queryPatient(mrn, this.mrnDomain); if (pixManagerBean != null) { Map<String, String> queryMap = pixManagerBean.getQueryIdMap(); if (null != queryMap) { eid = queryMap.get(PixManagerConstants.GLOBAL_DOMAIN_ID); } } Assert.hasText(eid, "The MRN cannot be transformed to an HL7v3 message or EID cannot be retrieved!"); return eid; } PixServiceImpl(String mrnDomain, String pidPrefix,
			PixManagerRequestXMLToJava requestXMLToJava,
			PixManagerService pixManagerService,
			PixManagerMessageHelper pixManagerMessageHelper,
			Hl7v3Transformer hl7v3Transformer, SimpleMarshaller simpleMarshaller); @Override String getEid(String mrn); @Override PixManagerBean queryPatient(String mrn, String mrnDomain); @Override PixManagerBean addPatient(PixPatientDto pixPatientDto); @Override PixManagerBean updatePatient(PixPatientDto pixPatientDto);  }
@Test public void testGetEid() throws Hl7v3TransformerException, JAXBException, IOException { ReflectionTestUtils.setField(sut, "mrnDomain", MRN_DOMAIN); PixManagerConstants.GLOBAL_DOMAIN_ID = EXPECTED_DOMAIN; arrangeCommonValid(); String eid = sut.getEid(MRN); assertEquals(EXPECTED_EID, eid); verify(marshallerMock, times(2)).marshal(anyObject()); }
@SuppressWarnings("unchecked") @Test public void testGetEid_Query_Failure_Hl7v3TransformerException() throws Hl7v3TransformerException { thrown.expect(IllegalArgumentException.class); ReflectionTestUtils.setField(sut, "mrnDomain", MRN_DOMAIN); PixManagerConstants.GLOBAL_DOMAIN_ID = EXPECTED_DOMAIN; when( hl7v3Transformer.getPixQueryXml(MRN, MRN_DOMAIN, Hl7v3Transformer.XML_PIX_QUERY)).thenThrow( Hl7v3TransformerException.class); String eid = sut.getEid(MRN); assertNull(eid); }