@Test public void handleOperationalDataRequest() throws Exception { InputStream is = new FileInputStream(OPERATIONAL_DATA_REQUEST); SoapParser parser = new SoapParserImpl(); SoapMessageImpl request = (SoapMessageImpl) parser.parse( MimeTypes.TEXT_XML_UTF8, is); QueryRequestHandler handler = new OperationalDataRequestHandler() { @Override protected OperationalDataRecords getOperationalDataRecords( ClientId filterByClient, long recordsFrom, long recordsTo, ClientId filterByServiceProvider, Set<String> outputFields) { return new OperationalDataRecords(Collections.emptyList()); } @Override protected ClientId getClientForFilter(ClientId clientId, SecurityServerId serverId) throws Exception { return null; } }; OutputStream out = new ByteArrayOutputStream(); handler.handle(request, out, ct -> testContentType = ct); String baseContentType = MimeUtils.getBaseContentType(testContentType); assertEquals(MimeTypes.MULTIPART_RELATED, baseContentType); SoapMessageDecoder decoder = new SoapMessageDecoder(testContentType, new SoapMessageDecoder.Callback() { @Override public void soap(SoapMessage message, Map<String, String> headers) throws Exception { assertEquals("cid:" + OperationalDataRequestHandler.CID, findRecordsContentId(message)); } @Override public void attachment(String contentType, InputStream content, Map<String, String> additionalHeaders) throws Exception { String expectedCid = "<" + OperationalDataRequestHandler.CID + ">"; assertEquals(expectedCid, additionalHeaders.get("content-id")); } @Override public void onCompleted() { } @Override public void onError(Exception t) throws Exception { throw t; } @Override public void fault(SoapFault fault) throws Exception { throw fault.toCodedException(); } }); decoder.parse(IOUtils.toInputStream(out.toString())); }
abstract void handle(SoapMessageImpl requestSoap, OutputStream out, Consumer<String> contentTypeCallback) throws Exception;
QueryRequestHandler { abstract void handle(SoapMessageImpl requestSoap, OutputStream out, Consumer<String> contentTypeCallback) throws Exception; }
QueryRequestHandler { abstract void handle(SoapMessageImpl requestSoap, OutputStream out, Consumer<String> contentTypeCallback) throws Exception;  }
QueryRequestHandler { abstract void handle(SoapMessageImpl requestSoap, OutputStream out, Consumer<String> contentTypeCallback) throws Exception;   }
QueryRequestHandler { abstract void handle(SoapMessageImpl requestSoap, OutputStream out, Consumer<String> contentTypeCallback) throws Exception;    }