DirectEdgeProxySoapImpl implements DirectEdgeProxy { @Override public RegistryResponseType provideAndRegisterDocumentSetB(MimeMessage message) { LOG.debug("Begin provideAndRegisterDocumentSetB"); RegistryResponseType response = null; try { ProvideAndRegisterDocumentSetRequestType prdsrt = null; if (message instanceof MimeMessage) { prdsrt = new MimeMessageTransformer().transform(message); } else { LOG.warn("MimeMessage was expected but not recieved."); } String url = oProxyHelper .getAdapterEndPointFromConnectionManager(NhincConstants.DIRECT_SOAP_EDGE_SERVICE_NAME); if (NullChecker.isNotNullish(url)) { ServicePortDescriptor<DocumentRepositoryPortType> portDescriptor = new DirectEdgeSoapServicePortDescriptor(); CONNECTClient<DocumentRepositoryPortType> client = getClient(portDescriptor, url); response = (RegistryResponseType) client.invokePort(DocumentRepositoryPortType.class, "documentRepositoryProvideAndRegisterDocumentSetB", prdsrt); } else { handleError("Failed to call the web service (" + NhincConstants.DIRECT_SOAP_EDGE_SERVICE_NAME + "). The URL is null.", message); } } catch (Exception ex) { handleError("Error sending Adapter Doc Submission Unsecured message: ", ex, message); } LOG.debug("End provideAndRegisterDocumentSetB"); return response; } DirectEdgeProxySoapImpl(WebServiceProxyHelper oProxyHelper); @Override RegistryResponseType provideAndRegisterDocumentSetB(MimeMessage message);  }
@Test(expected = DirectException.class) public void testSendWithNoURL() throws MessagingException { MimeMessage message = new MimeMessage(null, IOUtils.toInputStream(DirectUnitTestUtil .getFileAsString("Example_A.txt"))); RegistryResponseType resp = objectUnderTest.provideAndRegisterDocumentSetB(message); }
@SuppressWarnings("unchecked") @Test public void testSendWithMockedObjects() throws Exception { mockClient = mock(CONNECTClient.class); when(mockClient.invokePort(eq(DocumentRepositoryPortType.class), eq("documentRepositoryProvideAndRegisterDocumentSetB"), any(ProvideAndRegisterDocumentSetRequestType.class))).thenReturn(getSuccessResponse()); when(mockWebServiceProxyHelper.getAdapterEndPointFromConnectionManager(any(String.class))).thenReturn( ENDPOINT_URL); MimeMessage message = new MimeMessage(null, IOUtils.toInputStream(DirectUnitTestUtil .getFileAsString("Example_A.txt"))); objectUnderTest = getProxyWithMockClient(); RegistryResponseType resp = objectUnderTest.provideAndRegisterDocumentSetB(message); assertTrue(resp.getStatus().contains("Success")); }