use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class BasicProxyFactoryTest method testWrappedCollectionProxy.
@Test
public void testWrappedCollectionProxy() {
Collection<Schedule> col = factory.createCollectionProxy(Schedule.class, ScheduleRepository.ScheduleList.class, "http://127.0.0.1:99999");
Assert.assertTrue(col instanceof ScheduleRepository.ScheduleList);
ScheduleRepository.ScheduleList list = (ScheduleRepository.ScheduleList) col;
Assert.assertTrue(list.getWrappedList() instanceof ObjectProxy);
ObjectProxy proxy = (ObjectProxy) list.getWrappedList();
Assert.assertFalse(proxy.isLoaded());
Assert.assertEquals("http://127.0.0.1:99999", proxy.getUrl());
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class BasicActionTest method testCrudFind.
@Test
public void testCrudFind() {
Schedule schedule = new Schedule();
schedule.setId(1L);
schedule.setName("schedule");
scheduleRepo.create(schedule);
Iterable<Schedule> schedules = scheduleRepo.findAll(new QuerySpec(Schedule.class));
schedule = schedules.iterator().next();
Assert.assertEquals("schedule", schedule.getName());
scheduleRepo.delete(schedule.getId());
schedules = scheduleRepo.findAll(new QuerySpec(Schedule.class));
Assert.assertFalse(schedules.iterator().hasNext());
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class AbstractProxiedObjectsClientTest method noProxyForLazy.
@Test
public void noProxyForLazy() {
Schedule schedule = new Schedule();
schedule.setId(1L);
schedule.setName("project");
scheduleRepo.create(schedule);
Task task = new Task();
task.setId(2L);
task.setName("test");
taskRepo.create(task);
scheduleTaskRepo.setRelation(schedule, task.getId(), "lazyTask");
QuerySpec querySpec = new QuerySpec(Task.class);
schedule = scheduleRepo.findOne(1L, querySpec);
Task proxiedObject = schedule.getLazyTask();
Assert.assertNull(proxiedObject);
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class AbstractProxiedObjectsClientTest method saveDoesNotTriggerLazyLoad.
@Test
public void saveDoesNotTriggerLazyLoad() {
Schedule schedule = new Schedule();
schedule.setId(1L);
schedule.setName("project");
scheduleRepo.create(schedule);
QuerySpec querySpec = new QuerySpec(Schedule.class);
schedule = scheduleRepo.findOne(1L, querySpec);
Collection<Task> proxiedTasks = schedule.getTasks();
ObjectProxy proxy = (ObjectProxy) proxiedTasks;
Assert.assertFalse(proxy.isLoaded());
// update primitive field
schedule.setName("newValue");
scheduleRepo.save(schedule);
// save should not trigger a load of the relation
Assert.assertFalse(proxy.isLoaded());
Assert.assertSame(proxy, schedule.getTasks());
// data should be saved
schedule = scheduleRepo.findOne(1L, querySpec);
Assert.assertEquals("newValue", schedule.getName());
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class RestTemplateClientTest method testCreate.
@Test
public void testCreate() {
ScheduleRepository scheduleRepository = client.getRepositoryForInterface(ScheduleRepository.class);
Schedule schedule = new Schedule();
schedule.setName("mySchedule");
scheduleRepository.create(schedule);
QuerySpec querySpec = new QuerySpec(Schedule.class);
ScheduleRepository.ScheduleList list = scheduleRepository.findAll(querySpec);
Assert.assertEquals(1, list.size());
schedule = list.get(0);
Assert.assertNotNull(schedule.getId());
ScheduleRepository.ScheduleListMeta meta = list.getMeta();
ScheduleRepository.ScheduleListLinks links = list.getLinks();
Assert.assertNotNull(meta);
Assert.assertNotNull(links);
}
Aggregations