We've used methods throughout the code to give it meaning. The old code was very hard to read because you had to read so many implementations.

You can definitely see the improvement in readability after refactoring.

The test was performed using the MetadataTransformerIT class.

Comment From: markpollack

I think this refactoring goes a bit too far for my taste, it decomposes it too much and passing around the index makes it more confusing. I've made a small change

        for (int i = 0; i < documentSummaries.size(); i++) {
            Map<String, Object> summaryMetadata = getSummaryMetadata(i, documentSummaries);
            documents.get(i).getMetadata().putAll(summaryMetadata);
        }

in this commit 7775a76f51267de6b102faf2d73556b730385600 as i think this helps with clarity.

Thanks for the PR and sorry it took so long to get around to it.