Search in sources :

Example 6 with ClientAttribute

use of com.canoo.dp.impl.client.legacy.ClientAttribute 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)

Example 7 with ClientAttribute

use of com.canoo.dp.impl.client.legacy.ClientAttribute in project dolphin-platform by canoo.

the class TestDolphinCommandHandler method testInvocation.

@Test
public void testInvocation() throws Exception {
    // Given:
    final DolphinTestConfiguration configuration = createDolphinTestConfiguration();
    final ServerModelStore serverModelStore = configuration.getServerModelStore();
    final ClientModelStore clientModelStore = configuration.getClientModelStore();
    final DolphinCommandHandler dolphinCommandHandler = new DolphinCommandHandler(configuration.getClientConnector());
    final String modelId = UUID.randomUUID().toString();
    clientModelStore.createModel(modelId, null, new ClientAttribute("myAttribute", "UNKNOWN"));
    configuration.getServerConnector().register(new DolphinServerAction() {

        @Override
        public void registerIn(ActionRegistry registry) {
            registry.register(TestChangeCommand.class, new CommandHandler() {

                @Override
                public void handleCommand(Command command, List response) {
                    serverModelStore.findPresentationModelById(modelId).getAttribute("myAttribute").setValue("Hello World");
                }
            });
        }
    });
    // When:
    dolphinCommandHandler.invokeDolphinCommand(new TestChangeCommand()).get();
    // Then:
    assertEquals(clientModelStore.findPresentationModelById(modelId).getAttribute("myAttribute").getValue(), "Hello World");
}
Also used : ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) CommandHandler(com.canoo.dp.impl.server.legacy.communication.CommandHandler) DolphinCommandHandler(com.canoo.dp.impl.client.DolphinCommandHandler) ActionRegistry(com.canoo.dp.impl.server.legacy.communication.ActionRegistry) DolphinCommandHandler(com.canoo.dp.impl.client.DolphinCommandHandler) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) List(java.util.List) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) DolphinServerAction(com.canoo.dp.impl.server.legacy.action.DolphinServerAction) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Aggregations

ClientAttribute (com.canoo.dp.impl.client.legacy.ClientAttribute)7 Test (org.testng.annotations.Test)6 ValueChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand)4 Command (com.canoo.dp.impl.remoting.legacy.communication.Command)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 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 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)2 CreatePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand)2 DeletePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand)2 EmptyCommand (com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand)2 PresentationModelDeletedCommand (com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand)2 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)1 DolphinCommandHandler (com.canoo.dp.impl.client.DolphinCommandHandler)1 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)1 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)1 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)1 DolphinServerAction (com.canoo.dp.impl.server.legacy.action.DolphinServerAction)1 ActionRegistry (com.canoo.dp.impl.server.legacy.communication.ActionRegistry)1