Search in sources :

Example 1 with ResourceDelete

use of io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete in project crnk-framework by crnk-project.

the class ResourceDeleteTest method onGivenRequestResourceGetShouldHandleIt.

@Test
public void onGivenRequestResourceGetShouldHandleIt() throws Exception {
    // GIVEN
    JsonPath jsonPath = pathBuilder.build("/tasks/1");
    ResourceDelete sut = new ResourceDelete(resourceRegistry, new ArrayList<ResourceModificationFilter>());
    // WHEN
    Response response = sut.handle(jsonPath, emptyTaskQuery, null, null);
    // THEN
    assertThat(response.getDocument()).isNull();
}
Also used : Response(io.crnk.core.engine.dispatcher.Response) ResourceModificationFilter(io.crnk.core.engine.filter.ResourceModificationFilter) ResourceDelete(io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 2 with ResourceDelete

use of io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete 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();
}
Also used : ResourceModificationFilter(io.crnk.core.engine.filter.ResourceModificationFilter) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) ResourceDelete(io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 3 with ResourceDelete

use of io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete in project crnk-framework by crnk-project.

the class ResourceDeleteTest method onNonRelationRequestShouldDenyIt.

@Test
public void onNonRelationRequestShouldDenyIt() {
    // GIVEN
    JsonPath jsonPath = new ResourcePath("tasks/1/relationships/project");
    ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
    ResourceDelete sut = new ResourceDelete(resourceRegistry, new ArrayList<ResourceModificationFilter>());
    // WHEN
    boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
    // THEN
    assertThat(result).isFalse();
}
Also used : ResourcePath(io.crnk.core.engine.internal.dispatcher.path.ResourcePath) ResourceModificationFilter(io.crnk.core.engine.filter.ResourceModificationFilter) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) ResourceDelete(io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Aggregations

ResourceModificationFilter (io.crnk.core.engine.filter.ResourceModificationFilter)3 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)3 ResourceDelete (io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete)3 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)3 Test (org.junit.Test)3 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)2 Response (io.crnk.core.engine.dispatcher.Response)1 ResourcePath (io.crnk.core.engine.internal.dispatcher.path.ResourcePath)1