use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithIntegers.
@Test
public void shouldDecodeValueChangedCommandWithIntegers() {
final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":42,\"id\":\"ValueChanged\"}]");
final ValueChangedCommand command = (ValueChangedCommand) commands.get(0);
assertThat(command.getAttributeId(), is("3357S"));
assertThat(((Number) command.getNewValue()).intValue(), is(42));
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithBigInteger.
@Test
public void shouldDecodeValueChangedCommandWithBigInteger() {
final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":987654321234567890,\"id\":\"ValueChanged\"}]");
final ValueChangedCommand command = (ValueChangedCommand) commands.get(0);
assertThat(command.getAttributeId(), is("3357S"));
assertThat(((Number) command.getNewValue()).longValue(), is(987654321234567890L));
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldEncodeSingleNamedCommand.
@Test
public void shouldEncodeSingleNamedCommand() {
final Command command = createCommand();
final String actual = OptimizedJsonCodec.getInstance().encode(Collections.singletonList(command));
assertThat(actual, is("[" + createCommandJsonString() + "]"));
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithNulls.
@Test
public void shouldDecodeValueChangedCommandWithNulls() {
final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"id\":\"ValueChanged\"}]");
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue(null);
command.setAttributeId("3357S");
assertThat(commands, hasSize(1));
assertThat(commands.get(0), Matchers.<Command>samePropertyValuesAs(command));
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldDecodeValueChangedCommandWithDoubles.
@Test
public void shouldDecodeValueChangedCommandWithDoubles() {
final List<Command> commands = OptimizedJsonCodec.getInstance().decode("[{\"a_id\":\"3357S\",\"v\":2.7182,\"id\":\"ValueChanged\"}]");
final ValueChangedCommand command = (ValueChangedCommand) commands.get(0);
assertThat(command.getAttributeId(), is("3357S"));
assertThat(((Number) command.getNewValue()).doubleValue(), closeTo(2.7182, 1e-6));
}
Aggregations