@Test(expected = SExecutionException.class) public void shouldThrowSExecutionExceptionIfExceptionOccurs() throws Exception { Map<String, Serializable> context = buildContext(256L, null); doThrow(SBonitaReadException.class) .when(activityInstanceService) .searchArchivedTasks(any(QueryOptions.class)); rule.isAllowed("exception raised", context); }
@Test public void shouldNotBeAllowedIfNoArchivedTasks() throws Exception { final long processInstanceId = 541L; Map<String, Serializable> context = buildContext(processInstanceId, null); doReturn(Collections.emptyList()) .when(activityInstanceService) .searchArchivedTasks(any(QueryOptions.class)); final boolean allowed = rule.isAllowed("someKey", context); assertThat(allowed).isFalse(); }
@Test public void shouldBeAllowedIAnArchivedTaskIsAssignedToGivenUser() throws Exception { Map<String, Serializable> context = buildContext(541L, null); final SAUserTaskInstance userTaskInstance = mock(SAUserTaskInstance.class); doReturn(loggedUserId).when(userTaskInstance).getAssigneeId(); doReturn(Arrays.asList(userTaskInstance)) .when(activityInstanceService) .searchArchivedTasks(any(QueryOptions.class)); final boolean allowed = rule.isAllowed("someKey", context); assertThat(allowed).isTrue(); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowIllegalArgumentIfProcessInstanceIdParamNotPresent() throws Exception { Map<String, Serializable> context = buildContext(null, 7L); rule.isAllowed("betje", context); }