Search in sources :

Example 61 with ResourceInformation

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);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 62 with ResourceInformation

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());
}
Also used : ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 63 with ResourceInformation

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());
}
Also used : ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 64 with ResourceInformation

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());
}
Also used : ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 65 with ResourceInformation

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();
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Aggregations

ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)167 Test (org.junit.Test)79 ResourceField (io.crnk.core.engine.information.resource.ResourceField)76 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)60 QuerySpec (io.crnk.core.queryspec.QuerySpec)16 Resource (io.crnk.core.engine.document.Resource)15 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)15 QueryAdapter (io.crnk.core.engine.query.QueryAdapter)9 Task (io.crnk.core.mock.models.Task)9 JsonApiResponse (io.crnk.core.repository.response.JsonApiResponse)9 HashSet (java.util.HashSet)9 Collection (java.util.Collection)8 Relationship (io.crnk.core.engine.document.Relationship)7 HttpMethod (io.crnk.core.engine.http.HttpMethod)7 ResourceRepositoryAdapter (io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter)7 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)7 OffsetLimitPagingBehavior (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior)7 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)7 Set (java.util.Set)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6