@Test public void deserializeHandleException() throws IOException { // given thrown.expect(RuntimeException.class); thrown.expectMessage("Exception while parsing response [requestBytes] for verification"); // and when(objectMapper.readValue(eq("requestBytes"), same(VerificationDTO.class))) .thenThrow(new IOException("TEST EXCEPTION")); // when verificationSerializer.deserialize("requestBytes"); }
@Test public void deserialize() throws IOException { // given when(objectMapper.readValue(eq("requestBytes"), same(VerificationDTO.class))) .thenReturn(fullVerificationDTO); // when Verification verification = verificationSerializer.deserialize("requestBytes"); // then assertEquals(fullVerification, verification); }