@Test public void testProcessShouldNotOnEmptyBody() throws ApplicationException, TransformerException { given(request.getBody()).willReturn(null); underTest.process(request); verify(request, never()).setBody(Mockito.anyString()); }
@Override public void process(final WilmaHttpEntity entity) throws ApplicationException { String body = entity.getBody(); if ((body == null) || (body.length() == 0)) { return; } String contentTypeHeader = entity.getHeader("Content-Type"); if (contentTypeHeader != null && contentTypeHeader.contains("xml") && !contentTypeHeader.contains("image/svg+xml")) { try { Transformer transformer = transformerFactory.createTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = streamResultFactory.createStreamResult(); StreamSource source = streamSourceFactory.createStreamSourceFromString(body); transformer.transform(source, result); String xmlString = result.getWriter().toString(); entity.setBody(xmlString); } catch (TransformerException e) { logError(entity, e); } } else if (contentTypeHeader != null && contentTypeHeader.contains("json")) { handleJsonContent(entity); } }
PrettyPrintProcessor extends ProcessorBase { @Override public void process(final WilmaHttpEntity entity) throws ApplicationException { String body = entity.getBody(); if ((body == null) || (body.length() == 0)) { return; } String contentTypeHeader = entity.getHeader("Content-Type"); if (contentTypeHeader != null && contentTypeHeader.contains("xml") && !contentTypeHeader.contains("image/svg+xml")) { try { Transformer transformer = transformerFactory.createTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = streamResultFactory.createStreamResult(); StreamSource source = streamSourceFactory.createStreamSourceFromString(body); transformer.transform(source, result); String xmlString = result.getWriter().toString(); entity.setBody(xmlString); } catch (TransformerException e) { logError(entity, e); } } else if (contentTypeHeader != null && contentTypeHeader.contains("json")) { handleJsonContent(entity); } } }
PrettyPrintProcessor extends ProcessorBase { @Override public void process(final WilmaHttpEntity entity) throws ApplicationException { String body = entity.getBody(); if ((body == null) || (body.length() == 0)) { return; } String contentTypeHeader = entity.getHeader("Content-Type"); if (contentTypeHeader != null && contentTypeHeader.contains("xml") && !contentTypeHeader.contains("image/svg+xml")) { try { Transformer transformer = transformerFactory.createTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = streamResultFactory.createStreamResult(); StreamSource source = streamSourceFactory.createStreamSourceFromString(body); transformer.transform(source, result); String xmlString = result.getWriter().toString(); entity.setBody(xmlString); } catch (TransformerException e) { logError(entity, e); } } else if (contentTypeHeader != null && contentTypeHeader.contains("json")) { handleJsonContent(entity); } }  }
PrettyPrintProcessor extends ProcessorBase { @Override public void process(final WilmaHttpEntity entity) throws ApplicationException { String body = entity.getBody(); if ((body == null) || (body.length() == 0)) { return; } String contentTypeHeader = entity.getHeader("Content-Type"); if (contentTypeHeader != null && contentTypeHeader.contains("xml") && !contentTypeHeader.contains("image/svg+xml")) { try { Transformer transformer = transformerFactory.createTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = streamResultFactory.createStreamResult(); StreamSource source = streamSourceFactory.createStreamSourceFromString(body); transformer.transform(source, result); String xmlString = result.getWriter().toString(); entity.setBody(xmlString); } catch (TransformerException e) { logError(entity, e); } } else if (contentTypeHeader != null && contentTypeHeader.contains("json")) { handleJsonContent(entity); } }  @Override void process(final WilmaHttpEntity entity); }
PrettyPrintProcessor extends ProcessorBase { @Override public void process(final WilmaHttpEntity entity) throws ApplicationException { String body = entity.getBody(); if ((body == null) || (body.length() == 0)) { return; } String contentTypeHeader = entity.getHeader("Content-Type"); if (contentTypeHeader != null && contentTypeHeader.contains("xml") && !contentTypeHeader.contains("image/svg+xml")) { try { Transformer transformer = transformerFactory.createTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = streamResultFactory.createStreamResult(); StreamSource source = streamSourceFactory.createStreamSourceFromString(body); transformer.transform(source, result); String xmlString = result.getWriter().toString(); entity.setBody(xmlString); } catch (TransformerException e) { logError(entity, e); } } else if (contentTypeHeader != null && contentTypeHeader.contains("json")) { handleJsonContent(entity); } }  @Override void process(final WilmaHttpEntity entity);  }