Search in sources :

Example 56 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method shouldInheritGlobalForDefaultLookupBehaviorWhenDefault.

@Test
public void shouldInheritGlobalForDefaultLookupBehaviorWhenDefault() throws Exception {
    ResourceInformationProvider resourceInformationProviderWithProperty = getResourceInformationProviderWithProperty(CrnkProperties.INCLUDE_AUTOMATICALLY_OVERWRITE, "true");
    ResourceInformation resourceInformation = resourceInformationProviderWithProperty.build(JsonResourceWithDefaultLookupBehaviorRelationship.class);
    assertThat(resourceInformation.getRelationshipFields()).extracting("lookupIncludeBehavior").contains(LookupIncludeBehavior.AUTOMATICALLY_ALWAYS);
}
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 57 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method shouldHaveGetterBooleanWithIsPrefix.

@Test
public void shouldHaveGetterBooleanWithIsPrefix() throws Exception {
    ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
    assertThat(containsFieldWithName(resourceInformation, "completed")).isTrue();
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 58 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method shouldReturnIdFieldBasedOnFieldGetter.

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

Example 59 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method shouldHaveProperTypeWhenFieldAndGetterTypesDiffer.

@Test
public void shouldHaveProperTypeWhenFieldAndGetterTypesDiffer() 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 60 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method shouldRecognizeJsonAPIRelationTypeWithNonDefaults.

@Test
public void shouldRecognizeJsonAPIRelationTypeWithNonDefaults() throws Exception {
    ResourceInformation resourceInformation = resourceInformationProvider.build(JsonApiRelationTypeNonDefaults.class);
    assertThat(resourceInformation.getRelationshipFields()).isNotEmpty().hasSize(2).extracting("type").contains(Future.class).contains(Collection.class);
    assertThat(resourceInformation.getRelationshipFields()).extracting("serializeType").contains(SerializeType.ONLY_ID, SerializeType.EAGER);
    assertThat(resourceInformation.getRelationshipFields()).extracting("lookupIncludeBehavior").contains(LookupIncludeBehavior.AUTOMATICALLY_ALWAYS, LookupIncludeBehavior.AUTOMATICALLY_WHEN_NULL);
    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)

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