Search in sources :

Example 61 with JsonPath

use of io.crnk.core.engine.internal.dispatcher.path.JsonPath in project crnk-framework by crnk-project.

the class RelationshipsResourcePostTest method onValidRequestShouldAcceptIt.

@Test
public void onValidRequestShouldAcceptIt() {
    // GIVEN
    JsonPath jsonPath = pathBuilder.build("tasks/1/relationships/project");
    ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
    RelationshipsResourcePost sut = new RelationshipsResourcePost(resourceRegistry, typeParser, modificationFilters);
    // WHEN
    boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
    // THEN
    assertThat(result).isTrue();
}
Also used : ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) RelationshipsResourcePost(io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourcePost) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 62 with JsonPath

use of io.crnk.core.engine.internal.dispatcher.path.JsonPath in project crnk-framework by crnk-project.

the class RelationshipsResourcePostTest method onNonRelationRequestShouldDenyIt.

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

Example 63 with JsonPath

use of io.crnk.core.engine.internal.dispatcher.path.JsonPath 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 64 with JsonPath

use of io.crnk.core.engine.internal.dispatcher.path.JsonPath 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 65 with JsonPath

use of io.crnk.core.engine.internal.dispatcher.path.JsonPath 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

JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)88 Test (org.junit.Test)80 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)72 Response (io.crnk.core.engine.dispatcher.Response)50 Document (io.crnk.core.engine.document.Document)46 Resource (io.crnk.core.engine.document.Resource)41 ResourcePost (io.crnk.core.engine.internal.dispatcher.controller.ResourcePost)36 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)20 ResourcePatch (io.crnk.core.engine.internal.dispatcher.controller.ResourcePatch)16 Project (io.crnk.core.mock.models.Project)14 Relationship (io.crnk.core.engine.document.Relationship)13 RelationshipsResourcePost (io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourcePost)12 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)11 ResourcePath (io.crnk.core.engine.internal.dispatcher.path.ResourcePath)10 QuerySpec (io.crnk.core.queryspec.QuerySpec)10 JsonApiResponse (io.crnk.core.repository.response.JsonApiResponse)10 Task (io.crnk.core.mock.models.Task)9 TaskToProjectRepository (io.crnk.core.mock.repository.TaskToProjectRepository)9 QueryParams (io.crnk.legacy.queryParams.QueryParams)9 ResourceModificationFilter (io.crnk.core.engine.filter.ResourceModificationFilter)8