Search in sources :

Example 16 with Schedule

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());
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ScheduleRepository(io.crnk.test.mock.repository.ScheduleRepository) ObjectProxy(io.crnk.client.internal.proxy.ObjectProxy) Test(org.junit.Test)

Example 17 with Schedule

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());
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test) AbstractClientTest(io.crnk.client.AbstractClientTest)

Example 18 with Schedule

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);
}
Also used : Task(io.crnk.test.mock.models.Task) Schedule(io.crnk.test.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 19 with Schedule

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());
}
Also used : Task(io.crnk.test.mock.models.Task) Schedule(io.crnk.test.mock.models.Schedule) ObjectProxy(io.crnk.client.internal.proxy.ObjectProxy) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 20 with Schedule

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);
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ScheduleRepository(io.crnk.test.mock.repository.ScheduleRepository) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Schedule (io.crnk.test.mock.models.Schedule)37 Test (org.junit.Test)24 QuerySpec (io.crnk.core.queryspec.QuerySpec)21 Task (io.crnk.test.mock.models.Task)10 ScheduleRepository (io.crnk.test.mock.repository.ScheduleRepository)5 AbstractClientTest (io.crnk.client.AbstractClientTest)4 ObjectProxy (io.crnk.client.internal.proxy.ObjectProxy)4 Project (io.crnk.test.mock.models.Project)3 DocumentFilterChain (io.crnk.core.engine.filter.DocumentFilterChain)2 DocumentFilterContext (io.crnk.core.engine.filter.DocumentFilterContext)2 ActionPath (io.crnk.core.engine.internal.dispatcher.path.ActionPath)2 ScheduleList (io.crnk.test.mock.repository.ScheduleRepository.ScheduleList)2 ScheduleListLinks (io.crnk.test.mock.repository.ScheduleRepository.ScheduleListLinks)2 ScheduleListMeta (io.crnk.test.mock.repository.ScheduleRepository.ScheduleListMeta)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ApprovalManager (io.crnk.activiti.example.approval.ApprovalManager)1 ApprovalMapper (io.crnk.activiti.example.approval.ApprovalMapper)1 ApprovalRelationshipRepository (io.crnk.activiti.example.approval.ApprovalRelationshipRepository)1 ApproveTask (io.crnk.activiti.example.model.ApproveTask)1