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);
}
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());
}
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());
}
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);
}
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());
}
Aggregations