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()))))));
}
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()))))));
}
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());
}
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());
}
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);
}
Aggregations