Search in sources :

Example 26 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestModelCreation method testWithComplexDataTypesModel.

@Test
public void testWithComplexDataTypesModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
    ComplexDataTypesModel model = manager.create(ComplexDataTypesModel.class);
    assertThat(model, notNullValue());
    assertThat(model.getDateProperty(), notNullValue());
    assertThat(model.getDateProperty().get(), nullValue());
    assertThat(model.getCalendarProperty(), notNullValue());
    assertThat(model.getCalendarProperty().get(), nullValue());
    assertThat(model.getEnumProperty(), notNullValue());
    assertThat(model.getEnumProperty().get(), nullValue());
    assertThat(beanRepository.isManaged(model), is(true));
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(ComplexDataTypesModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    PresentationModel dolphinModel = dolphinModels.get(0);
    List<Attribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_SERVER)), hasProperty("qualifier", nullValue()))));
    List<ServerPresentationModel> classModels = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
    assertThat(classModels, contains(hasProperty("attributes", containsInAnyOrder(allOf(hasProperty("propertyName", is(PlatformRemotingConstants.JAVA_CLASS)), hasProperty("value", is(ComplexDataTypesModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", is(DateConverterFactory.FIELD_TYPE_DATE)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", is(CalendarConverterFactory.FIELD_TYPE_CALENDAR)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), hasProperty("value", is(EnumConverterFactory.FIELD_TYPE_ENUM)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_SERVER)), hasProperty("qualifier", nullValue()))))));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ComplexDataTypesModel(com.canoo.impl.server.util.ComplexDataTypesModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 27 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestModelCreation method testWithWrongModelType.

@Test(expectedExceptions = BeanDefinitionException.class)
public void testWithWrongModelType() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    String model = manager.create(String.class);
}
Also used : ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 28 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestModelDeletion method testWithSingleReferenceModel.

@Test
public void testWithSingleReferenceModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
    SingleReferenceModel model = manager.create(SingleReferenceModel.class);
    beanRepository.delete(model);
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName());
    assertThat(dolphinModels, empty());
    Collection<ServerPresentationModel> allDolphinModels = serverModelStore.listPresentationModels();
    assertThat(allDolphinModels, hasSize(1));
    assertThat(beanRepository.isManaged(model), is(false));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) SingleReferenceModel(com.canoo.impl.server.util.SingleReferenceModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 29 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestModelDeletion method testWithInheritedModel.

@Test
public void testWithInheritedModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
    ChildModel model = manager.create(ChildModel.class);
    beanRepository.delete(model);
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
    assertThat(dolphinModels, empty());
    Collection<ServerPresentationModel> allDolphinModels = serverModelStore.listPresentationModels();
    assertThat(allDolphinModels, hasSize(1));
    assertThat(beanRepository.isManaged(model), is(false));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ChildModel(com.canoo.impl.server.util.ChildModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 30 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestModelDeletion method testWithNull.

@Test(expectedExceptions = NullPointerException.class)
public void testWithNull() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
    beanRepository.delete(null);
}
Also used : EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) 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