use of io.crnk.core.engine.information.resource.ResourceField in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testManyToManyOppositeRelation.
@Test
public void testManyToManyOppositeRelation() {
ResourceInformation info = builder.build(ManyToManyOppositeEntity.class);
ResourceField field = info.findRelationshipFieldByName("tests");
Assert.assertEquals(ResourceFieldType.RELATIONSHIP, field.getResourceFieldType());
Assert.assertEquals("manyToManyTest", field.getOppositeResourceType());
Assert.assertEquals(SerializeType.LAZY, field.getSerializeType());
Assert.assertEquals("opposites", field.getOppositeName());
}
use of io.crnk.core.engine.information.resource.ResourceField 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.core.engine.information.resource.ResourceField in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testOneToManyRelation.
@Test
public void testOneToManyRelation() {
ResourceInformation info = builder.build(TestEntity.class);
ResourceField field = info.findRelationshipFieldByName("manyRelatedValues");
Assert.assertEquals(ResourceFieldType.RELATIONSHIP, field.getResourceFieldType());
Assert.assertEquals("related", field.getOppositeResourceType());
Assert.assertEquals(SerializeType.LAZY, field.getSerializeType());
Assert.assertEquals("testEntity", field.getOppositeName());
}
use of io.crnk.core.engine.information.resource.ResourceField in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testVersionAccess.
@Test
public void testVersionAccess() {
ResourceInformation info = builder.build(VersionedEntity.class);
ResourceField field = info.findAttributeFieldByName("version");
// must not be immutable to support optimistic locking
Assert.assertTrue(field.getAccess().isPostable());
Assert.assertTrue(field.getAccess().isPatchable());
}
use of io.crnk.core.engine.information.resource.ResourceField 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());
}
Aggregations