Search in sources :

Example 6 with LazyTask

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

the class DocumentMapperTest method testRelationshipLazyMultiValued.

@Test
public void testRelationshipLazyMultiValued() {
    LazyTask task = createLazyTask(2);
    Project project1 = createProject(3, "sample project");
    Project project2 = createProject(4, "sample project");
    task.setProjects(Arrays.asList(project1, project2));
    Document document = mapper.toDocument(toResponse(task), createAdapter(Task.class));
    Resource resource = document.getSingleData().get();
    Assert.assertEquals("2", resource.getId());
    Relationship relationship = resource.getRelationships().get("projects");
    Assert.assertNotNull(relationship);
    Nullable<List<ResourceIdentifier>> relationshipData = relationship.getCollectionData();
    Assert.assertFalse(relationshipData.isPresent());
    Assert.assertTrue(document.getIncluded().isEmpty());
}
Also used : Project(io.crnk.core.mock.models.Project) LazyTask(io.crnk.core.mock.models.LazyTask) Task(io.crnk.core.mock.models.Task) Relationship(io.crnk.core.engine.document.Relationship) Resource(io.crnk.core.engine.document.Resource) List(java.util.List) LazyTask(io.crnk.core.mock.models.LazyTask) Document(io.crnk.core.engine.document.Document) Test(org.junit.Test)

Aggregations

LazyTask (io.crnk.core.mock.models.LazyTask)6 Document (io.crnk.core.engine.document.Document)5 Relationship (io.crnk.core.engine.document.Relationship)5 Resource (io.crnk.core.engine.document.Resource)5 Project (io.crnk.core.mock.models.Project)5 Test (org.junit.Test)5 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)4 Task (io.crnk.core.mock.models.Task)3 QuerySpec (io.crnk.core.queryspec.QuerySpec)2 List (java.util.List)1