@Test
public void orderIsKept() {

    PDAnnotationSquareCircle one = new PDAnnotationSquareCircle(SUB_TYPE_SQUARE);
    one.setAnnotationName("one");
    PDAnnotationText two = new PDAnnotationText();
    two.setAnnotationName("two");
    PDAnnotationLine three = new PDAnnotationLine();
    three.setAnnotationName("three");
    PDAnnotationSquareCircle four = new PDAnnotationSquareCircle(SUB_TYPE_SQUARE);
    four.setAnnotationName("four");
    PDAnnotationLine five = new PDAnnotationLine();
    five.setAnnotationName("five");
    PDAnnotationSquareCircle six = new PDAnnotationSquareCircle(SUB_TYPE_SQUARE);
    six.setAnnotationName("six");
    List<PDAnnotation> annotations = Arrays.asList(one, two, three, four, five, six);
    oldPage.setAnnotations(annotations);
    PDDocument doc = new PDDocument();
    doc.addPage(oldPage);
    new AnnotationsDistiller(doc).retainRelevantAnnotations(lookup);
    List<PDAnnotation> annots = newPage.getAnnotations();
    assertEquals(6, annots.size());
    assertThat(annots.stream().map(PDAnnotation::getAnnotationName).collect(Collectors.toList()),
            Matchers.contains(annotations.stream().map(PDAnnotation::getAnnotationName)
                    .map(d -> Matchers.equalTo(d)).collect(Collectors.toList())));
}