use of com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand in project dolphin-platform by canoo.
the class ServerModelStore method presentationModelCommand.
/**
* Convenience method to let the client (!) dolphin create a presentation model as specified by the DTO.
* The server model store remains untouched until the client has issued the notification.
*/
@Deprecated
public static void presentationModelCommand(final List<Command> response, final String id, final String presentationModelType, final DTO dto) {
if (response == null) {
return;
}
List<Map<String, Object>> list = new ArrayList<>();
for (Slot slot : dto.getSlots()) {
Map<String, Object> map = new HashMap<>();
map.put("propertyName", slot.getPropertyName());
map.put("value", slot.getValue());
map.put("qualifier", slot.getQualifier());
list.add(map);
}
response.add(new CreatePresentationModelCommand(id, presentationModelType, list));
}
use of com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand in project dolphin-platform by canoo.
the class BlindCommandBatcherTest method testMergeCreatePmAfterValueChange.
@Test
public void testMergeCreatePmAfterValueChange() {
// 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));
list.add(new CommandAndHandler(new CreatePresentationModelCommand()));
// when:
for (CommandAndHandler commandAndHandler : list) {
batcher.batch(commandAndHandler);
}
// then:
try {
List<CommandAndHandler> nextBatch = batcher.getWaitingBatches().getVal();
Assert.assertEquals(2, nextBatch.size());
Assert.assertEquals(ValueChangedCommand.class, nextBatch.get(0).getCommand().getClass());
Assert.assertEquals(CreatePresentationModelCommand.class, nextBatch.get(1).getCommand().getClass());
Assert.assertTrue(batcher.isEmpty());
} catch (InterruptedException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand in project dolphin-platform by canoo.
the class ClientConnectorTests method testHandle_CreatePresentationModel_MergeAttributesToExistingModel.
@Test(expectedExceptions = IllegalStateException.class)
public void testHandle_CreatePresentationModel_MergeAttributesToExistingModel() {
clientModelStore.createModel("p1", null);
clientConnector.dispatchHandle(new CreatePresentationModelCommand("p1", "type", Collections.<Map<String, Object>>emptyList()));
}
use of com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand in project dolphin-platform by canoo.
the class ClientConnectorTests method testHandle_CreatePresentationModel.
@Test
public void testHandle_CreatePresentationModel() {
List<Map<String, Object>> attributes = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<>();
map.put("propertyName", "attr");
map.put("value", "initialValue");
map.put("qualifier", "qualifier");
((ArrayList<Map<String, Object>>) attributes).add(map);
clientConnector.dispatchHandle(new CreatePresentationModelCommand("p1", "type", attributes));
Assert.assertNotNull(clientModelStore.findPresentationModelById("p1"));
Assert.assertNotNull(clientModelStore.findPresentationModelById("p1").getAttribute("attr"));
Assert.assertEquals("initialValue", clientModelStore.findPresentationModelById("p1").getAttribute("attr").getValue());
Assert.assertEquals("qualifier", clientModelStore.findPresentationModelById("p1").getAttribute("attr").getQualifier());
syncAndWaitUntilDone();
assertCommandsTransmitted(2);
Assert.assertFalse(clientConnector.getTransmittedCommands().isEmpty());
Assert.assertEquals(CreatePresentationModelCommand.class, clientConnector.getTransmittedCommands().get(0).getClass());
}
use of com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand in project dolphin-platform by canoo.
the class ClientConnectorTests method testHandle_CreatePresentationModel_ClientSideOnly.
@Test
public void testHandle_CreatePresentationModel_ClientSideOnly() {
List<Map<String, Object>> attributes = new ArrayList<Map<String, Object>>();
Map map = new HashMap();
map.put("propertyName", "attr");
map.put("value", "initialValue");
map.put("qualifier", "qualifier");
((ArrayList<Map<String, Object>>) attributes).add(map);
clientConnector.dispatchHandle(new CreatePresentationModelCommand("p1", "type", attributes, true));
Assert.assertNotNull(clientModelStore.findPresentationModelById("p1"));
Assert.assertNotNull(clientModelStore.findPresentationModelById("p1").getAttribute("attr"));
Assert.assertEquals("initialValue", clientModelStore.findPresentationModelById("p1").getAttribute("attr").getValue());
Assert.assertEquals("qualifier", clientModelStore.findPresentationModelById("p1").getAttribute("attr").getQualifier());
syncAndWaitUntilDone();
assertOnlySyncCommandWasTransmitted();
}
Aggregations