public static EntitySelector mockEntitySelector(
     EntityDescriptor entityDescriptor, Object... entities) {
   EntitySelector entitySelector = mock(EntitySelector.class);
   when(entitySelector.getEntityDescriptor()).thenReturn(entityDescriptor);
   final List<Object> entityList = Arrays.<Object>asList(entities);
   when(entitySelector.iterator())
       .thenAnswer(
           new Answer<Iterator<Object>>() {
             @Override
             public Iterator<Object> answer(InvocationOnMock invocation) throws Throwable {
               return entityList.iterator();
             }
           });
   when(entitySelector.listIterator())
       .thenAnswer(
           new Answer<ListIterator<Object>>() {
             @Override
             public ListIterator<Object> answer(InvocationOnMock invocation) throws Throwable {
               return entityList.listIterator();
             }
           });
   for (int i = 0; i < entityList.size(); i++) {
     final int index = i;
     when(entitySelector.listIterator(index))
         .thenAnswer(
             new Answer<ListIterator<Object>>() {
               @Override
               public ListIterator<Object> answer(InvocationOnMock invocation) throws Throwable {
                 return entityList.listIterator(index);
               }
             });
   }
   when(entitySelector.endingIterator())
       .thenAnswer(
           new Answer<Iterator<Object>>() {
             @Override
             public Iterator<Object> answer(InvocationOnMock invocation) throws Throwable {
               return entityList.iterator();
             }
           });
   when(entitySelector.isCountable()).thenReturn(true);
   when(entitySelector.isNeverEnding()).thenReturn(false);
   when(entitySelector.getSize()).thenReturn((long) entityList.size());
   return entitySelector;
 }
 public boolean isNeverEnding() {
   return randomSelection
       || leftEntitySelector.isNeverEnding()
       || rightEntitySelector.isNeverEnding();
 }