Search in sources :

Example 51 with JsonPath

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

the class CollectionGetTest method onGivenRequestCollectionWithIdsGetShouldHandleIt.

@Test
public void onGivenRequestCollectionWithIdsGetShouldHandleIt() {
    // GIVEN
    JsonPath jsonPath = pathBuilder.build("/tasks/1,2");
    CollectionGet sut = new CollectionGet(resourceRegistry, typeParser, documentMapper);
    // WHEN
    Response response = sut.handle(jsonPath, emptyTaskQuery, null, null);
    // THEN
    Assert.assertNotNull(response);
}
Also used : Response(io.crnk.core.engine.dispatcher.Response) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) Test(org.junit.Test)

Example 52 with JsonPath

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

the class CollectionGetTest method onGivenRequestCollectionGetShouldAcceptIt.

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

Example 53 with JsonPath

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

the class CollectionGetTest method onGivenRequestCollectionGetShouldHandleIt.

@Test
public void onGivenRequestCollectionGetShouldHandleIt() {
    // GIVEN
    JsonPath jsonPath = pathBuilder.build("/tasks/");
    CollectionGet sut = new CollectionGet(resourceRegistry, typeParser, documentMapper);
    // WHEN
    Response response = sut.handle(jsonPath, emptyTaskQuery, null, null);
    // THEN
    Assert.assertNotNull(response);
}
Also used : Response(io.crnk.core.engine.dispatcher.Response) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) Test(org.junit.Test)

Example 54 with JsonPath

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

the class FieldResourcePostTest method onRelationshipRequestShouldDenyIt.

@Test
public void onRelationshipRequestShouldDenyIt() {
    // GIVEN
    JsonPath jsonPath = new ResourcePath("tasks/1/relationships/project");
    ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
    FieldResourcePost sut = new FieldResourcePost(resourceRegistry, PROPERTIES_PROVIDER, typeParser, objectMapper, documentMapper, 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) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) FieldResourcePost(io.crnk.core.engine.internal.dispatcher.controller.FieldResourcePost) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 55 with JsonPath

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

the class RelationshipsResourceGetTest method onNonRelationRequestShouldDenyIt.

@Test
public void onNonRelationRequestShouldDenyIt() {
    // GIVEN
    JsonPath jsonPath = new ResourcePath("tasks");
    ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
    RelationshipsResourceGet sut = new RelationshipsResourceGet(resourceRegistry, typeParser, documentMapper);
    // WHEN
    boolean result = sut.isAcceptable(jsonPath, REQUEST_TYPE);
    // THEN
    assertThat(result).isFalse();
}
Also used : ResourcePath(io.crnk.core.engine.internal.dispatcher.path.ResourcePath) RelationshipsResourceGet(io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourceGet) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) 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