PixOperationsServiceImpl implements PixOperationsService { @Override public RegistryResponse provideAndRegisterClinicalDocument(String c32xml) { c32xml = updatePatientAndAuthorId(c32xml); return xdsbRepository.provideAndRegisterDocumentSet(c32xml, PixManagerConstants.GLOBAL_DOMAIN_ID, XdsbDocumentType.CLINICAL_DOCUMENT); }  @Override MCCIIN000002UV01 addPatientRegistryRecord(String c32xml); @Override String addPerson(String reqXMLPath); SimpleMarshaller getMarshaller(); XdsbRepositoryService getXdsbRepository(); XmlAttributeSetter getXmlAttributeSetter(); @Override RegistryResponse provideAndRegisterClinicalDocument(String c32xml); @Override PixManagerBean queryPerson(String xmlFilePath); @Override MCCIIN000002UV01 revisePatientRegistryRecord(String c32xml); void setMarshaller(SimpleMarshaller marshaller); void setPixManagerTransformService(
			PixManagerTransformService pixManagerTransformService); void setPixMgrService(PixManagerService pixMgrService); void setRequestXMLToJava(PixManagerRequestXMLToJava requestXMLToJava); void setXdsbRegistryGetter(XdsbRegistryGetter xdsbRegistryGetter); void setXdsbRepository(XdsbRepositoryService xdsbRepository); void setXmlAttributeSetter(XmlAttributeSetter xmlAttributeSetter); @Override String updatePatientAndAuthorId(String c32xml); @Override String updatePerson(String reqXMLPath);  }
@Test public void testProvideAndRegisterClinicalDocument() throws JAXBException, IOException, Hl7v3TransformerException { final String c32XmlMock = "c32XmlMock"; final String hl7v3Xml = "hl7v3Xml"; final String eidMock = "eidMock"; final PRPAIN201309UV02 mockPRPAIN201309UV02 = new PRPAIN201309UV02(); final PRPAIN201310UV02 mockPRPAIN201310UV02 = new PRPAIN201310UV02(); final PixManagerBean pixManagerBeanMock = new PixManagerBean(); final HashMap<String, String> queryMap = new HashMap<String, String>(); queryMap.put(PixManagerConstants.GLOBAL_DOMAIN_ID, eidMock); final RegistryResponse registryResponseMock = new RegistryResponse(); pixManagerBeanMock.setQueryIdMap(queryMap); sut.setPixManagerTransformService(pixManagerTransformServiceMock); sut.setXdsbRegistryGetter(xdsbRegistryGetterMock); sut.setPixMgrService(pixMgrServiceMock); sut.setXdsbRepository(xdsbRepositoryMock); sut.setXmlAttributeSetter(xmlAttributeSetter); sut.setRequestXMLToJava(requestXMLToJavaMock); when( requestXMLToJavaMock.getPIXQueryReqObject(hl7v3Xml, PixManagerConstants.ENCODE_STRING)).thenReturn( mockPRPAIN201309UV02); when(pixMgrServiceMock.pixManagerPRPAIN201309UV02(mockPRPAIN201309UV02)) .thenReturn(mockPRPAIN201310UV02); when(pixManagerTransformServiceMock.getPixQueryXml(c32XmlMock)) .thenReturn(hl7v3Xml); doReturn(pixManagerBeanMock).when(sut).queryPerson(hl7v3Xml); when( xmlAttributeSetter.setAttributeValue(eq(c32XmlMock), anyString(), anyString(), anyString())) .thenReturn(c32XmlMock).thenReturn(c32XmlMock) .thenReturn(c32XmlMock).thenReturn(c32XmlMock) .thenReturn(c32XmlMock).thenReturn(c32XmlMock); when( xdsbRepositoryMock.provideAndRegisterDocumentSet(c32XmlMock, PixManagerConstants.GLOBAL_DOMAIN_ID, XdsbDocumentType.CLINICAL_DOCUMENT)).thenReturn( registryResponseMock); final RegistryResponse actualResponse = sut .provideAndRegisterClinicalDocument(c32XmlMock); assertEquals(registryResponseMock, actualResponse); }
@Test public void testProvideAndRegisterClinicalDocument() throws JAXBException, IOException, Hl7v3TransformerException { final String c32XmlMock = "c32XmlMock"; final String hl7v3Xml = "hl7v3Xml"; final String eidMock = "eidMock"; final PRPAIN201309UV02 mockPRPAIN201309UV02 = new PRPAIN201309UV02(); final PRPAIN201310UV02 mockPRPAIN201310UV02 = new PRPAIN201310UV02(); final PixManagerBean pixManagerBeanMock = new PixManagerBean(); final HashMap<String, String> queryMap = new HashMap<String, String>(); queryMap.put(PixManagerConstants.GLOBAL_DOMAIN_ID, eidMock); final RegistryResponse registryResponseMock = new RegistryResponse(); pixManagerBeanMock.setQueryIdMap(queryMap); sut.setPixManagerTransformService(pixManagerTransformServiceMock); sut.setXdsbRegistryGetter(xdsbRegistryGetterMock); sut.setPixMgrService(pixMgrServiceMock); sut.setXdsbRepository(xdsbRepositoryMock); sut.setXmlAttributeSetter(xmlAttributeSetter); sut.setRequestXMLToJava(requestXMLToJavaMock); when( requestXMLToJavaMock.getPIXQueryReqObject(hl7v3Xml, PixManagerConstants.ENCODE_STRING)).thenReturn( mockPRPAIN201309UV02); when(pixMgrServiceMock.pixManagerPRPAIN201309UV02(mockPRPAIN201309UV02)) .thenReturn(mockPRPAIN201310UV02); when(pixManagerTransformServiceMock.getPixQueryXml(c32XmlMock)) .thenReturn(hl7v3Xml); when(sut.queryPerson(hl7v3Xml)).thenReturn(pixManagerBeanMock); when( xmlAttributeSetter.setAttributeValue(eq(c32XmlMock), anyString(), anyString(), anyString())) .thenReturn(c32XmlMock).thenReturn(c32XmlMock) .thenReturn(c32XmlMock).thenReturn(c32XmlMock) .thenReturn(c32XmlMock).thenReturn(c32XmlMock); when( xdsbRepositoryMock.provideAndRegisterDocumentSet(c32XmlMock, PixManagerConstants.GLOBAL_DOMAIN_ID, XdsbDocumentType.CLINICAL_DOCUMENT)).thenReturn( registryResponseMock); final RegistryResponse actualResponse = sut .provideAndRegisterClinicalDocument(c32XmlMock); assertEquals(registryResponseMock, actualResponse); }