Search in sources :

Example 1 with ClientAttribute

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

the class ClientResponseHandler method handleCreatePresentationModelCommand.

private void handleCreatePresentationModelCommand(final CreatePresentationModelCommand serverCommand) {
    if (clientModelStore.containsPresentationModel(serverCommand.getPmId())) {
        throw new IllegalStateException("There already is a presentation model with id '" + serverCommand.getPmId() + "' known to the client.");
    }
    List<ClientAttribute> attributes = new ArrayList<ClientAttribute>();
    for (Map<String, Object> attr : serverCommand.getAttributes()) {
        Object propertyName = attr.get("propertyName");
        Object value = attr.get("value");
        Object qualifier = attr.get("qualifier");
        Object id = attr.get("id");
        ClientAttribute attribute = new ClientAttribute(propertyName != null ? propertyName.toString() : null, value, qualifier != null ? qualifier.toString() : null);
        if (id != null && id.toString().endsWith("S")) {
            attribute.setId(id.toString());
        }
        attributes.add(attribute);
    }
    ClientPresentationModel model = new ClientPresentationModel(serverCommand.getPmId(), attributes);
    model.setPresentationModelType(serverCommand.getPmType());
    if (serverCommand.isClientSideOnly()) {
        model.setClientSideOnly(true);
    }
    clientModelStore.add(model);
    clientModelStore.updateQualifiers(model);
}
Also used : ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) ArrayList(java.util.ArrayList) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel)

Example 2 with ClientAttribute

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

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

the class ClientConnectorTests method testMetaDataChange_UnregisteredAttribute.

@Test
public void testMetaDataChange_UnregisteredAttribute() {
    ClientAttribute attribute = new ExtendedAttribute("attr", "initialValue", "qualifier");
    ((ExtendedAttribute) attribute).setAdditionalParam("oldValue");
    attributeChangeListener.propertyChange(new PropertyChangeEvent(attribute, "additionalParam", null, "newTag"));
    syncAndWaitUntilDone();
    assertCommandsTransmitted(2);
    Assert.assertFalse(clientConnector.getTransmittedCommands().isEmpty());
    Assert.assertEquals(ChangeAttributeMetadataCommand.class, clientConnector.getTransmittedCommands().get(0).getClass());
    Assert.assertEquals("oldValue", ((ExtendedAttribute) attribute).getAdditionalParam());
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) Test(org.testng.annotations.Test)

Example 4 with ClientAttribute

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

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

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