Search in sources :

Example 31 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class TaskToProjectRepository method findManyTargets.

@Override
public ResourceList<Project> findManyTargets(Long sourceId, String fieldName, QuerySpec queryParams) {
    DefaultResourceList<Project> projects = new DefaultResourceList<>();
    for (Relation<Task> relation : THREAD_LOCAL_REPOSITORY.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Project project = new Project();
            project.setId((Long) relation.getTargetId());
            projects.add(project);
        }
    }
    return projects;
}
Also used : Project(io.crnk.test.mock.models.Project) Task(io.crnk.test.mock.models.Task) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList)

Example 32 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class ProjectToTaskRepository method findOneTarget.

@Override
public Task findOneTarget(Long sourceId, String fieldName, QuerySpec queryParams) {
    for (Relation<Project> relation : THREAD_LOCAL_REPOSITORY.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Task task = taskRepo.findOne((long) relation.getTargetId(), null);
            Assert.assertNotNull(task);
            return task;
        }
    }
    return null;
}
Also used : Project(io.crnk.test.mock.models.Project) Task(io.crnk.test.mock.models.Task)

Example 33 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class ClientResourceUpsertTest method setMeta.

@Test
public void setMeta() throws IOException {
    Resource resource = new Resource();
    JsonNode meta = boot.getObjectMapper().reader().readTree("{\"value\": \"metaValue\"}");
    resource.setMeta((ObjectNode) meta);
    Task task = new Task();
    ResourceInformation resourceInformation = boot.getResourceRegistry().getEntry(Task.class).getResourceInformation();
    upsert.setMeta(resource, task, resourceInformation);
    Assert.assertEquals("metaValue", task.getMetaInformation().value);
}
Also used : Task(io.crnk.test.mock.models.Task) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Resource(io.crnk.core.engine.document.Resource) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 34 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class ClientResourceUpsertTest method setInvalidMetaThrowsException.

@Test(expected = ResponseBodyException.class)
public void setInvalidMetaThrowsException() throws IOException {
    Resource resource = new Resource();
    JsonNode invalidMeta = boot.getObjectMapper().reader().readTree("{\"invalidAttr\": 1}");
    resource.setMeta((ObjectNode) invalidMeta);
    Task task = new Task();
    ResourceInformation resourceInformation = boot.getResourceRegistry().getEntry(Task.class).getResourceInformation();
    upsert.setMeta(resource, task, resourceInformation);
}
Also used : Task(io.crnk.test.mock.models.Task) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Resource(io.crnk.core.engine.document.Resource) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 35 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class ClientResourceUpsertTest method setInvalidLinksThrowsException.

@Test(expected = ResponseBodyException.class)
public void setInvalidLinksThrowsException() throws IOException {
    Resource resource = new Resource();
    JsonNode invalidLinks = boot.getObjectMapper().reader().readTree("{\"invalidAttr\": 1}");
    resource.setLinks((ObjectNode) invalidLinks);
    Task task = new Task();
    ResourceInformation resourceInformation = boot.getResourceRegistry().getEntry(Task.class).getResourceInformation();
    upsert.setLinks(resource, task, resourceInformation);
}
Also used : Task(io.crnk.test.mock.models.Task) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Resource(io.crnk.core.engine.document.Resource) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

Task (io.crnk.test.mock.models.Task)53 Test (org.junit.Test)42 QuerySpec (io.crnk.core.queryspec.QuerySpec)27 Project (io.crnk.test.mock.models.Project)11 Schedule (io.crnk.test.mock.models.Schedule)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 QueryParams (io.crnk.legacy.queryParams.QueryParams)6 ObjectProxy (io.crnk.client.internal.proxy.ObjectProxy)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 Resource (io.crnk.core.engine.document.Resource)4 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)4 Span (org.springframework.cloud.sleuth.Span)4 SortSpec (io.crnk.core.queryspec.SortSpec)3 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)3 TaskRepository (io.crnk.test.mock.repository.TaskRepository)3 Interceptor (okhttp3.Interceptor)3 Before (org.junit.Before)3 OkHttpAdapter (io.crnk.client.http.okhttp.OkHttpAdapter)2 OkHttpAdapterListener (io.crnk.client.http.okhttp.OkHttpAdapterListener)2 FilterSpec (io.crnk.core.queryspec.FilterSpec)2