Search in sources :

Example 11 with ResourcePath

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

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

the class RelationshipsResourceDeleteTest method onNonRelationRequestShouldDenyIt.

@Test
public void onNonRelationRequestShouldDenyIt() {
    // GIVEN
    JsonPath jsonPath = new ResourcePath("tasks");
    ResourceRegistry resourceRegistry = mock(ResourceRegistry.class);
    RelationshipsResourceDelete sut = new RelationshipsResourceDelete(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) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) RelationshipsResourceDelete(io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourceDelete) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 13 with ResourcePath

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

the class ResourcePostTest method onNoBodyResourceShouldThrowException.

@Test
public void onNoBodyResourceShouldThrowException() throws Exception {
    // GIVEN
    ResourcePost sut = new ResourcePost(resourceRegistry, PROPERTIES_PROVIDER, typeParser, objectMapper, documentMapper, modificationFilters);
    // THEN
    expectedException.expect(RequestBodyNotFoundException.class);
    // WHEN
    sut.handle(new ResourcePath("tasks"), emptyTaskQuery, null, null);
}
Also used : ResourcePath(io.crnk.core.engine.internal.dispatcher.path.ResourcePath) ResourcePost(io.crnk.core.engine.internal.dispatcher.controller.ResourcePost) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 14 with ResourcePath

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

the class ResourcePostTest method onUnknownResourceTypeShouldThrowException.

@Test
public void onUnknownResourceTypeShouldThrowException() throws Exception {
    // GIVEN
    ResourcePost sut = new ResourcePost(resourceRegistry, PROPERTIES_PROVIDER, typeParser, objectMapper, documentMapper, modificationFilters);
    // THEN
    expectedException.expect(RepositoryNotFoundException.class);
    // WHEN
    sut.handle(new ResourcePath("fridges"), emptyTaskQuery, null, null);
}
Also used : ResourcePath(io.crnk.core.engine.internal.dispatcher.path.ResourcePath) ResourcePost(io.crnk.core.engine.internal.dispatcher.controller.ResourcePost) BaseControllerTest(io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest) Test(org.junit.Test)

Example 15 with ResourcePath

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

the class ControllerRegistryBuilderTest method onBuildShouldAddAllControllers.

@Test
public void onBuildShouldAddAllControllers() throws Exception {
    // GIVEN
    PropertiesProvider propertiesProvider = Mockito.mock(PropertiesProvider.class);
    ResourceFilterDirectory resourceFilterDirectory = Mockito.mock(ResourceFilterDirectory.class);
    ControllerRegistryBuilder sut = new ControllerRegistryBuilder(null, null, null, propertiesProvider, resourceFilterDirectory, (List) Collections.emptyList());
    // WHEN
    ControllerRegistry result = sut.build();
    // THEN
    result.getController(new ResourcePath("path"), "GET");
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) ControllerRegistry(io.crnk.core.engine.internal.dispatcher.ControllerRegistry) ResourcePath(io.crnk.core.engine.internal.dispatcher.path.ResourcePath) ResourceFilterDirectory(io.crnk.core.engine.filter.ResourceFilterDirectory) ControllerRegistryBuilder(io.crnk.core.engine.internal.dispatcher.ControllerRegistryBuilder) 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