@Test() public void testDecodeRequestWithNoType() { final JsonMessageDecoder jsonMessageDecoder = createDecoder(); try { jsonMessageDecoder.decode(getResourceAsString("/messages/requestWithNoType.json")); fail("No DecodeException thrown"); } catch (DecodeException e) { System.out.println("e.getMessage() = " + e.getMessage()); assertTrue(e.getMessage().contains("No message type")); assertTrue(e.getMessage().contains("(sequence_id=a29e4fd0-581d-e06b-c837-4f5f4be7dd18)")); } }
@Test public void testDecodeValidMessageNoFields() throws DecodeException { final JsonMessageDecoder jsonMessageDecoder = createDecoder(); final Message msg = jsonMessageDecoder.decode(getResourceAsString("/messages/validLoginRequestNoFields.json")); assertNotNull(msg); assertEquals(LoginMessage.MESSAGE_TYPE, msg.getType()); assertNull(msg.getSequenceId()); assertThat(msg, is(instanceOf(LoginMessage.class))); assertEquals("*****@*****.**", ((LoginMessage) msg).getEmail()); assertNull(((LoginMessage) msg).getPassword()); }
@Test() public void testDecodeValidJsonInvalidRequest() throws DecodeException { final JsonMessageDecoder jsonMessageDecoder = createDecoder(); try { jsonMessageDecoder.decode(getResourceAsString("/messages/validJsonInvalidRequest.json")); fail("No DecodeException thrown"); } catch (DecodeException e) { System.out.println("e.getText() = " + e.getText()); System.out.println("e.getMessage() = " + e.getMessage()); assertTrue(e.getMessage().contains("Unknown password format")); assertTrue(e.getMessage().contains("(sequence_id=a29e4fd0-581d-e06b-c837-4f5f4be7dd18)")); } }