Search in sources :

Example 6 with ResourceGet

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

the class ResourceGetTest method onGivenRequestResourceGetShouldAcceptIt.

@Test
public void onGivenRequestResourceGetShouldAcceptIt() {
    // GIVEN
    JsonPath jsonPath = pathBuilder.build("/tasks/2");
    ResourceGet sut = new ResourceGet(resourceRegistry, typeParser, documentMapper);
    // WHEN
    boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
    // THEN
    Assert.assertEquals(result, true);
}
Also used : ResourceGet(io.crnk.core.engine.internal.dispatcher.controller.ResourceGet) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 7 with ResourceGet

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

the class ResourceGetTest method onMethodMismatchShouldDenyIt.

@Test
public void onMethodMismatchShouldDenyIt() {
    // GIVEN
    JsonPath jsonPath = pathBuilder.build("/tasks/2");
    ResourceGet sut = new ResourceGet(resourceRegistry, typeParser, documentMapper);
    // WHEN
    boolean result = sut.isAcceptable(jsonPath, "POST");
    // THEN
    Assert.assertEquals(result, false);
}
Also used : ResourceGet(io.crnk.core.engine.internal.dispatcher.controller.ResourceGet) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 8 with ResourceGet

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

the class ResourceGetTest method onGivenRequestResourceGetShouldThrowError.

@Test(expected = ResourceNotFoundException.class)
public void onGivenRequestResourceGetShouldThrowError() throws Exception {
    // GIVEN
    JsonPath jsonPath = pathBuilder.build("/tasks/" + -1);
    ResourceGet sut = new ResourceGet(resourceRegistry, typeParser, documentMapper);
    // WHEN
    Response response = sut.handle(jsonPath, emptyTaskQuery, null, null);
    // THEN
    Assert.assertNull(response);
}
Also used : Response(io.crnk.core.engine.dispatcher.Response) ResourceGet(io.crnk.core.engine.internal.dispatcher.controller.ResourceGet) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Aggregations

BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)8 ResourceGet (io.crnk.core.engine.internal.dispatcher.controller.ResourceGet)8 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)8 Test (org.junit.Test)8 Response (io.crnk.core.engine.dispatcher.Response)5 Resource (io.crnk.core.engine.document.Resource)4 Document (io.crnk.core.engine.document.Document)3 ResourceModificationFilter (io.crnk.core.engine.filter.ResourceModificationFilter)2 RelationshipsResourcePost (io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourcePost)2 ResourcePost (io.crnk.core.engine.internal.dispatcher.controller.ResourcePost)2 QueryParamsAdapter (io.crnk.legacy.internal.QueryParamsAdapter)2 DefaultQueryParamsParser (io.crnk.legacy.queryParams.DefaultQueryParamsParser)2 QueryParams (io.crnk.legacy.queryParams.QueryParams)2 QueryParamsBuilder (io.crnk.legacy.queryParams.QueryParamsBuilder)2 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)1 ResourcePatch (io.crnk.core.engine.internal.dispatcher.controller.ResourcePatch)1 Project (io.crnk.core.mock.models.Project)1 Task (io.crnk.core.mock.models.Task)1 TaskWithLookup (io.crnk.core.mock.models.TaskWithLookup)1 TaskToProjectRepository (io.crnk.core.mock.repository.TaskToProjectRepository)1