use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestDeleteAll method testWithSimpleModel.
@Test
public void testWithSimpleModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
SimpleTestModel model1 = manager.create(SimpleTestModel.class);
SimpleTestModel model2 = manager.create(SimpleTestModel.class);
SimpleTestModel model3 = manager.create(SimpleTestModel.class);
SimpleAnnotatedTestModel wrongModel = manager.create(SimpleAnnotatedTestModel.class);
for (final Object bean : manager.findAll(SimpleTestModel.class)) {
beanRepository.delete(bean);
}
assertThat(beanRepository.isManaged(model1), is(false));
assertThat(beanRepository.isManaged(model2), is(false));
assertThat(beanRepository.isManaged(model3), is(false));
assertThat(beanRepository.isManaged(wrongModel), is(true));
List<ServerPresentationModel> testModels = serverModelStore.findAllPresentationModelsByType("com.canoo.dolphin.server.util.SimpleTestModel");
assertThat(testModels, hasSize(0));
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class DefaultOpenDolphinFactoryTest method testDolphinCreation.
@Test
public void testDolphinCreation() {
final ServerModelStore modelStore = new ServerModelStore();
final ServerConnector serverConnector = new ServerConnector();
serverConnector.setCodec(OptimizedJsonCodec.getInstance());
serverConnector.setServerModelStore(modelStore);
final DefaultServerDolphin serverDolphin = new DefaultServerDolphin(modelStore, serverConnector);
serverDolphin.getServerConnector().registerDefaultActions();
assertNotNull(serverDolphin);
assertNotNull(serverDolphin.getModelStore());
assertNotNull(serverDolphin.getServerConnector());
assertNotNull(serverDolphin.getModelStore());
assertNotNull(serverDolphin.getServerConnector().getCodec());
assertEquals(OptimizedJsonCodec.class, serverDolphin.getServerConnector().getCodec().getClass());
assertEquals(serverDolphin.getServerConnector().getRegistry().getActions().size(), 4);
assertTrue(serverDolphin.getServerConnector().getRegistry().getActions().containsKey(ValueChangedCommand.class));
assertTrue(serverDolphin.getServerConnector().getRegistry().getActions().containsKey(CreatePresentationModelCommand.class));
assertTrue(serverDolphin.getServerConnector().getRegistry().getActions().containsKey(ChangeAttributeMetadataCommand.class));
assertTrue(serverDolphin.getServerConnector().getRegistry().getActions().containsKey(PresentationModelDeletedCommand.class));
assertEquals(serverDolphin.getModelStore().listPresentationModelIds().size(), 0);
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class AbstractDolphinBasedTest method createDolphinTestConfiguration.
protected DolphinTestConfiguration createDolphinTestConfiguration() {
DefaultInMemoryConfig config = new DefaultInMemoryConfig(DirectExecutor.getInstance());
config.getServerConnector().registerDefaultActions();
ServerModelStore store = config.getServerModelStore();
store.setCurrentResponse(new ArrayList<Command>());
return new DolphinTestConfiguration(config.getClientModelStore(), config.getServerModelStore(), config.getClientConnector(), config.getServerConnector());
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestObservableListSync method replacingSingleElementAtBeginningAsUser_shouldReplaceElement.
// ////////////////////////////////////////////////////////////
// Replacing elements from different positions as user
// ////////////////////////////////////////////////////////////
@Test
public void replacingSingleElementAtBeginningAsUser_shouldReplaceElement() {
// given :
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final String newValue = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().set(0, newValue);
// then :
final List<ServerPresentationModel> changes = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE);
assertThat(changes, hasSize(1));
final PresentationModel change = changes.get(0);
assertThat(change.getAttribute("source").getValue(), allOf(instanceOf(String.class), is((Object) sourceModel.getId())));
assertThat(change.getAttribute("attribute").getValue(), allOf(instanceOf(String.class), is((Object) "primitiveList")));
assertThat(change.getAttribute("from").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) newValue)));
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestObservableListSync method addingSingleElementInMiddleFromDolphin_shouldAddElement.
@Test
public void addingSingleElementInMiddleFromDolphin_shouldAddElement() {
// given :
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final String newElement = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 1).withAttribute("to", 1).withAttribute("count", 1).withAttribute("0", newElement).create();
// then :
assertThat(model.getPrimitiveList(), is(Arrays.asList("1", newElement, "2", "3")));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Aggregations