DocumentCollectionVariableIndexer implements ProcessVariableIndexer { @Override public List<VariableInstanceLog> index(String name, Object variable) { DocumentCollection<? extends Document> documentCollection = (DocumentCollection<? extends Document>) variable; int max = documentCollection.getDocuments().size(); return IntStream.range(0, max) .mapToObj(index -> toVariableLog(name, index, max, documentCollection.getDocuments().get(index))) .collect(Collectors.toList()); }  @Override boolean accept(Object variable); @Override List<VariableInstanceLog> index(String name, Object variable);  }
@Test public void testIndexEmpty() { Assertions.assertThat(indexer.index(VARIABLE_NAME, new Documents())) .isEmpty(); }
@Test public void testIndex() { DocumentImpl doc1 = new DocumentImpl(DOC_1, DOC_1, 1024, new Date()); DocumentImpl doc2 = new DocumentImpl(DOC_2, DOC_3, 1024, new Date()); DocumentImpl doc3 = new DocumentImpl(DOC_3, DOC_3, 1024, new Date()); List<VariableInstanceLog> indexed = indexer.index(VARIABLE_NAME, new DocumentCollectionImpl(Arrays.asList(doc1, doc2, doc3))); Assertions.assertThat(indexed) .hasSize(3); testDocument(0, 3, indexed.get(0), doc1); testDocument(1, 3, indexed.get(1), doc2); testDocument(2, 3, indexed.get(2), doc3); }