Search in sources :

Example 96 with ResourceInformation

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

Example 97 with ResourceInformation

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

Example 98 with ResourceInformation

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

Example 99 with ResourceInformation

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

Example 100 with ResourceInformation

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