use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldEncodeValueChangedCommandWithBooleans.
@Test
public void shouldEncodeValueChangedCommandWithBooleans() {
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue(false);
command.setAttributeId("3357S");
final String actual = OptimizedJsonCodec.getInstance().encode(Collections.<Command>singletonList(command));
assertThat(actual, is("[{\"a_id\":\"3357S\",\"v\":false,\"id\":\"ValueChanged\"}]"));
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithBooleans.
@Test
public void shouldDecodeValueChangedCommandWithBooleans() {
final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":false,\"id\":\"ValueChanged\"}]");
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue(false);
command.setAttributeId("3357S");
assertThat(commands, hasSize(1));
assertThat(commands.get(0), Matchers.<Command>samePropertyValuesAs(command));
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithStrings.
@Test
public void shouldDecodeValueChangedCommandWithStrings() {
final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":\"Good Bye\",\"id\":\"ValueChanged\"}]");
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue("Good Bye");
command.setAttributeId("3357S");
assertThat(commands, hasSize(1));
assertThat(commands.get(0), Matchers.<Command>samePropertyValuesAs(command));
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldEncodeValueChangedCommandWithFloats.
@Test
public void shouldEncodeValueChangedCommandWithFloats() {
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue(2.7182f);
command.setAttributeId("3357S");
final String actual = OptimizedJsonCodec.getInstance().encode(Collections.<Command>singletonList(command));
assertThat(actual, is("[{\"a_id\":\"3357S\",\"v\":2.7182,\"id\":\"ValueChanged\"}]"));
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class ValueChangedCommandEncoder method decode.
@Override
public ValueChangedCommand decode(final JsonObject jsonObject) {
Assert.requireNonNull(jsonObject, "jsonObject");
try {
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue(ValueEncoder.decodeValue(jsonObject.get(VALUE)));
command.setAttributeId(getStringElement(jsonObject, ATTRIBUTE_ID));
return command;
} catch (IllegalStateException | ClassCastException | NullPointerException ex) {
throw new JsonParseException("Illegal JSON detected", ex);
}
}
Aggregations