Search in sources :

Example 6 with Schedule

use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.

the class QuerySpecClientTest method testNullNonLazyRelationWithSave.

@Test
public void testNullNonLazyRelationWithSave() {
    Schedule schedule = new Schedule();
    schedule.setId(1L);
    schedule.setName("schedule");
    scheduleRepo.create(schedule);
    Task task = new Task();
    task.setId(2L);
    task.setName("test");
    task.setSchedule(schedule);
    taskRepo.create(task);
    Task savedTask = taskRepo.findOne(task.getId(), new QuerySpec(Task.class));
    Assert.assertNotNull(savedTask.getSchedule());
    // null
    savedTask.setSchedule(null);
    taskRepo.save(savedTask);
    // relation must be null
    Task updatedTask = taskRepo.findOne(task.getId(), new QuerySpec(Task.class));
    Assert.assertNull(updatedTask.getSchedule());
}
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 7 with Schedule

use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.

the class QuerySpecClientTest method testInterfaceAccess.

@Test
public void testInterfaceAccess() {
    // tag::interfaceAccess[]
    ScheduleRepository scheduleRepository = client.getResourceRepository(ScheduleRepository.class);
    Schedule schedule = new Schedule();
    schedule.setId(13L);
    schedule.setName("mySchedule");
    scheduleRepository.create(schedule);
    QuerySpec querySpec = new QuerySpec(Schedule.class);
    ScheduleList list = scheduleRepository.findAll(querySpec);
    Assert.assertEquals(1, list.size());
    ScheduleListMeta meta = list.getMeta();
    ScheduleListLinks links = list.getLinks();
    Assert.assertNotNull(meta);
    Assert.assertNotNull(links);
// end::interfaceAccess[]
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ScheduleRepository(io.crnk.test.mock.repository.ScheduleRepository) ScheduleListMeta(io.crnk.test.mock.repository.ScheduleRepository.ScheduleListMeta) ScheduleList(io.crnk.test.mock.repository.ScheduleRepository.ScheduleList) ScheduleListLinks(io.crnk.test.mock.repository.ScheduleRepository.ScheduleListLinks) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 8 with Schedule

use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.

the class QuerySpecClientTest method testSaveRelationWithSave.

@Test
public void testSaveRelationWithSave() {
    Schedule schedule = new Schedule();
    schedule.setId(1L);
    schedule.setName("schedule");
    scheduleRepo.create(schedule);
    Task task = new Task();
    task.setId(2L);
    task.setName("test");
    taskRepo.create(task);
    Task createdTask = taskRepo.findOne(task.getId(), new QuerySpec(Task.class));
    Assert.assertNull(createdTask.getSchedule());
    createdTask.setSchedule(schedule);
    taskRepo.save(createdTask);
    Task updatedTask = taskRepo.findOne(task.getId(), new QuerySpec(Task.class));
    Assert.assertNotNull(updatedTask.getSchedule());
}
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 9 with Schedule

use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.

the class QuerySpecClientTest method testCannotNullLazyRelationWithSave.

@Test
public void testCannotNullLazyRelationWithSave() {
    Task task = new Task();
    task.setId(2L);
    task.setName("test");
    taskRepo.create(task);
    Schedule schedule = new Schedule();
    schedule.setId(1L);
    schedule.setName("schedule");
    schedule.setLazyTask(task);
    scheduleRepo.create(schedule);
    // since lazy, will not be sent to client if not requested
    QuerySpec querySpec = new QuerySpec(Schedule.class);
    Schedule savedSchedule = scheduleRepo.findOne(schedule.getId(), querySpec);
    Assert.assertNull(savedSchedule.getLazyTask());
    querySpec.includeRelation(Arrays.asList("lazyTask"));
    savedSchedule = scheduleRepo.findOne(schedule.getId(), querySpec);
    Assert.assertNotNull(savedSchedule.getLazyTask());
    // null
    savedSchedule.setLazyTask(task);
    scheduleRepo.save(savedSchedule);
    // still not null because cannot differantiate between not loaded and
    // nulled
    Schedule updatedSchedule = scheduleRepo.findOne(schedule.getId(), querySpec);
    Assert.assertNotNull(updatedSchedule.getLazyTask());
}
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 10 with Schedule

use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.

the class RelationIdClientTest method checkCrud.

@Test
public void checkCrud() {
    Schedule schedule = checkPost();
    checkFindWithoutInclusion(schedule);
    checkFindWithInclusion(schedule);
    schedule = checkPatch(schedule);
    checkPatchRelationship(schedule);
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) Test(org.junit.Test)

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