Search in sources :

Example 31 with Project

use of io.crnk.core.mock.models.Project in project crnk-framework by crnk-project.

the class AnnotatedRelationshipRepositoryAdapterTest method onClassWithoutSetRelationShouldThrowException.

@Test(expected = RepositoryAnnotationNotFoundException.class)
public void onClassWithoutSetRelationShouldThrowException() throws Exception {
    // GIVEN
    RelationshipRepositoryWithoutAnyMethods repo = new RelationshipRepositoryWithoutAnyMethods();
    AnnotatedRelationshipRepositoryAdapter<Task, Long, Project, Long> sut = new AnnotatedRelationshipRepositoryAdapter<>(repo, parameterProvider);
    // WHEN
    sut.setRelation(new Task(), 1L, "project", queryAdapter);
}
Also used : Project(io.crnk.core.mock.models.Project) Task(io.crnk.core.mock.models.Task) AnnotatedRelationshipRepositoryAdapter(io.crnk.legacy.internal.AnnotatedRelationshipRepositoryAdapter) Test(org.junit.Test)

Example 32 with Project

use of io.crnk.core.mock.models.Project in project crnk-framework by crnk-project.

the class AnnotatedRelationshipRepositoryAdapterTest method onClassWithSetRelationShouldSetValue.

@Test
public void onClassWithSetRelationShouldSetValue() throws Exception {
    // GIVEN
    RelationshipRepositoryWithSetRelation repo = spy(RelationshipRepositoryWithSetRelation.class);
    AnnotatedRelationshipRepositoryAdapter<Task, Long, Project, Long> sut = new AnnotatedRelationshipRepositoryAdapter<>(repo, parameterProvider);
    Task task = new Task();
    // WHEN
    sut.setRelation(task, 1L, "project", queryAdapter);
    // THEN
    verify(repo).setRelation(eq(task), eq(1L), eq("project"));
}
Also used : Project(io.crnk.core.mock.models.Project) Task(io.crnk.core.mock.models.Task) AnnotatedRelationshipRepositoryAdapter(io.crnk.legacy.internal.AnnotatedRelationshipRepositoryAdapter) Test(org.junit.Test)

Example 33 with Project

use of io.crnk.core.mock.models.Project in project crnk-framework by crnk-project.

the class AnnotatedRelationshipRepositoryAdapterTest method onClassWithSetRelationsShouldSetValues.

@Test
public void onClassWithSetRelationsShouldSetValues() throws Exception {
    // GIVEN
    RelationshipRepositoryWithSetRelations repo = spy(RelationshipRepositoryWithSetRelations.class);
    AnnotatedRelationshipRepositoryAdapter<Task, Long, Project, Long> sut = new AnnotatedRelationshipRepositoryAdapter<>(repo, parameterProvider);
    Task task = new Task();
    // WHEN
    sut.setRelations(task, Collections.singleton(1L), "project", queryAdapter);
    // THEN
    verify(repo).setRelations(eq(task), eq(Collections.singleton(1L)), eq("project"));
}
Also used : Project(io.crnk.core.mock.models.Project) Task(io.crnk.core.mock.models.Task) AnnotatedRelationshipRepositoryAdapter(io.crnk.legacy.internal.AnnotatedRelationshipRepositoryAdapter) Test(org.junit.Test)

Example 34 with Project

use of io.crnk.core.mock.models.Project in project crnk-framework by crnk-project.

the class AnnotatedRelationshipRepositoryAdapterTest method onClassWithoutRemoveRelationsShouldThrowException.

@Test(expected = RepositoryAnnotationNotFoundException.class)
public void onClassWithoutRemoveRelationsShouldThrowException() throws Exception {
    // GIVEN
    RelationshipRepositoryWithoutAnyMethods repo = new RelationshipRepositoryWithoutAnyMethods();
    AnnotatedRelationshipRepositoryAdapter<Task, Long, Project, Long> sut = new AnnotatedRelationshipRepositoryAdapter<>(repo, parameterProvider);
    // WHEN
    sut.removeRelations(new Task(), Collections.singleton(1L), "project", queryAdapter);
}
Also used : Project(io.crnk.core.mock.models.Project) Task(io.crnk.core.mock.models.Task) AnnotatedRelationshipRepositoryAdapter(io.crnk.legacy.internal.AnnotatedRelationshipRepositoryAdapter) Test(org.junit.Test)

Example 35 with Project

use of io.crnk.core.mock.models.Project in project crnk-framework by crnk-project.

the class AnnotatedRelationshipRepositoryAdapterTest method onClassWithEmptyRemoveRelationsShouldThrowException.

@Test(expected = RepositoryMethodException.class)
public void onClassWithEmptyRemoveRelationsShouldThrowException() throws Exception {
    // GIVEN
    RelationshipRepositoryWithEmptyRemoveRelations repo = new RelationshipRepositoryWithEmptyRemoveRelations();
    AnnotatedRelationshipRepositoryAdapter<Task, Long, Project, Long> sut = new AnnotatedRelationshipRepositoryAdapter<>(repo, parameterProvider);
    // WHEN
    sut.removeRelations(new Task(), Collections.singleton(1L), "project", queryAdapter);
}
Also used : Project(io.crnk.core.mock.models.Project) Task(io.crnk.core.mock.models.Task) AnnotatedRelationshipRepositoryAdapter(io.crnk.legacy.internal.AnnotatedRelationshipRepositoryAdapter) Test(org.junit.Test)

Aggregations

Project (io.crnk.core.mock.models.Project)68 Test (org.junit.Test)54 Task (io.crnk.core.mock.models.Task)44 Document (io.crnk.core.engine.document.Document)27 QuerySpec (io.crnk.core.queryspec.QuerySpec)25 Resource (io.crnk.core.engine.document.Resource)24 Response (io.crnk.core.engine.dispatcher.Response)15 Relationship (io.crnk.core.engine.document.Relationship)14 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)14 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)12 AnnotatedRelationshipRepositoryAdapter (io.crnk.legacy.internal.AnnotatedRelationshipRepositoryAdapter)12 ResourcePost (io.crnk.core.engine.internal.dispatcher.controller.ResourcePost)11 LazyTask (io.crnk.core.mock.models.LazyTask)11 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)10 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)8 TaskToProjectRepository (io.crnk.core.mock.repository.TaskToProjectRepository)8 ProjectRepository (io.crnk.core.mock.repository.ProjectRepository)7 TaskRepository (io.crnk.core.mock.repository.TaskRepository)7 QueryParams (io.crnk.legacy.queryParams.QueryParams)7 ResourceField (io.crnk.core.engine.information.resource.ResourceField)6