@Before public void setup() { response = new CommandResponse(command, status, message); }
@Test public void serializeCommandResponseContainsStatus() { boolean status = true; String serialized = JsonFormatter.serialize(new CommandResponse( Command.CommandType.VERSION, true)); assertThat(serialized, containsString("status")); assertThat(serialized, containsString("true")); }
@Test public void serializeCommandResponseWithMessage() { serializeDeserializeAndCheckEqual(new CommandResponse( Command.CommandType.DEVICE_ID, true, "bar")); serializeDeserializeAndCheckEqual(new CommandResponse( Command.CommandType.VERSION, true, "bar")); }
@Test public void serializeCommandResponseUsesStringCommand() { boolean status = true; String serialized = JsonFormatter.serialize(new CommandResponse( Command.CommandType.VERSION, true)); assertThat(serialized, containsString("version")); }
@Test public void serializeCommandResponse() { serializeDeserializeAndCheckEqual(new CommandResponse( Command.CommandType.DEVICE_ID, true)); }
@Test public void sameCommandAndMessageEquals() { CommandResponse anotherResponse = new CommandResponse( command, status, message); assertEquals(response, anotherResponse); }
@Test public void differentMessageDoesntEqual() { CommandResponse anotherResponse = new CommandResponse( command, status, message + " different"); assertFalse(response.equals(anotherResponse)); }
@Test public void differentStatusDoesntEqual() { CommandResponse anotherResponse = new CommandResponse( command, !status, message); assertFalse(response.equals(anotherResponse)); }
@Test public void differentCommandDoesntEqual() { CommandResponse anotherResponse = new CommandResponse( CommandType.DEVICE_ID, status); assertFalse(response.equals(anotherResponse)); }
message = response.getMessage(); return new CommandResponse(commandType, response.getStatus(), message);