SoapDirectEdgeOrchestration { public RegistryResponseType orchestrate(ProvideAndRegisterDocumentSetRequestType prdst, SoapEdgeContext context) throws Exception { RegistryResponseType resp; SoapEdgeAuditor auditor = auditorFactory.getAuditor(); auditor.audit(SoapEdgeAuditor.PRINCIPAL, SoapEdgeAuditor.REQUESTRECIEVED_CATEGORY, SoapEdgeAuditor.REQUESTRECIEVED_MESSAGE, context); resp = sendMessage(prdst, context); auditor.audit(SoapEdgeAuditor.PRINCIPAL, SoapEdgeAuditor.RESPONSERETURNED_CATEGORY, SoapEdgeAuditor.RESPONSERETURNED_MESSAGE, context); return resp; } SoapDirectEdgeOrchestration();  SoapDirectEdgeOrchestration(SoapEdgeAuditorFactory auditorFactory,
            ToAddressParserFactory toParserFactory,
            FromAddressParserFactory fromParserFactory,
            DirectAdapterFactory adapterFactory,
            XdsDirectDocumentsTransformer docTransformer); RegistryResponseType orchestrate(ProvideAndRegisterDocumentSetRequestType prdst, SoapEdgeContext context);  }
@Test public void testOrchestrate() throws Exception{ SoapDirectEdgeOrchestration orch = new SoapDirectEdgeOrchestration(mockAuditorFactory, mockToParserFactory, mockFromParserFactory, mockAdapterFactory, mockDocTransformer); when(mockAuditorFactory.getAuditor()).thenReturn(mockAuditor); final DirectDocuments documents = new DirectDocuments(); when(mockDocTransformer.transform(mockRequest)).thenReturn(documents); when(mockContext.getDirectTo()).thenReturn(TO_ADDRESS_VALUE); when(mockContext.getDirectFrom()).thenReturn(FROM_ADDRESS_VALUE); when(mockContext.getMessageId()).thenReturn(MESSAGE_ID); Address toAddress = mock(Address.class); Set<Address> toAddresses = new HashSet<>(); toAddresses.add(toAddress); Address[] addressArray = toAddresses.toArray(new Address[0]); Address fromAddress = mock(Address.class); when(mockToParserFactory.getToParser()).thenReturn(mockToParser); when(mockFromParserFactory.getFromParser()).thenReturn(mockFromParser); when(mockToParser.parse(TO_ADDRESS_VALUE, documents)).thenReturn(toAddresses); when(mockFromParser.parse(FROM_ADDRESS_VALUE, documents)).thenReturn(fromAddress); when(mockAdapterFactory.getDirectSender()).thenReturn(mockSender); RegistryResponseType response = orch.orchestrate(mockRequest, mockContext); verify(mockAuditor).audit(SoapEdgeAuditor.PRINCIPAL, SoapEdgeAuditor.REQUESTRECIEVED_CATEGORY, SoapEdgeAuditor.REQUESTRECIEVED_MESSAGE, mockContext); verify(mockToParser).parse(TO_ADDRESS_VALUE, documents); verify(mockFromParser).parse(FROM_ADDRESS_VALUE, documents); verify(mockSender).sendOutboundDirect(fromAddress, addressArray, documents, MESSAGE_ID); verify(mockAuditor).audit(SoapEdgeAuditor.PRINCIPAL, SoapEdgeAuditor.RESPONSERETURNED_CATEGORY, SoapEdgeAuditor.RESPONSERETURNED_MESSAGE, mockContext); assertNotNull(response); assertEquals(response.getStatus(), NhincConstants.NHINC_ADHOC_QUERY_SUCCESS_RESPONSE); }