Search in sources :

Example 6 with DirectResponseResourceEntry

use of io.crnk.legacy.internal.DirectResponseResourceEntry in project crnk-framework by crnk-project.

the class QuerySpecAdapterTest method test.

@Test
public void test() {
    ModuleRegistry moduleRegistry = new ModuleRegistry();
    ResourceRegistry resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
    ResourceInformation resourceInformation = new ResourceInformation(moduleRegistry.getTypeParser(), Task.class, "tasks", null, null, new OffsetLimitPagingBehavior());
    resourceRegistry.addEntry(new RegistryEntry(new DirectResponseResourceEntry(null, new ResourceRepositoryInformationImpl("tasks", resourceInformation, RepositoryMethodAccess.ALL))));
    QuerySpec spec = new QuerySpec(Task.class);
    spec.includeField(Arrays.asList("test"));
    spec.includeRelation(Arrays.asList("relation"));
    QuerySpecAdapter adapter = new QuerySpecAdapter(spec, resourceRegistry);
    Assert.assertEquals(Task.class, adapter.getResourceInformation().getResourceClass());
    Assert.assertEquals(spec, adapter.getQuerySpec());
    TypedParams<IncludedFieldsParams> includedFields = adapter.getIncludedFields();
    IncludedFieldsParams includedFieldsParams = includedFields.getParams().get("tasks");
    Assert.assertEquals(1, includedFieldsParams.getParams().size());
    Assert.assertEquals("test", includedFieldsParams.getParams().iterator().next());
    TypedParams<IncludedRelationsParams> includedRelations = adapter.getIncludedRelations();
    IncludedRelationsParams includedRelationsParams = includedRelations.getParams().get("tasks");
    Assert.assertEquals(1, includedRelationsParams.getParams().size());
    Assert.assertEquals("relation", includedRelationsParams.getParams().iterator().next().getPath());
    Assert.assertEquals(new OffsetLimitPagingSpec(), adapter.getPagingSpec());
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) DirectResponseResourceEntry(io.crnk.legacy.internal.DirectResponseResourceEntry) OffsetLimitPagingSpec(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec) ModuleRegistry(io.crnk.core.module.ModuleRegistry) ResourceRegistryImpl(io.crnk.core.engine.internal.registry.ResourceRegistryImpl) IncludedRelationsParams(io.crnk.legacy.queryParams.params.IncludedRelationsParams) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) IncludedFieldsParams(io.crnk.legacy.queryParams.params.IncludedFieldsParams) ResourceRepositoryInformationImpl(io.crnk.core.engine.internal.information.repository.ResourceRepositoryInformationImpl) DefaultResourceRegistryPart(io.crnk.core.engine.registry.DefaultResourceRegistryPart) Test(org.junit.Test)

Aggregations

DirectResponseResourceEntry (io.crnk.legacy.internal.DirectResponseResourceEntry)6 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)4 ResourceRepositoryInformation (io.crnk.core.engine.information.repository.ResourceRepositoryInformation)3 ResourceField (io.crnk.core.engine.information.resource.ResourceField)3 ResourceRepositoryInformationImpl (io.crnk.core.engine.internal.information.repository.ResourceRepositoryInformationImpl)3 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)3 RepositoryInstanceBuilder (io.crnk.legacy.registry.RepositoryInstanceBuilder)3 Test (org.junit.Test)3 OffsetLimitPagingBehavior (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior)2 DirectResponseRelationshipEntry (io.crnk.legacy.internal.DirectResponseRelationshipEntry)2 AnnotatedResourceEntry (io.crnk.legacy.registry.AnnotatedResourceEntry)2 ResourceRepositoryStubImpl (io.crnk.client.internal.ResourceRepositoryStubImpl)1 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)1 ResourceFieldImpl (io.crnk.core.engine.internal.information.resource.ResourceFieldImpl)1 ResourceRegistryImpl (io.crnk.core.engine.internal.registry.ResourceRegistryImpl)1 ResourceRepositoryAdapter (io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter)1 DefaultResourceRegistryPart (io.crnk.core.engine.registry.DefaultResourceRegistryPart)1 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)1 Task (io.crnk.core.mock.models.Task)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1