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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations