use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class ModuleClientTest method test.
@Test
public void test() {
ResourceRepositoryV2<Task, Long> taskRepo = client.getRepositoryForType(Task.class);
Task task = new Task();
task.setId(1L);
task.setName("task");
taskRepo.create(task);
List<Task> tasks = taskRepo.findAll(new QuerySpec(Task.class));
Assert.assertEquals(1, tasks.size());
Mockito.verify(testModule, Mockito.times(1)).setupModule(Mockito.any(ModuleContext.class));
Mockito.verify(testModule, Mockito.times(1)).setHttpAdapter(Mockito.eq(client.getHttpAdapter()));
Mockito.verify(adapterListener, Mockito.times(1)).onBuild(Mockito.any(Builder.class));
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testSortDesc.
@Test
public void testSortDesc() {
for (int i = 0; i < 5; i++) {
Task task = new Task();
task.setId(Long.valueOf(i));
task.setName("task" + i);
taskRepo.create(task);
}
QuerySpec querySpec = new QuerySpec(Task.class);
querySpec.addSort(new SortSpec(Arrays.asList("name"), Direction.DESC));
List<Task> tasks = taskRepo.findAll(querySpec);
Assert.assertEquals(5, tasks.size());
for (int i = 0; i < 5; i++) {
Assert.assertEquals("task" + i, tasks.get(4 - i).getName());
}
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testSortAsc.
@Test
public void testSortAsc() {
for (int i = 0; i < 5; i++) {
Task task = new Task();
task.setId(Long.valueOf(i));
task.setName("task" + i);
taskRepo.create(task);
}
QuerySpec querySpec = new QuerySpec(Task.class);
querySpec.addSort(new SortSpec(Arrays.asList("name"), Direction.ASC));
List<Task> tasks = taskRepo.findAll(querySpec);
Assert.assertEquals(5, tasks.size());
for (int i = 0; i < 5; i++) {
Assert.assertEquals("task" + i, tasks.get(i).getName());
}
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testFindEmpty.
@Test
public void testFindEmpty() {
List<Task> tasks = taskRepo.findAll(new QuerySpec(Task.class));
Assert.assertTrue(tasks.isEmpty());
}
use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testDelete.
@Test
public void testDelete() {
Task task = new Task();
task.setId(1L);
task.setName("test");
taskRepo.create(task);
taskRepo.delete(1L);
List<Task> tasks = taskRepo.findAll(new QuerySpec(Task.class));
Assert.assertEquals(0, tasks.size());
}
Aggregations