use of com.canoo.dp.impl.remoting.BeanRepository 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);
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelDeletion method testWithWrongModelType.
@Test(expectedExceptions = BeanDefinitionException.class)
public void testWithWrongModelType() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
beanRepository.delete("I'm a String");
}
use of com.canoo.dp.impl.remoting.BeanRepository 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));
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelCreation method testWithAllPrimitiveDatatypes.
@Test
public void testWithAllPrimitiveDatatypes(@Mocked AbstractClientConnector connector) {
final ClientModelStore clientModelStore = createClientModelStore(connector);
final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher);
PrimitiveDataTypesModel model = manager.create(PrimitiveDataTypesModel.class);
assertThat(model, notNullValue());
assertThat(model.getTextProperty(), notNullValue());
assertThat(model.getTextProperty().get(), nullValue());
assertThat(repository.isManaged(model), is(true));
List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(PrimitiveDataTypesModel.class.getName());
assertThat(dolphinModels, hasSize(1));
PresentationModel dolphinModel = dolphinModels.get(0);
List<Attribute> attributes = dolphinModel.getAttributes();
assertThat(attributes, hasSize(9));
for (Attribute attribute : attributes) {
if (RemotingConstants.SOURCE_SYSTEM.equals(attribute.getPropertyName())) {
assertThat(attribute.getValue(), Matchers.<Object>is(RemotingConstants.SOURCE_SYSTEM_CLIENT));
} else {
assertThat(attribute.getValue(), nullValue());
}
assertThat(attribute.getQualifier(), nullValue());
}
final List<ClientPresentationModel> classModels = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
assertThat(classModels, hasSize(1));
final PresentationModel classModel = classModels.get(0);
final List<Attribute> classAttributes = classModel.getAttributes();
assertThat(classAttributes, hasSize(10));
for (Attribute attribute : classAttributes) {
if (PlatformRemotingConstants.JAVA_CLASS.equals(attribute.getPropertyName())) {
assertThat(attribute.getValue().toString(), is(PrimitiveDataTypesModel.class.getName()));
} else if (RemotingConstants.SOURCE_SYSTEM.equals(attribute.getPropertyName())) {
assertThat(attribute.getValue(), Matchers.<Object>is(RemotingConstants.SOURCE_SYSTEM_CLIENT));
} else {
switch(attribute.getPropertyName()) {
case "byteProperty":
assertThat((Integer) attribute.getValue(), is(ByteConverterFactory.FIELD_TYPE_BYTE));
break;
case "shortProperty":
assertThat((Integer) attribute.getValue(), is(ShortConverterFactory.FIELD_TYPE_SHORT));
break;
case "integerProperty":
assertThat((Integer) attribute.getValue(), is(IntegerConverterFactory.FIELD_TYPE_INT));
break;
case "longProperty":
assertThat((Integer) attribute.getValue(), is(LongConverterFactory.FIELD_TYPE_LONG));
break;
case "floatProperty":
assertThat((Integer) attribute.getValue(), is(FloatConverterFactory.FIELD_TYPE_FLOAT));
break;
case "doubleProperty":
assertThat((Integer) attribute.getValue(), is(DoubleConverterFactory.FIELD_TYPE_DOUBLE));
break;
case "booleanProperty":
assertThat((Integer) attribute.getValue(), is(BooleanConverterFactory.FIELD_TYPE_BOOLEAN));
break;
case "textProperty":
assertThat((Integer) attribute.getValue(), is(StringConverterFactory.FIELD_TYPE_STRING));
break;
default:
fail("Unknown attribute found: " + attribute);
break;
}
}
assertThat(attribute.getQualifier(), nullValue());
}
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelCreation method testWithSingleReferenceModel.
@Test
public void testWithSingleReferenceModel(@Mocked AbstractClientConnector connector) {
final ClientModelStore clientModelStore = createClientModelStore(connector);
final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher);
SingleReferenceModel model = manager.create(SingleReferenceModel.class);
assertThat(model, notNullValue());
assertThat(model.getReferenceProperty(), notNullValue());
assertThat(model.getReferenceProperty().get(), nullValue());
assertThat(repository.isManaged(model), is(true));
List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName());
assertThat(dolphinModels, hasSize(1));
PresentationModel dolphinModel = dolphinModels.get(0);
List<Attribute> 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_CLIENT)), hasProperty("qualifier", nullValue()))));
List<ClientPresentationModel> classModels = clientModelStore.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_CLIENT)), hasProperty("qualifier", nullValue()))))));
}
Aggregations