use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class ScheduleRepositoryImpl method copyResources.
private List<Schedule> copyResources(Collection<Schedule> values) {
ArrayList<Schedule> copiedList = new ArrayList<>();
for (Schedule schedule : values) {
Schedule copy = new Schedule();
copy.setId(schedule.getId());
copy.setName(schedule.getName());
copy.setTasks(schedule.getTasks());
copy.setDelayed(schedule.isDelayed());
copy.setLazyTask(schedule.getLazyTask());
copy.setTasksList(schedule.getTasksList());
if (schedule.getProject() != null) {
copy.setProject(schedule.getProject());
} else {
copy.setProjectId(schedule.getProjectId());
}
if (schedule.getProjects() != null) {
copy.setProjects(schedule.getProjects());
} else {
copy.setProjectIds(schedule.getProjectIds());
}
copy.setTask(schedule.getTask());
copiedList.add(copy);
}
return copiedList;
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class ApprovalManagerTest method checkApprovedForwardsToRepository.
@Test
public void checkApprovedForwardsToRepository() {
Map processVariable = new HashMap();
processVariable.put("resourceId", mockId.toString());
processVariable.put("resourceType", "schedule");
processVariable.put("newValues.name", "John");
processVariable.put("previousValues.name", "Jane");
Mockito.when(runtimeService.getVariables(Mockito.anyString())).thenReturn(processVariable);
Execution execution = Mockito.mock(Execution.class);
manager.approved(execution);
ArgumentCaptor<Object> savedEntityCaptor = ArgumentCaptor.forClass(Object.class);
Mockito.verify(repositoryFacade, Mockito.times(1)).save(savedEntityCaptor.capture());
System.out.println(savedEntityCaptor.getValue());
// check value updated on original resource
Schedule savedEntity = (Schedule) savedEntityCaptor.getValue();
Assert.assertSame(originalResource, savedEntity);
Assert.assertEquals("John", savedEntity.getName());
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class ApprovalTestApplication method createApprovalModule.
// tag::approvalModule[]
public static SimpleModule createApprovalModule(ApprovalManager approvalManager) {
FilterSpec approvalFilter = new FilterSpec(Arrays.asList("definitionKey"), FilterOperator.EQ, "scheduleChange");
List<FilterSpec> approvalFilters = Arrays.asList(approvalFilter);
SimpleModule module = new SimpleModule("approval");
module.addRepositoryDecoratorFactory(ApprovalRepositoryDecorator.createFactory(approvalManager));
module.addRepository(new ApprovalRelationshipRepository(Schedule.class, ScheduleApprovalProcessInstance.class, "approval", "approval/schedule", approvalFilters));
return module;
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testSaveRelationWithCreate.
@Test
public void testSaveRelationWithCreate() {
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);
// check relationship available
Task savedTask = taskRepo.findOne(task.getId(), new QuerySpec(Task.class));
Assert.assertNotNull(savedTask.getSchedule());
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testSetRelation.
@Test
public void testSetRelation() {
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);
relRepo.setRelation(task, schedule.getId(), "schedule");
Schedule relSchedule = taskScheduleRepo.findOneTarget(task.getId(), "schedule", new QuerySpec(Schedule.class));
Assert.assertNotNull(relSchedule);
Assert.assertEquals(schedule.getId(), relSchedule.getId());
}
Aggregations