use of com.canoo.dp.impl.client.DolphinCommandHandler 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");
}
Aggregations