Search in sources :

Example 1 with Schedule

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;
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ArrayList(java.util.ArrayList)

Example 2 with Schedule

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());
}
Also used : Execution(org.activiti.engine.runtime.Execution) HashMap(java.util.HashMap) Schedule(io.crnk.test.mock.models.Schedule) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with Schedule

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;
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) ApprovalRelationshipRepository(io.crnk.activiti.example.approval.ApprovalRelationshipRepository) FilterSpec(io.crnk.core.queryspec.FilterSpec) SimpleModule(io.crnk.core.module.SimpleModule)

Example 4 with Schedule

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());
}
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 5 with Schedule

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

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