use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class ClientConnectorTests method testHandle_ValueChanged.
@Test
public void testHandle_ValueChanged() {
ClientAttribute attribute = new ClientAttribute("attr", "initialValue");
clientModelStore.registerAttribute(attribute);
clientConnector.dispatchHandle(new ValueChangedCommand(attribute.getId(), "newValue"));
Assert.assertEquals("newValue", attribute.getValue());
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class BlindCommandBatcherTest method testMergeInOneCommand.
@Test
public void testMergeInOneCommand() {
// 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));
ValueChangedCommand command1 = new ValueChangedCommand();
command1.setAttributeId("0");
command1.setNewValue(2);
list.add(new CommandAndHandler(command1));
ValueChangedCommand command2 = new ValueChangedCommand();
command2.setAttributeId("0");
command2.setNewValue(3);
list.add(new CommandAndHandler(command2));
// when:
for (CommandAndHandler commandAndHandler : list) {
batcher.batch(commandAndHandler);
}
// then:
try {
List<CommandAndHandler> nextBatch = batcher.getWaitingBatches().getVal();
Assert.assertEquals(1, nextBatch.size());
Assert.assertEquals(ValueChangedCommand.class, nextBatch.get(0).getCommand().getClass());
ValueChangedCommand cmd = (ValueChangedCommand) nextBatch.get(0).getCommand();
Assert.assertEquals(3, cmd.getNewValue());
Assert.assertTrue(batcher.isEmpty());
} catch (InterruptedException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class ClientConnectorTests method testValueChange_noQualifier.
@Test
public void testValueChange_noQualifier() {
ClientAttribute attribute = new ClientAttribute("attr", "initialValue");
clientModelStore.registerAttribute(attribute);
attributeChangeListener.propertyChange(new PropertyChangeEvent(attribute, Attribute.VALUE_NAME, attribute.getValue(), "newValue"));
syncAndWaitUntilDone();
assertCommandsTransmitted(2);
Assert.assertEquals("initialValue", attribute.getValue());
boolean valueChangedCommandFound = false;
for (Command c : clientConnector.getTransmittedCommands()) {
if (c instanceof ValueChangedCommand) {
}
valueChangedCommandFound = true;
}
Assert.assertTrue(valueChangedCommandFound);
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class ClientConnectorTests method testHandle_ValueChangedWithBadBaseValueIgnoredInNonStrictMode.
@Test
public void testHandle_ValueChangedWithBadBaseValueIgnoredInNonStrictMode() {
ClientAttribute attribute = new ClientAttribute("attr", "initialValue");
clientModelStore.registerAttribute(attribute);
clientConnector.dispatchHandle(new ValueChangedCommand(attribute.getId(), "newValue"));
Assert.assertEquals("newValue", attribute.getValue());
}
use of com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand in project dolphin-platform by canoo.
the class ClientConnectorTests method testValueChange_withQualifier.
@Test
public void testValueChange_withQualifier() {
syncDone = new CountDownLatch(1);
ClientAttribute attribute = new ClientAttribute("attr", "initialValue", "qualifier");
clientModelStore.registerAttribute(attribute);
attributeChangeListener.propertyChange(new PropertyChangeEvent(attribute, Attribute.VALUE_NAME, attribute.getValue(), "newValue"));
syncAndWaitUntilDone();
assertCommandsTransmitted(3);
Assert.assertEquals("newValue", attribute.getValue());
boolean valueChangedCommandFound = false;
for (Command c : clientConnector.getTransmittedCommands()) {
if (c instanceof ValueChangedCommand) {
}
valueChangedCommandFound = true;
}
Assert.assertTrue(valueChangedCommandFound);
}
Aggregations