FastInfosetDecompressorProcessor extends ProcessorBase { @Override public void process(final WilmaHttpEntity entity) { if (isContentFISCompressed(entity)) { ByteArrayOutputStream compressedBody = fastinfosetDecompressor.decompress(entity.getInputStream()); entity.setBody(compressedBody.toString()); } }  @Override void process(final WilmaHttpEntity entity);  }
@Test public void testProcessShouldCallDecompressWhenFIDecompressionNeeded() throws ApplicationException { given(entity.getHeader(CONTENT_TYPE)).willReturn(FAST_INFO_SET); given(entity.getInputStream()).willReturn(inputStream); given(fastinfosetDecompressor.decompress(inputStream)).willReturn(body); underTest.process(entity); verify(fastinfosetDecompressor).decompress(inputStream); }
@Test public void testProcessShouldSetBodyWhenFIDecompressionNeeded() throws ApplicationException { given(entity.getHeader(CONTENT_TYPE)).willReturn(FAST_INFO_SET); given(entity.getInputStream()).willReturn(inputStream); given(fastinfosetDecompressor.decompress(inputStream)).willReturn(body); underTest.process(entity); verify(entity).setBody(body.toString()); }
@Test public void testProcessShouldSetNotBodyWhenFIDecompressionNotNeeded() throws ApplicationException { given(entity.getHeader(CONTENT_TYPE)).willReturn("xml"); given(entity.getInputStream()).willReturn(inputStream); given(fastinfosetDecompressor.decompress(inputStream)).willReturn(body); underTest.process(entity); verify(entity, never()).setBody(body.toString()); }
@Test public void testProcessShouldSetNotBodyWhenHeaderIsNull() throws ApplicationException { given(entity.getHeader(CONTENT_TYPE)).willReturn(null); given(entity.getInputStream()).willReturn(inputStream); given(fastinfosetDecompressor.decompress(inputStream)).willReturn(body); underTest.process(entity); verify(entity, never()).setBody(body.toString()); }