Search in sources :

Example 56 with ServerModelStore

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));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) SimpleAnnotatedTestModel(com.canoo.impl.server.util.SimpleAnnotatedTestModel) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) SimpleTestModel(com.canoo.impl.server.util.SimpleTestModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 57 with ServerModelStore

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);
}
Also used : ServerConnector(com.canoo.dp.impl.server.legacy.ServerConnector) PresentationModelDeletedCommand(com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand) DefaultServerDolphin(com.canoo.dp.impl.server.legacy.DefaultServerDolphin) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ChangeAttributeMetadataCommand(com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) ValueChangedCommand(com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand) Test(org.testng.annotations.Test)

Example 58 with ServerModelStore

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());
}
Also used : Command(com.canoo.dp.impl.remoting.legacy.communication.Command) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore)

Example 59 with ServerModelStore

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)));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ListReferenceModel(com.canoo.impl.server.util.ListReferenceModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 60 with ServerModelStore

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());
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ListReferenceModel(com.canoo.impl.server.util.ListReferenceModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Aggregations

ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)103 Test (org.testng.annotations.Test)100 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)97 BeanManager (com.canoo.platform.remoting.BeanManager)91 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)88 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)66 ListReferenceModel (com.canoo.impl.server.util.ListReferenceModel)65 SimpleTestModel (com.canoo.impl.server.util.SimpleTestModel)18 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)14 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)14 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)8 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)7 ServerPresentationModelBuilder (com.canoo.dp.impl.server.model.ServerPresentationModelBuilder)5 SimpleAnnotatedTestModel (com.canoo.impl.server.util.SimpleAnnotatedTestModel)5 Command (com.canoo.dp.impl.remoting.legacy.communication.Command)4 ChildModel (com.canoo.impl.server.util.ChildModel)4 SingleReferenceModel (com.canoo.impl.server.util.SingleReferenceModel)4 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)4 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)4 Subscription (com.canoo.platform.core.functional.Subscription)3