use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method shouldReturnMergedAnnotationsOnAnnotationsOnFieldAndMethod.
@Test
public void shouldReturnMergedAnnotationsOnAnnotationsOnFieldAndMethod() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(AnnotationOnFieldAndMethodResource.class);
assertThat(resourceInformation.getRelationshipFields()).isNotNull().hasSize(0);
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method checkJsonPropertyAccessPolicy.
@Test
public void checkJsonPropertyAccessPolicy() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(JsonIgnoreTestResource.class);
ResourceField defaultAttribute = resourceInformation.findAttributeFieldByName("defaultAttribute");
ResourceField readOnlyAttribute = resourceInformation.findAttributeFieldByName("readOnlyAttribute");
ResourceField readWriteAttribute = resourceInformation.findAttributeFieldByName("readWriteAttribute");
ResourceField writeOnlyAttribute = resourceInformation.findAttributeFieldByName("writeOnlyAttribute");
Assert.assertTrue(defaultAttribute.getAccess().isPatchable());
Assert.assertTrue(defaultAttribute.getAccess().isPostable());
Assert.assertFalse(readOnlyAttribute.getAccess().isPatchable());
Assert.assertFalse(readOnlyAttribute.getAccess().isPostable());
Assert.assertTrue(readOnlyAttribute.getAccess().isReadable());
Assert.assertTrue(readWriteAttribute.getAccess().isPatchable());
Assert.assertTrue(readWriteAttribute.getAccess().isPostable());
Assert.assertTrue(readWriteAttribute.getAccess().isReadable());
Assert.assertTrue(writeOnlyAttribute.getAccess().isPatchable());
Assert.assertTrue(writeOnlyAttribute.getAccess().isPostable());
Assert.assertFalse(writeOnlyAttribute.getAccess().isReadable());
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method shouldBeReadableAndPostableAndPatchableWithSetter.
@Test
public void shouldBeReadableAndPostableAndPatchableWithSetter() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
ResourceField field = resourceInformation.findAttributeFieldByName("name");
Assert.assertTrue(field.getAccess().isReadable());
Assert.assertTrue(field.getAccess().isPostable());
Assert.assertTrue(field.getAccess().isPatchable());
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method shouldBeReadableButNotPostableOrPatchableWithoutSetter.
@Test
public void shouldBeReadableButNotPostableOrPatchableWithoutSetter() throws Exception {
ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
ResourceField field = resourceInformation.findAttributeFieldByName("readOnlyValue");
Assert.assertTrue(field.getAccess().isReadable());
Assert.assertFalse(field.getAccess().isPostable());
Assert.assertFalse(field.getAccess().isPatchable());
}
use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.
the class DefaultResourceInformationProviderTest method shouldNotHaveIgnoredField.
@Test
public void shouldNotHaveIgnoredField() throws Exception {
// GIVEN a field that has the JsonIgnore annotation, and a corresponding getter that does not
ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
// THEN we should not pick up the java bean property
assertThat(containsFieldWithName(resourceInformation, "ignoredField")).isFalse();
}
Aggregations