Search in sources :

Example 96 with BeanManager

use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.

the class TestObservableListSync method replaceObjectNullWithElementAsUser_shouldReplaceElement.

@Test
public void replaceObjectNullWithElementAsUser_shouldReplaceElement(@Mocked AbstractClientConnector connector) {
    // given :
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    final SimpleTestModel newObject = manager.create(SimpleTestModel.class);
    final PresentationModel newObjectModel = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    model.getObjectList().add(null);
    deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getObjectList().set(0, newObject);
    // then :
    final List<ClientPresentationModel> changes = clientModelStore.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) "objectList")));
    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) newObjectModel.getId())));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ListReferenceModel(com.canoo.dolphin.client.util.ListReferenceModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Example 97 with BeanManager

use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.

the class TestObservableListSync method replaceObjectElementAsUser_shouldReplaceElement.

@Test
public void replaceObjectElementAsUser_shouldReplaceElement(@Mocked AbstractClientConnector connector) {
    // given :
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    final SimpleTestModel newObject = manager.create(SimpleTestModel.class);
    final PresentationModel newObjectModel = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    final SimpleTestModel oldObject = manager.create(SimpleTestModel.class);
    model.getObjectList().add(oldObject);
    deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getObjectList().set(0, newObject);
    // then :
    final List<ClientPresentationModel> changes = clientModelStore.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) "objectList")));
    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) newObjectModel.getId())));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ListReferenceModel(com.canoo.dolphin.client.util.ListReferenceModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Example 98 with BeanManager

use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.

the class TestObservableListSync method deletingSingleElementInBeginningFromDolphin_shouldRemoveElement.

// ////////////////////////////////////////////////////////////
// Removing elements from different positions from dolphin
// ////////////////////////////////////////////////////////////
@Test
public void deletingSingleElementInBeginningFromDolphin_shouldRemoveElement(@Mocked AbstractClientConnector connector) {
    // given :
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 0).withAttribute("to", 1).withAttribute("count", 0).create();
    // then :
    assertThat(model.getPrimitiveList(), is(Arrays.asList("2", "3")));
    assertThat(clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ListReferenceModel(com.canoo.dolphin.client.util.ListReferenceModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Example 99 with BeanManager

use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.

the class TestObservableListSync method deletingSingleElementAtEndAsUser_shouldDeleteElement.

@Test
public void deletingSingleElementAtEndAsUser_shouldDeleteElement(@Mocked AbstractClientConnector connector) {
    // given :
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().remove(2);
    // then :
    final List<ClientPresentationModel> changes = clientModelStore.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) 2)));
    assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 3)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ListReferenceModel(com.canoo.dolphin.client.util.ListReferenceModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Example 100 with BeanManager

use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.

the class TestObservableListSync method addingObjectElementFromDolphin_shouldAddElement.

// /////////////////////////////////////////////////////////////////
// Adding, removing, and replacing all element types from dolphin
// /////////////////////////////////////////////////////////////////
@Test
public void addingObjectElementFromDolphin_shouldAddElement(@Mocked AbstractClientConnector connector) {
    // given :
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    final PresentationModel classDescription = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN).get(0);
    classDescription.getAttribute("objectList").setValue(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN);
    final SimpleTestModel object = manager.create(SimpleTestModel.class);
    final PresentationModel objectModel = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    // when :
    new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", objectModel.getId()).create();
    // then :
    assertThat(model.getObjectList(), is(Collections.singletonList(object)));
    assertThat(clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) ListReferenceModel(com.canoo.dolphin.client.util.ListReferenceModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Aggregations

BeanManager (com.canoo.platform.remoting.BeanManager)182 Test (org.testng.annotations.Test)182 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)142 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)91 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)91 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)91 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)91 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)82 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)82 ListReferenceModel (com.canoo.dolphin.client.util.ListReferenceModel)65 ListReferenceModel (com.canoo.impl.server.util.ListReferenceModel)65 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)39 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)39 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)21 SimpleTestModel (com.canoo.impl.server.util.SimpleTestModel)18 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)17 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)8 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)8 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)7 Subscription (com.canoo.platform.core.functional.Subscription)6