Search in sources :

Example 1 with ServerAttribute

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

the class TestModelCreation 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);
    assertThat(model, notNullValue());
    assertThat(model.getReferenceProperty(), notNullValue());
    assertThat(model.getReferenceProperty().get(), nullValue());
    assertThat(beanRepository.isManaged(model), is(true));
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    ServerPresentationModel dolphinModel = dolphinModels.get(0);
    List<ServerAttribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("referenceProperty")), 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(SingleReferenceModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("referenceProperty")), hasProperty("value", is(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN)), 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) 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) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 2 with ServerAttribute

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

the class TestModelCreation 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);
    assertThat(model, notNullValue());
    assertThat(model.getParentProperty(), notNullValue());
    assertThat(model.getParentProperty().get(), nullValue());
    assertThat(model.getChildProperty(), notNullValue());
    assertThat(model.getChildProperty().get(), nullValue());
    assertThat(beanRepository.isManaged(model), is(true));
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    ServerPresentationModel dolphinModel = dolphinModels.get(0);
    List<ServerAttribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("childProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("parentProperty")), 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, hasSize(1));
    assertThat(classModels, contains(hasProperty("attributes", containsInAnyOrder(allOf(hasProperty("propertyName", is(PlatformRemotingConstants.JAVA_CLASS)), hasProperty("value", is(ChildModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("childProperty")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("parentProperty")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), 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) 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) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 3 with ServerAttribute

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

the class DolphinServerActionTests method testChangeValue.

public void testChangeValue() {
    action.changeValue(new ServerAttribute("attr", "initial"), "newValue");
    Assert.assertEquals(1, action.getDolphinResponse().size());
    Assert.assertEquals(ValueChangedCommand.class, action.getDolphinResponse().get(0).getClass());
}
Also used : ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute)

Example 4 with ServerAttribute

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

the class StoreAttributeActionTests method testChangeAttributeMetadata.

@Test
public void testChangeAttributeMetadata() {
    StoreAttributeAction action = new StoreAttributeAction();
    action.setServerModelStore(serverModelStore);
    action.registerIn(registry);
    ServerAttribute attribute = new ServerAttribute("newAttribute", "");
    serverModelStore.add(new ServerPresentationModel("model", Collections.singletonList(attribute), serverModelStore));
    registry.getActionsFor(ChangeAttributeMetadataCommand.class).get(0).handleCommand(new ChangeAttributeMetadataCommand(attribute.getId(), "value", "newValue"), Collections.emptyList());
    Assert.assertEquals("newValue", attribute.getValue());
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ChangeAttributeMetadataCommand(com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Test(org.testng.annotations.Test)

Example 5 with ServerAttribute

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

the class CreatePresentationModelAction method createPresentationModel.

private static void createPresentationModel(final CreatePresentationModelCommand command, final ServerModelStore serverModelStore) {
    if (serverModelStore.findPresentationModelById(command.getPmId()) != null) {
        LOG.trace("Ignoring create PM '{}' since it is already in the model store.", command.getPmId());
        return;
    }
    if (command.getPmId().endsWith(RemotingConstants.SERVER_PM_AUTO_ID_SUFFIX)) {
        LOG.trace("Creating the PM '{}' with reserved server-auto-suffix.", command.getPmId());
    }
    List<ServerAttribute> attributes = new LinkedList();
    for (Map<String, Object> attr : command.getAttributes()) {
        ServerAttribute attribute = new ServerAttribute((String) attr.get("propertyName"), attr.get("value"), (String) attr.get("qualifier"));
        attribute.setId((String) attr.get("id"));
        attributes.add(attribute);
    }
    ServerPresentationModel model = new ServerPresentationModel(command.getPmId(), attributes, serverModelStore);
    model.setPresentationModelType(command.getPmType());
    serverModelStore.checkClientAdded(model);
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) LinkedList(java.util.LinkedList)

Aggregations

ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)10 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)8 Test (org.testng.annotations.Test)7 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)6 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)6 BeanManager (com.canoo.platform.remoting.BeanManager)6 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)5 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)5 BindingException (com.canoo.dp.impl.remoting.BindingException)1 PropertyImpl (com.canoo.dp.impl.remoting.PropertyImpl)1 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)1 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)1 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)1 ChildModel (com.canoo.impl.server.util.ChildModel)1 ListReferenceModel (com.canoo.impl.server.util.ListReferenceModel)1 PrimitiveDataTypesModel (com.canoo.impl.server.util.PrimitiveDataTypesModel)1 SimpleAnnotatedTestModel (com.canoo.impl.server.util.SimpleAnnotatedTestModel)1 SimpleTestModel (com.canoo.impl.server.util.SimpleTestModel)1 SingleReferenceModel (com.canoo.impl.server.util.SingleReferenceModel)1 Binding (com.canoo.platform.core.functional.Binding)1