use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class DecoratorTest method testResourceRegistryAwareDecoration.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testResourceRegistryAwareDecoration() {
RegistryAwareResourceRepository repository = Mockito.mock(RegistryAwareResourceRepository.class);
ResourceRepositoryDecoratorBase<Schedule, Long> decorator = new ResourceRepositoryDecoratorBase() {
};
decorator.setDecoratedObject(repository);
ResourceRegistry resourceRegistry = Mockito.mock(ResourceRegistry.class);
decorator.setResourceRegistry(resourceRegistry);
Mockito.verify(repository, Mockito.times(1)).setResourceRegistry(Mockito.eq(resourceRegistry));
}
use of io.crnk.core.engine.registry.ResourceRegistry 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.ResourceRegistry in project crnk-framework by crnk-project.
the class RelationshipsResourceDeleteTest method onValidRequestShouldAcceptIt.
@Test
public void onValidRequestShouldAcceptIt() {
// GIVEN
JsonPath jsonPath = pathBuilder.build("tasks/1/relationships/project");
ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
RelationshipsResourceDelete sut = new RelationshipsResourceDelete(resourceRegistry, typeParser, modificationFilters);
// WHEN
boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
// THEN
assertThat(result).isTrue();
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class RelationshipsResourcePatchTest method onNonRelationRequestShouldDenyIt.
@Test
public void onNonRelationRequestShouldDenyIt() {
// GIVEN
JsonPath jsonPath = new ResourcePath("tasks");
ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
RelationshipsResourcePatch sut = new RelationshipsResourcePatch(resourceRegistry, typeParser, modificationFilters);
// WHEN
boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
// THEN
assertThat(result).isFalse();
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class ResourceDeleteTest method onValidRequestShouldAcceptIt.
@Test
public void onValidRequestShouldAcceptIt() {
// GIVEN
JsonPath jsonPath = pathBuilder.build("tasks/1");
ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
ResourceDelete sut = new ResourceDelete(resourceRegistry, new ArrayList<ResourceModificationFilter>());
// WHEN
boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
// THEN
assertThat(result).isTrue();
}
Aggregations