use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldEncodeValueChangedCommandWithIntegers.
@Test
public void shouldEncodeValueChangedCommandWithIntegers() {
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue(42);
command.setAttributeId("3357S");
final String actual = OptimizedJsonCodec.getInstance().encode(Collections.<Command>singletonList(command));
assertThat(actual, is("[{\"a_id\":\"3357S\",\"v\":42,\"id\":\"ValueChanged\"}]"));
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand 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.ValueChangedCommand 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));
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class TestOptimizedJsonCodec method shouldEncodeValueChangedCommandWithStrings.
@Test
public void shouldEncodeValueChangedCommandWithStrings() {
final ValueChangedCommand command = new ValueChangedCommand();
command.setNewValue("Good Bye");
command.setAttributeId("3357S");
final String actual = OptimizedJsonCodec.getInstance().encode(Collections.<Command>singletonList(command));
assertThat(actual, is("[{\"a_id\":\"3357S\",\"v\":\"Good Bye\",\"id\":\"ValueChanged\"}]"));
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class BlindCommandBatcherTest method testMergeCreatePmAfterValueChange.
@Test
public void testMergeCreatePmAfterValueChange() {
// given:
batcher.setMergeValueChanges(true);
List<CommandAndHandler> list = new ArrayList<CommandAndHandler>();
ValueChangedCommand command = new ValueChangedCommand();
command.setAttributeId("0");
command.setNewValue(1);
list.add(new CommandAndHandler(command));
list.add(new CommandAndHandler(new CreatePresentationModelCommand()));
// when:
for (CommandAndHandler commandAndHandler : list) {
batcher.batch(commandAndHandler);
}
// then:
try {
List<CommandAndHandler> nextBatch = batcher.getWaitingBatches().getVal();
Assert.assertEquals(2, nextBatch.size());
Assert.assertEquals(ValueChangedCommand.class, nextBatch.get(0).getCommand().getClass());
Assert.assertEquals(CreatePresentationModelCommand.class, nextBatch.get(1).getCommand().getClass());
Assert.assertTrue(batcher.isEmpty());
} catch (InterruptedException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
Aggregations