LazyWorkflowTaskAssigneeList extends AbstractList<WorkflowTaskAssignee> { @Override public int size() { if (_workflowTaskAssignees != null) { return _workflowTaskAssignees.size(); } return _kaleoTaskAssignmentInstanceLocalService. getKaleoTaskAssignmentInstancesCount( _kaleoTaskInstanceToken.getKaleoTaskInstanceTokenId()); } LazyWorkflowTaskAssigneeList(
		KaleoTaskInstanceToken kaleoTaskInstanceToken,
		KaleoTaskAssignmentInstanceLocalService
			kaleoTaskAssignmentInstanceLocalService); @Override WorkflowTaskAssignee get(int index); @Override Iterator<WorkflowTaskAssignee> iterator(); @Override int size();  }
@Test public void testGetSizeWhenWorkflowTaskAssigneesIsNotLoaded() { long kaleoTaskInstanceTokenId = RandomTestUtil.randomLong(); KaleoTaskInstanceToken kaleoTaskInstanceToken = new KaleoTaskInstanceTokenWrapper( KaleoRuntimeTestUtil.mockKaleoTaskInstanceToken()) { @Override public long getKaleoTaskInstanceTokenId() { return kaleoTaskInstanceTokenId; } }; int kaleoTaskAssignmentInstancesCount = RandomTestUtil.randomInt(); KaleoTaskAssignmentInstanceLocalService kaleoTaskAssignmentInstanceLocalService = new KaleoTaskAssignmentInstanceLocalServiceWrapper(null) { @Override public int getKaleoTaskAssignmentInstancesCount( long kaleoTaskInstanceTokenId) { _executedMethodsNames.add( "getKaleoTaskAssignmentInstancesCount"); if (kaleoTaskInstanceTokenId == kaleoTaskInstanceToken. getKaleoTaskInstanceTokenId()) { return kaleoTaskAssignmentInstancesCount; } return -1; } }; LazyWorkflowTaskAssigneeList lazyWorkflowTaskAssigneeList = new LazyWorkflowTaskAssigneeList( kaleoTaskInstanceToken, kaleoTaskAssignmentInstanceLocalService); Assert.assertEquals( kaleoTaskAssignmentInstancesCount, lazyWorkflowTaskAssigneeList.size()); Assert.assertTrue( _executedMethodsNames.contains( "getKaleoTaskAssignmentInstancesCount")); }