Search in sources :

Example 16 with ValueChangedCommand

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());
}
Also used : ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 17 with ValueChangedCommand

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());
    }
}
Also used : CommandAndHandler(com.canoo.dp.impl.client.legacy.communication.CommandAndHandler) ArrayList(java.util.ArrayList) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 18 with ValueChangedCommand

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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) InterruptLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) PresentationModelDeletedCommand(com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand) AttributeMetadataChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand) DeletePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand) EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) ChangeAttributeMetadataCommand(com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand) ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 19 with ValueChangedCommand

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());
}
Also used : ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 20 with ValueChangedCommand

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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) InterruptLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) PresentationModelDeletedCommand(com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand) AttributeMetadataChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand) DeletePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand) EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) ChangeAttributeMetadataCommand(com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand) ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test)

Aggregations

ValueChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand)25 Test (org.testng.annotations.Test)22 CreatePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand)13 Command (com.canoo.dp.impl.remoting.legacy.communication.Command)12 EmptyCommand (com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand)11 CallActionCommand (com.canoo.dp.impl.remoting.commands.CallActionCommand)9 ClientAttribute (com.canoo.dp.impl.client.legacy.ClientAttribute)4 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)3 PresentationModelDeletedCommand (com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand)3 CommandAndHandler (com.canoo.dp.impl.client.legacy.communication.CommandAndHandler)2 InterruptLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand)2 StartLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)2 AttributeMetadataChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand)2 DeletePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 ArrayList (java.util.ArrayList)2 JsonParseException (com.google.gson.JsonParseException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1