Search in sources :

Example 91 with ResourceInformation

use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.

the class DefaultResourceInformationProviderTest method shouldIgnoreCustomGetNamedMethods.

@Test
public void shouldIgnoreCustomGetNamedMethods() {
    ResourceInformation resourceInformation = resourceInformationProvider.build(JsonApiRelationTypeCustomGetMethod.class);
    assertNull(resourceInformation.getRelationshipFields().get(0).getIdType());
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 92 with ResourceInformation

use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.

the class DefaultResourceInformationProviderTest method shouldOverrideGlobalLookupBehavior.

@Test
public void shouldOverrideGlobalLookupBehavior() throws Exception {
    ResourceInformationProvider resourceInformationProviderWithProperty = getResourceInformationProviderWithProperty(CrnkProperties.INCLUDE_AUTOMATICALLY_OVERWRITE, "true");
    ResourceInformation resourceInformation = resourceInformationProviderWithProperty.build(JsonResourceWithOverrideLookupBehaviorRelationship.class);
    // Global says automatically always, but relationship says only when null.
    // Relationship annotation should win in this case.
    assertThat(resourceInformation.getRelationshipFields()).extracting("lookupIncludeBehavior").contains(LookupIncludeBehavior.AUTOMATICALLY_WHEN_NULL);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) ResourceInformationProvider(io.crnk.core.engine.information.resource.ResourceInformationProvider) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) Test(org.junit.Test)

Example 93 with ResourceInformation

use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.

the class DefaultResourceInformationProviderTest method shouldHaveIdFieldInfoForValidResource.

@Test
public void shouldHaveIdFieldInfoForValidResource() throws Exception {
    ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
    assertThat(resourceInformation.getIdField().getUnderlyingName()).isNotNull().isEqualTo("id");
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 94 with ResourceInformation

use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.

the class DefaultResourceInformationProviderTest method shouldRecognizeJsonAPIRelationTypeWithDefaults.

@Test
public void shouldRecognizeJsonAPIRelationTypeWithDefaults() throws Exception {
    ResourceInformation resourceInformation = resourceInformationProvider.build(JsonApiRelationType.class);
    assertThat(resourceInformation.getRelationshipFields()).isNotEmpty().hasSize(2).extracting("type").contains(Future.class).contains(Collection.class);
    assertThat(resourceInformation.getRelationshipFields()).extracting("serializeType").contains(SerializeType.LAZY, SerializeType.LAZY);
    assertThat(resourceInformation.getRelationshipFields()).extracting("lookupIncludeBehavior").contains(LookupIncludeBehavior.NONE, LookupIncludeBehavior.NONE);
    assertThat(resourceInformation.getRelationshipFields()).extracting("resourceFieldType").contains(ResourceFieldType.RELATIONSHIP, ResourceFieldType.RELATIONSHIP);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Future(java.util.concurrent.Future) Test(org.junit.Test)

Example 95 with ResourceInformation

use of io.crnk.core.engine.information.resource.ResourceInformation in project crnk-framework by crnk-project.

the class DefaultResourceInformationProviderTest method shouldThrowExceptionOnMultipleMetaInformationFields.

@Test
public void shouldThrowExceptionOnMultipleMetaInformationFields() throws Exception {
    ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
    assertThat(resourceInformation.getMetaField().getUnderlyingName()).isEqualTo("metaInformation");
}
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