use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class TaskToProjectRepository method findOneTarget.
@Override
public Project findOneTarget(Long sourceId, String fieldName, QuerySpec queryParams) {
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());
return project;
}
}
return null;
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class ProjectToTaskRepository method findManyTargets.
@Override
public ResourceList<Task> findManyTargets(Long sourceId, String fieldName, QuerySpec queryParams) {
DefaultResourceList<Task> tasks = new DefaultResourceList<>();
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);
tasks.add(task);
}
}
return tasks;
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class ControllerTest method setup.
@Before
public void setup() {
TaskRepository repo = new TaskRepository();
Task task = new Task();
task.setName("test value");
task.setId(1L);
repo.save(task);
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testCreateAndFind.
@Test
public void testCreateAndFind() {
Task task = new Task();
task.setId(1L);
task.setName("test");
taskRepo.create(task);
// check retrievable with findAll
List<Task> tasks = taskRepo.findAll(new QuerySpec(Task.class));
Assert.assertEquals(1, tasks.size());
Task savedTask = tasks.get(0);
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getName(), savedTask.getName());
// check retrievable with findAll(ids)
tasks = taskRepo.findAll(Arrays.asList(1L), new QuerySpec(Task.class));
Assert.assertEquals(1, tasks.size());
savedTask = tasks.get(0);
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getName(), savedTask.getName());
// check retrievable with findOne
savedTask = taskRepo.findOne(1L, new QuerySpec(Task.class));
Assert.assertEquals(task.getId(), savedTask.getId());
Assert.assertEquals(task.getName(), savedTask.getName());
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testGeneratedId.
@Test
public void testGeneratedId() {
Task task = new Task();
task.setId(null);
task.setName("test");
Task savedTask = taskRepo.create(task);
Assert.assertNotNull(savedTask.getId());
}
Aggregations