LazyWorkflowTaskAssigneeList extends AbstractList<WorkflowTaskAssignee> { @Override public WorkflowTaskAssignee get(int index) { if (index == 0) { Optional<WorkflowTaskAssignee> workflowTaskAssigneeOptional = _firstWorkflowTaskAssigneeSupplier.get(); return workflowTaskAssigneeOptional.orElseThrow( IndexOutOfBoundsException::new); } initWorkflowTaskAssignees(); return _workflowTaskAssignees.get(index); } LazyWorkflowTaskAssigneeList(
		KaleoTaskInstanceToken kaleoTaskInstanceToken,
		KaleoTaskAssignmentInstanceLocalService
			kaleoTaskAssignmentInstanceLocalService); @Override WorkflowTaskAssignee get(int index); @Override Iterator<WorkflowTaskAssignee> iterator(); @Override int size();  }
@Test public void testGetWhenIndexIsGreaterThanZero() { KaleoTaskInstanceToken kaleoTaskInstanceToken = _getKaleoTaskInstanceToken( KaleoRuntimeTestUtil.mockKaleoTaskAssignmentInstance( Role.class.getName(), 1), KaleoRuntimeTestUtil.mockKaleoTaskAssignmentInstance( User.class.getName(), 2)); LazyWorkflowTaskAssigneeList lazyWorkflowTaskAssigneeList = new LazyWorkflowTaskAssigneeList(kaleoTaskInstanceToken, null); KaleoRuntimeTestUtil.assertWorkflowTaskAssignee( User.class.getName(), 2, lazyWorkflowTaskAssigneeList.get(1)); Assert.assertFalse( _executedMethodsNames.contains( "getFirstKaleoTaskAssignmentInstance")); Assert.assertTrue( _executedMethodsNames.contains("getKaleoTaskAssignmentInstances")); }
@Test public void testGetWhenIndexIsZeroAndAssignmentIsNotNull() { String assigneeClassName = StringUtil.randomString(); long assigneeClassPK = RandomTestUtil.randomLong(); KaleoTaskInstanceToken kaleoTaskInstanceToken = _getKaleoTaskInstanceToken( KaleoRuntimeTestUtil.mockKaleoTaskAssignmentInstance( assigneeClassName, assigneeClassPK)); LazyWorkflowTaskAssigneeList lazyWorkflowTaskAssigneeList = new LazyWorkflowTaskAssigneeList(kaleoTaskInstanceToken, null); KaleoRuntimeTestUtil.assertWorkflowTaskAssignee( assigneeClassName, assigneeClassPK, lazyWorkflowTaskAssigneeList.get(0)); Assert.assertTrue( _executedMethodsNames.contains( "getFirstKaleoTaskAssignmentInstance")); Assert.assertFalse( _executedMethodsNames.contains("getKaleoTaskAssignmentInstances")); }
@Test(expected = IndexOutOfBoundsException.class) public void testGetWhenIndexIsZeroAndAssignmentIsNull() { KaleoTaskInstanceToken kaleoTaskInstanceToken = KaleoRuntimeTestUtil.mockKaleoTaskInstanceToken(); LazyWorkflowTaskAssigneeList lazyWorkflowTaskAssigneeList = new LazyWorkflowTaskAssigneeList(kaleoTaskInstanceToken, null); lazyWorkflowTaskAssigneeList.get(0); }