Search in sources :

Example 66 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method shouldContainMetaInformationField.

@Test
public void shouldContainMetaInformationField() 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)

Example 67 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method shouldIgnoreTransientAttributes.

@Test
public void shouldIgnoreTransientAttributes() throws Exception {
    ResourceInformation resourceInformation = resourceInformationProvider.build(IgnoredTransientAttributeResource.class);
    Assert.assertNull(resourceInformation.findFieldByName("attribute"));
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Test(org.junit.Test)

Example 68 with ResourceInformation

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

the class DefaultResourceInformationProviderTest method checkJsonApiAttributeAnnotationDefaults.

@Test
public void checkJsonApiAttributeAnnotationDefaults() throws Exception {
    ResourceInformation resourceInformation = resourceInformationProvider.build(Task.class);
    ResourceField field = resourceInformation.findAttributeFieldByName("name");
    Assert.assertTrue(field.getAccess().isPatchable());
    Assert.assertTrue(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 69 with ResourceInformation

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

the class ClientResourceUpsertTest method setLinks.

@Test
public void setLinks() throws IOException {
    Resource resource = new Resource();
    JsonNode links = boot.getObjectMapper().reader().readTree("{\"value\": \"linksValue\"}");
    resource.setLinks((ObjectNode) links);
    Task task = new Task();
    ResourceInformation resourceInformation = boot.getResourceRegistry().getEntry(Task.class).getResourceInformation();
    upsert.setLinks(resource, task, resourceInformation);
    Assert.assertEquals("linksValue", task.getLinksInformation().value);
}
Also used : Task(io.crnk.test.mock.models.Task) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Resource(io.crnk.core.engine.document.Resource) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 70 with ResourceInformation

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

the class BasicProxyFactory method createResourceProxy.

@Override
public <T> T createResourceProxy(Class<T> clazz, Object id) {
    T instance = ClassUtils.newInstance(clazz);
    ResourceRegistry resourceRegistry = context.getModuleRegistry().getResourceRegistry();
    RegistryEntry entry = resourceRegistry.findEntry(clazz);
    ResourceInformation resourceInformation = entry.getResourceInformation();
    resourceInformation.setId(instance, id);
    return instance;
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry)

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