Search in sources :

Example 11 with Schedule

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

the class RelationIdClientTest method checkPost.

private Schedule checkPost() {
    project = new Project();
    project.setName("myProject");
    project = projectRepo.create(project);
    Schedule schedule = new Schedule();
    schedule.setId(1L);
    schedule.setName("mySchedule");
    schedule.setProjectId(project.getId());
    schedule.setProjectIds(Arrays.asList(project.getId()));
    Schedule savedSchedule = scheduleRepo.create(schedule);
    Schedule serverSchedule = ScheduleRepositoryImpl.schedules.get(1L);
    Assert.assertEquals(project.getId(), serverSchedule.getProjectId());
    Assert.assertEquals(1, serverSchedule.getProjectIds().size());
    Assert.assertEquals(project.getId(), serverSchedule.getProjectIds().get(0));
    Assert.assertNull(serverSchedule.getProject());
    Assert.assertNotSame(schedule, savedSchedule);
    Assert.assertEquals(project.getId(), savedSchedule.getProjectId());
    Assert.assertEquals(1, savedSchedule.getProjectIds().size());
    return savedSchedule;
}
Also used : Project(io.crnk.test.mock.models.Project) Schedule(io.crnk.test.mock.models.Schedule)

Example 12 with Schedule

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

the class RelationIdClientTest method checkFindWithoutInclusion.

private void checkFindWithoutInclusion(Schedule schedule) {
    QuerySpec querySpec = new QuerySpec(Schedule.class);
    Schedule foundSchedule = scheduleRepo.findOne(schedule.getId(), querySpec);
    Assert.assertEquals(project.getId(), foundSchedule.getProjectId());
    Assert.assertNull(foundSchedule.getProject());
    Assert.assertEquals(1, foundSchedule.getProjectIds().size());
    Assert.assertEquals(project.getId(), foundSchedule.getProjectIds().get(0));
    Assert.assertNotNull(foundSchedule.getProjects());
    // TODO list should contain proxies in the future
    List<Project> projects = foundSchedule.getProjects();
    Assert.assertEquals(1, projects.size());
    // not initialized, id-only
    Assert.assertNull(projects.get(0).getName());
}
Also used : Project(io.crnk.test.mock.models.Project) Schedule(io.crnk.test.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 13 with Schedule

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

the class RelationIdClientTest method checkFindWithInclusion.

private void checkFindWithInclusion(Schedule schedule) {
    QuerySpec querySpec = new QuerySpec(Schedule.class);
    querySpec.includeRelation(Arrays.asList("project"));
    querySpec.includeRelation(Arrays.asList("projects"));
    Schedule foundSchedule = scheduleRepo.findOne(schedule.getId(), querySpec);
    Assert.assertEquals(project.getId(), foundSchedule.getProjectId());
    Assert.assertNotNull(foundSchedule.getProject());
    Assert.assertEquals(project.getId(), foundSchedule.getProject().getId());
    Assert.assertEquals(1, foundSchedule.getProjectIds().size());
    Assert.assertEquals(1, foundSchedule.getProjects().size());
    Assert.assertEquals(project.getId(), foundSchedule.getProjectIds().get(0));
    Assert.assertEquals(project.getId(), foundSchedule.getProjects().get(0).getId());
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 14 with Schedule

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

the class JsonApiActionResponseTest method testCrudFind.

@Test
public void testCrudFind() {
    Schedule schedule = new Schedule();
    schedule.setId(1L);
    schedule.setName("schedule");
    scheduleRepository.create(schedule);
    Iterable<Schedule> schedules = scheduleRepository.findAll(new QuerySpec(Schedule.class));
    schedule = schedules.iterator().next();
    Assert.assertEquals("schedule", schedule.getName());
    scheduleRepository.delete(schedule.getId());
    schedules = scheduleRepository.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 15 with Schedule

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

the class JsonApiActionResponseTest method testInvokeResourceAction.

@Test
public void testInvokeResourceAction() {
    Schedule schedule = new Schedule();
    schedule.setId(1L);
    schedule.setName("scheduleName");
    scheduleRepository.create(schedule);
    String result = scheduleRepository.resourceAction(1, "hello");
    Assert.assertEquals("{\"data\":\"resource action: hello@scheduleName\"}", result);
    // check filters
    ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
    Mockito.verify(filter, Mockito.times(2)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
    DocumentFilterContext actionContext = contexts.getAllValues().get(1);
    Assert.assertEquals("GET", actionContext.getMethod());
    Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
Also used : DocumentFilterContext(io.crnk.core.engine.filter.DocumentFilterContext) Schedule(io.crnk.test.mock.models.Schedule) DocumentFilterChain(io.crnk.core.engine.filter.DocumentFilterChain) ActionPath(io.crnk.core.engine.internal.dispatcher.path.ActionPath) Test(org.junit.Test) AbstractClientTest(io.crnk.client.AbstractClientTest)

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