use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class ApprovalManagerTest method checkRequestApproval.
@Test
public void checkRequestApproval() {
Schedule changedEntity = new Schedule();
changedEntity.setId(mockId);
changedEntity.setName("John");
Assert.assertFalse(manager.needsApproval(changedEntity, HttpMethod.POST));
Assert.assertTrue(manager.needsApproval(changedEntity, HttpMethod.PATCH));
manager.requestApproval(changedEntity, HttpMethod.PATCH);
ArgumentCaptor<Map> processVariablesCaptor = ArgumentCaptor.forClass(Map.class);
Mockito.verify(runtimeService, Mockito.times(1)).startProcessInstanceByKey(Mockito.eq("scheduleChange"), processVariablesCaptor.capture());
Map processVariables = processVariablesCaptor.getValue();
Assert.assertEquals(4, processVariables.size());
Assert.assertEquals(mockId.toString(), processVariables.get("resourceId"));
Assert.assertEquals("schedule", processVariables.get("resourceType"));
Assert.assertEquals("John", processVariables.get("newValues.name"));
Assert.assertEquals("Jane", processVariables.get("previousValues.name"));
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class ApprovalManagerTest method setup.
@Before
public void setup() {
runtimeService = Mockito.mock(RuntimeService.class);
TaskService taskService = Mockito.mock(TaskService.class);
repositoryFacade = Mockito.mock(ResourceRepositoryV2.class);
ApprovalMapper approvalMapper = new ApprovalMapper();
ActivitiResourceMapper resourceMapper = new ActivitiResourceMapper(new TypeParser(), new DefaultDateTimeMapper());
ResourceInformation information = Mockito.mock(ResourceInformation.class);
registryEntry = Mockito.mock(RegistryEntry.class);
ResourceRegistry resourceRegistry = Mockito.mock(ResourceRegistry.class);
Mockito.when(registryEntry.getResourceInformation()).thenReturn(information);
Mockito.when(registryEntry.getResourceRepositoryFacade()).thenReturn(repositoryFacade);
Mockito.when(information.getResourceType()).thenReturn("schedule");
Mockito.when(information.getId(Mockito.any())).thenReturn(mockId);
Mockito.when(resourceRegistry.getEntry(Mockito.any(Class.class))).thenReturn(registryEntry);
Mockito.when(resourceRegistry.getEntry(Mockito.any(String.class))).thenReturn(registryEntry);
ModuleRegistry moduleRegistry = Mockito.mock(ModuleRegistry.class);
Mockito.when(moduleRegistry.getResourceRegistry()).thenReturn(resourceRegistry);
originalResource = new Schedule();
originalResource.setId(mockId);
originalResource.setName("Jane");
Mockito.when(repositoryFacade.findOne(Mockito.any(Long.class), Mockito.any(QuerySpec.class))).thenReturn(originalResource);
manager = new ApprovalManager();
manager.init(runtimeService, taskService, resourceMapper, approvalMapper, moduleRegistry);
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class ScheduleRepositoryImpl method repositoryActionWithResourceResult.
@Override
public Schedule repositoryActionWithResourceResult(String msg) {
Schedule schedule = new Schedule();
schedule.setId(1L);
schedule.setName(msg);
return schedule;
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class BasicActionTest method testInvokeResourceAction.
@Test
public void testInvokeResourceAction() {
Schedule schedule = new Schedule();
schedule.setId(1L);
schedule.setName("scheduleName");
scheduleRepo.create(schedule);
String result = scheduleRepo.resourceAction(1, "hello");
Assert.assertEquals("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);
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class QuerySpecClientTest method testCreate.
@Test
public void testCreate() {
ScheduleRepository scheduleRepository = client.getResourceRepository(ScheduleRepository.class);
Schedule schedule = new Schedule();
schedule.setName("mySchedule");
scheduleRepository.create(schedule);
QuerySpec querySpec = new QuerySpec(Schedule.class);
ScheduleList list = scheduleRepository.findAll(querySpec);
Assert.assertEquals(1, list.size());
schedule = list.get(0);
Assert.assertNotNull(schedule.getId());
ScheduleListMeta meta = list.getMeta();
ScheduleListLinks links = list.getLinks();
Assert.assertNotNull(meta);
Assert.assertNotNull(links);
}
Aggregations