Search in sources :

Example 6 with ResourcePath

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

Example 7 with ResourcePath

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

the class ResourcePostTest method onNonExistentResourceShouldThrowException.

@Test
public void onNonExistentResourceShouldThrowException() throws Exception {
    // GIVEN
    Document newProjectBody = new Document();
    Resource data = createProject();
    data.setType("fridges");
    newProjectBody.setData(Nullable.of((Object) data));
    ResourcePost sut = new ResourcePost(resourceRegistry, PROPERTIES_PROVIDER, typeParser, objectMapper, documentMapper, modificationFilters);
    // THEN
    expectedException.expect(RepositoryNotFoundException.class);
    // WHEN
    sut.handle(new ResourcePath("fridges"), emptyTaskQuery, null, newProjectBody);
}
Also used : ResourcePath(io.crnk.core.engine.internal.dispatcher.path.ResourcePath) Resource(io.crnk.core.engine.document.Resource) Document(io.crnk.core.engine.document.Document) ResourcePost(io.crnk.core.engine.internal.dispatcher.controller.ResourcePost) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 8 with ResourcePath

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

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

Example 10 with ResourcePath

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

the class RelationshipsResourceGetTest method onFieldRequestShouldDenyIt.

@Test
public void onFieldRequestShouldDenyIt() {
    // GIVEN
    JsonPath jsonPath = new ResourcePath("tasks/1/project");
    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

ResourcePath (io.crnk.core.engine.internal.dispatcher.path.ResourcePath)15 Test (org.junit.Test)15 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)14 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)10 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)10 ResourcePost (io.crnk.core.engine.internal.dispatcher.controller.ResourcePost)4 FieldResourceGet (io.crnk.core.engine.internal.dispatcher.controller.FieldResourceGet)2 FieldResourcePost (io.crnk.core.engine.internal.dispatcher.controller.FieldResourcePost)2 RelationshipsResourceGet (io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourceGet)2 Document (io.crnk.core.engine.document.Document)1 Resource (io.crnk.core.engine.document.Resource)1 ResourceFilterDirectory (io.crnk.core.engine.filter.ResourceFilterDirectory)1 ResourceModificationFilter (io.crnk.core.engine.filter.ResourceModificationFilter)1 ControllerRegistry (io.crnk.core.engine.internal.dispatcher.ControllerRegistry)1 ControllerRegistryBuilder (io.crnk.core.engine.internal.dispatcher.ControllerRegistryBuilder)1 RelationshipsResourceDelete (io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourceDelete)1 RelationshipsResourcePatch (io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourcePatch)1 RelationshipsResourcePost (io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourcePost)1 ResourceDelete (io.crnk.core.engine.internal.dispatcher.controller.ResourceDelete)1 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)1