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;
}
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());
}
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());
}
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());
}
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);
}
Aggregations