use of io.crnk.meta.model.MetaDataObject in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testReadOnlyField.
@Test
public void testReadOnlyField() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
ResourceInformation info = builder.build(AnnotationTestEntity.class);
ResourceField field = info.findAttributeFieldByName("readOnlyValue");
Assert.assertFalse(field.getAccess().isPostable());
Assert.assertFalse(field.getAccess().isPatchable());
MetaDataObject meta = jpaMetaProvider.discoverMeta(AnnotationTestEntity.class).asDataObject();
MetaAttribute attribute = meta.getAttribute("readOnlyValue");
Assert.assertFalse(attribute.isInsertable());
Assert.assertFalse(attribute.isUpdatable());
}
use of io.crnk.meta.model.MetaDataObject in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testAttributeAnnotations.
@Test
public void testAttributeAnnotations() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
ResourceInformation info = builder.build(AnnotationTestEntity.class);
ResourceField lobField = info.findAttributeFieldByName("lobValue");
ResourceField fieldAnnotatedField = info.findAttributeFieldByName("fieldAnnotatedValue");
ResourceField columnAnnotatedField = info.findAttributeFieldByName("columnAnnotatedValue");
Assert.assertFalse(lobField.getAccess().isSortable());
Assert.assertFalse(lobField.getAccess().isFilterable());
Assert.assertTrue(lobField.getAccess().isPostable());
Assert.assertTrue(lobField.getAccess().isPatchable());
Assert.assertFalse(fieldAnnotatedField.getAccess().isSortable());
Assert.assertFalse(fieldAnnotatedField.getAccess().isFilterable());
Assert.assertTrue(fieldAnnotatedField.getAccess().isPostable());
Assert.assertFalse(fieldAnnotatedField.getAccess().isPatchable());
Assert.assertTrue(columnAnnotatedField.getAccess().isSortable());
Assert.assertTrue(columnAnnotatedField.getAccess().isFilterable());
Assert.assertFalse(columnAnnotatedField.getAccess().isPostable());
Assert.assertTrue(columnAnnotatedField.getAccess().isPatchable());
MetaDataObject meta = jpaMetaProvider.discoverMeta(AnnotationTestEntity.class).asDataObject();
Assert.assertTrue(meta.getAttribute("lobValue").isLob());
Assert.assertFalse(meta.getAttribute("fieldAnnotatedValue").isLob());
}
use of io.crnk.meta.model.MetaDataObject in project crnk-framework by crnk-project.
the class QueryFilterBuilder method filterSimpleOperation.
private P filterSimpleOperation(FilterSpec fs, MetaDataObject rootMeta) {
Object value = fs.getValue();
if (value instanceof Set) {
// HashSet not properly supported in ORM/JDBC, convert to
// list
Set<?> set = (Set<?>) value;
value = new ArrayList<Object>(set);
}
MetaAttributePath path = rootMeta.resolvePath(fs.getAttributePath(), attributeFinder);
path = enhanceAttributePath(path, value);
return backend.buildPredicate(fs.getOperator(), path, value);
}
use of io.crnk.meta.model.MetaDataObject in project crnk-framework by crnk-project.
the class MetaEntityTest method testGeneratedPrimaryKey.
@Test
public void testGeneratedPrimaryKey() {
MetaDataObject meta = metaProvider.discoverMeta(SequenceEntity.class).asDataObject();
MetaPrimaryKey primaryKey = meta.getPrimaryKey();
Assert.assertNotNull(primaryKey);
Assert.assertEquals(1, primaryKey.getElements().size());
Assert.assertEquals("id", primaryKey.getElements().get(0).getName());
Assert.assertTrue(primaryKey.isGenerated());
}
use of io.crnk.meta.model.MetaDataObject in project crnk-framework by crnk-project.
the class MetaLookupTest method testObjectArrayMeta.
@Test
public void testObjectArrayMeta() {
MetaArrayType meta = metaProvider.discoverMeta(TestEntity[].class);
MetaType elementType = meta.getElementType();
Assert.assertTrue(elementType instanceof MetaDataObject);
}
Aggregations