@Test public void testConversionTimeout() throws Exception { InputStream inputStream = MockConversion.TIMEOUT.toInputStream(MESSAGE); MockConversion.RichMessage richMessage = MockConversion.from(inputStream); assertEquals(MockConversion.TIMEOUT, richMessage.getMockConversion()); assertEquals(MESSAGE, richMessage.getMessage()); IInputStreamConsumer callback = mock(IInputStreamConsumer.class); richMessage.applyTo(callback); verifyZeroInteractions(callback); }
@Test public void testConversionError() throws Exception { InputStream inputStream = MockConversion.CONVERTER_ERROR.toInputStream(MESSAGE); MockConversion.RichMessage richMessage = MockConversion.from(inputStream); assertEquals(MockConversion.CONVERTER_ERROR, richMessage.getMockConversion()); assertEquals(MESSAGE, richMessage.getMessage()); IInputStreamConsumer callback = mock(IInputStreamConsumer.class); richMessage.applyTo(callback); verify(callback).onException(any(ConverterException.class)); verifyNoMoreInteractions(callback); }
@Test public void testConversionCancel() throws Exception { InputStream inputStream = MockConversion.CANCEL.toInputStream(MESSAGE); MockConversion.RichMessage richMessage = MockConversion.from(inputStream); assertEquals(MockConversion.CANCEL, richMessage.getMockConversion()); assertEquals(MESSAGE, richMessage.getMessage()); IInputStreamConsumer callback = mock(IInputStreamConsumer.class); richMessage.applyTo(callback); verify(callback).onCancel(); verifyNoMoreInteractions(callback); }