@Test public void createForProcessOverviewShouldAddCorrectAuthorizations() throws Exception { doReturn("clave") .when(formMappingKeyGenerator) .generateKey(PROCESS_DEFINITION_ID, null, FormMappingType.PROCESS_OVERVIEW.getId()); formMappingService.create( PROCESS_DEFINITION_ID, null, FormMappingType.PROCESS_OVERVIEW.getId(), SFormMapping.TARGET_URL, null); verify(pageMappingService) .create( "clave", null, EXTERNAL, Arrays.asList( IS_ADMIN, IS_PROCESS_OWNER, IS_PROCESS_INITIATOR, IS_TASK_PERFORMER, IS_INVOLVED_IN_PROCESS_INSTANCE)); }
@Test public void createWithInternalPageShouldCallPageMapping_create() throws Exception { doReturn("theKey").when(formMappingKeyGenerator).generateKey(PROCESS_DEFINITION_ID, "step1", 2); formMappingService.create( PROCESS_DEFINITION_ID, "step1", 2, SFormMapping.TARGET_INTERNAL, null); verify(pageMappingService).create(eq("theKey"), isNull(Long.class), anyList()); }
@Test public void createFormMappingWithUndefinedTargetShouldNotAddPageMapping() throws Exception { doReturn("mockedKey") .when(formMappingKeyGenerator) .generateKey(PROCESS_DEFINITION_ID, "someHumanTask", 84); formMappingService.create( PROCESS_DEFINITION_ID, "someHumanTask", 84, SFormMapping.TARGET_UNDEFINED, null); verifyZeroInteractions(pageMappingService); }
@Test public void createLegacyFormShouldNotAddCorrectAuthorizations() throws Exception { doReturn("keye") .when(formMappingKeyGenerator) .generateKey(PROCESS_DEFINITION_ID, null, FormMappingType.PROCESS_START.getId()); formMappingService.create( PROCESS_DEFINITION_ID, null, FormMappingType.PROCESS_START.getId(), SFormMapping.TARGET_LEGACY, null); verify(pageMappingService).create("keye", null, LEGACY, null); }
@Test public void createForProcessStartShouldAddCorrectAuthorizations() throws Exception { doReturn("keye") .when(formMappingKeyGenerator) .generateKey(PROCESS_DEFINITION_ID, null, FormMappingType.PROCESS_START.getId()); formMappingService.create( PROCESS_DEFINITION_ID, null, FormMappingType.PROCESS_START.getId(), SFormMapping.TARGET_URL, null); verify(pageMappingService) .create( "keye", null, EXTERNAL, Arrays.asList(IS_ADMIN, IS_PROCESS_OWNER, IS_ACTOR_INITIATOR)); }
@Test public void createForTaskShouldAddCorrectAuthorizations() throws Exception { doReturn("clef") .when(formMappingKeyGenerator) .generateKey(PROCESS_DEFINITION_ID, "task", FormMappingType.TASK.getId()); formMappingService.create( PROCESS_DEFINITION_ID, "task", FormMappingType.TASK.getId(), SFormMapping.TARGET_INTERNAL, null); verify(pageMappingService) .create( "clef", null, Arrays.asList(IS_ADMIN, IS_PROCESS_OWNER, IS_TASK_AVAILABLE_FOR_USER)); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithNullTarget() throws Exception { formMappingService.create(1654L, "step1", 1, null, null); }