use of io.crnk.core.engine.information.resource.ResourceField in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testLongAttributeAccess.
@Test
public void testLongAttributeAccess() {
ResourceInformation info = builder.build(VersionedEntity.class);
ResourceField field = info.findAttributeFieldByName("longValue");
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 testStringAttributeAccess.
@Test
public void testStringAttributeAccess() {
ResourceInformation info = builder.build(TestEntity.class);
ResourceField field = info.findAttributeFieldByName("stringValue");
Assert.assertTrue(field.getAccess().isPostable());
Assert.assertTrue(field.getAccess().isPatchable());
Assert.assertTrue(field.getAccess().isSortable());
Assert.assertTrue(field.getAccess().isFilterable());
}
use of io.crnk.core.engine.information.resource.ResourceField in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testPrimitiveTypesProperlyRecognized.
@Test
public void testPrimitiveTypesProperlyRecognized() {
ResourceInformation info = builder.build(TestEntity.class);
ResourceField field = info.findAttributeFieldByName("longValue");
Assert.assertNotNull(field);
Assert.assertEquals(long.class, field.getType());
Assert.assertEquals(long.class, field.getGenericType());
}
use of io.crnk.core.engine.information.resource.ResourceField in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method testManyToOneRelation.
@Test
public void testManyToOneRelation() {
ResourceInformation info = builder.build(TestEntity.class);
ResourceField field = info.findRelationshipFieldByName("oneRelatedValue");
Assert.assertEquals(ResourceFieldType.RELATIONSHIP, field.getResourceFieldType());
Assert.assertEquals("related", field.getOppositeResourceType());
Assert.assertEquals(SerializeType.LAZY, field.getSerializeType());
Assert.assertNull(field.getOppositeName());
}
use of io.crnk.core.engine.information.resource.ResourceField in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method test.
@Test
public void test() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
ResourceInformation info = builder.build(TestEntity.class);
ResourceField idField = info.getIdField();
assertNotNull(idField);
assertEquals("id", idField.getJsonName());
assertEquals("id", idField.getUnderlyingName());
assertEquals(Long.class, idField.getType());
assertEquals(Long.class, idField.getGenericType());
List<ResourceField> attrFields = new ArrayList<>(info.getAttributeFields());
Collections.sort(attrFields, ResourceFieldComparator.INSTANCE);
assertEquals(5, attrFields.size());
ResourceField embField = attrFields.get(1);
assertEquals(TestEntity.ATTR_embValue, embField.getJsonName());
assertEquals(TestEntity.ATTR_embValue, embField.getUnderlyingName());
assertEquals(TestEmbeddable.class, embField.getType());
assertEquals(TestEmbeddable.class, embField.getGenericType());
Assert.assertTrue(embField.getAccess().isPostable());
Assert.assertTrue(embField.getAccess().isPatchable());
Assert.assertTrue(embField.getAccess().isSortable());
Assert.assertTrue(embField.getAccess().isFilterable());
ArrayList<ResourceField> relFields = new ArrayList<ResourceField>(info.getRelationshipFields());
Collections.sort(relFields, ResourceFieldComparator.INSTANCE);
assertEquals(4, relFields.size());
boolean found = false;
for (ResourceField relField : relFields) {
if (relField.getUnderlyingName().equals(TestEntity.ATTR_oneRelatedValue)) {
assertEquals(TestEntity.ATTR_oneRelatedValue, relField.getJsonName());
assertEquals(RelatedEntity.class, relField.getType());
assertEquals(RelatedEntity.class, relField.getGenericType());
found = true;
}
}
Assert.assertTrue(found);
}
Aggregations