use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method shouldHaveResourceClassInfoForValidResource.
@Test
public void shouldHaveResourceClassInfoForValidResource() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
assertThat(resourceInformation.getResourceClass()).isNotNull().isEqualTo(Task.class);
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method shouldHaveProperTypeWhenFieldAndGetterTypesDifferV2.
@Test
public void shouldHaveProperTypeWhenFieldAndGetterTypesDifferV2() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(DifferentTypes.class);
assertThat(resourceInformation.getRelationshipFields()).isNotNull().hasSize(1).extracting("type").contains(String.class);
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method shouldDiscardParametrizedTypeWithJsonIgnore.
@Test
public void shouldDiscardParametrizedTypeWithJsonIgnore() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(ShapeResource.class);
// if we get this far, that is good, it means parsing the class didn't trigger the
// IllegalStateException when calling ClassUtils#getRawType on a parameterized type T
assertThat(resourceInformation.findAttributeFieldByName("type")).isNotNull();
// This assert fails, because JsonIgnore is on the getter not the field itself
// assertThat(resourceInformation.findAttributeFieldByName("delegate")).isNull();
assertThat(resourceInformation.getIdField().getUnderlyingName()).isNotNull().isEqualTo("id");
assertThat(containsFieldWithName(resourceInformation, "delegate")).isFalse();
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method checkJsonApiAttributeAnnotation.
@Test
public void checkJsonApiAttributeAnnotation() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
ResourceField field = resourceInformation.findAttributeFieldByName("status");
Assert.assertFalse(field.getAccess().isPatchable());
Assert.assertFalse(field.getAccess().isPostable());
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method checkJsonApiAttributeAnnotationDefaultsForIds.
@Test
public void checkJsonApiAttributeAnnotationDefaultsForIds() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
ResourceField field = resourceInformation.getIdField();
Assert.assertFalse(field.getAccess().isPatchable());
Assert.assertTrue(field.getAccess().isPostable());
Assert.assertTrue(field.getAccess().isReadable());
}
Aggregations