use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class DefaultQuerySpecSerializerTest method testPagingOnRelation.
@Test
public void testPagingOnRelation() throws InstantiationException, IllegalAccessException {
QuerySpec querySpec = new QuerySpec(Task.class);
querySpec.setLimit(2L);
querySpec.setOffset(1L);
RegistryEntry entry = resourceRegistry.getEntry(Task.class);
String actualUrl = urlBuilder.buildUrl(entry.getResourceInformation(), 1L, querySpec, "projects");
assertEquals("http://127.0.0.1/tasks/1/relationships/projects?page[limit]=2&page[offset]=1", actualUrl);
}
use of io.crnk.core.engine.registry.RegistryEntry 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;
}
use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class ResourceIdControllerTest method toQueryAdapter.
private QueryAdapter toQueryAdapter(QueryParams requestParams, Class resourceType) {
ResourceRegistry resourceRegistry = moduleRegistry.getResourceRegistry();
RegistryEntry entry = resourceRegistry.getEntry(resourceType);
ResourceInformation resourceInformation = entry.getResourceInformation();
return new QueryParamsAdapter(resourceInformation, requestParams, moduleRegistry);
}
use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class ResourceFilterDirectoryImplTest method checkForbiddenRelationshipsField.
@Test
public void checkForbiddenRelationshipsField() {
ResourceInformation projectsInformation = Mockito.mock(ResourceInformation.class);
Mockito.when(filter.filterField(Mockito.eq(resourceField), Mockito.any(HttpMethod.class))).thenReturn(FilterBehavior.NONE);
Mockito.when(resourceField.getResourceFieldType()).thenReturn(ResourceFieldType.RELATIONSHIP);
Mockito.when(resourceField.getOppositeResourceType()).thenReturn("projects");
RegistryEntry projectsEntry = Mockito.mock(RegistryEntry.class);
Mockito.when(projectsEntry.getResourceInformation()).thenReturn(projectsInformation);
Mockito.when(resourceRegistry.getEntry(Mockito.eq("projects"))).thenReturn(projectsEntry);
// forbid related resource
Mockito.when(filter.filterResource(Mockito.eq(projectsInformation), Mockito.any(HttpMethod.class))).thenReturn(FilterBehavior.FORBIDDEN);
Assert.assertEquals(FilterBehavior.FORBIDDEN, directory.get(resourceField, HttpMethod.GET));
// allow related resource
Mockito.when(filter.filterResource(Mockito.eq(projectsInformation), Mockito.any(HttpMethod.class))).thenReturn(FilterBehavior.NONE);
Assert.assertEquals(FilterBehavior.NONE, directory.get(resourceField, HttpMethod.GET));
}
use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.
the class RelationshipRepositoryBehaviorTest method checkRelationIdTriggersImplicitOwnerRepo.
@Test
public void checkRelationIdTriggersImplicitOwnerRepo() {
RegistryEntry entry = resourceRegistry.getEntry(RelationshipBehaviorTestResource.class);
Object relRepository = entry.getRelationshipRepository("testRelationId", null).getRelationshipRepository();
Assert.assertEquals(ForwardingRelationshipRepository.class, relRepository.getClass());
}
Aggregations