private void checkVersions(DocumentModel doc, String... labels) {
   List<String> actual = new LinkedList<String>();
   for (DocumentModel ver : session.getVersions(doc.getRef())) {
     assertTrue(ver.isVersion());
     actual.add(ver.getVersionLabel());
   }
   // build a debug list of versions and creation times
   // in case of failure
   StringBuilder buf = new StringBuilder("version time: ");
   for (VersionModel vm : session.getVersionsForDocument(doc.getRef())) {
     buf.append(vm.getLabel());
     buf.append("=");
     buf.append(vm.getCreated().getTimeInMillis());
     buf.append(", ");
   }
   buf.setLength(buf.length() - 2);
   assertEquals(buf.toString(), Arrays.asList(labels), actual);
   List<DocumentRef> versionsRefs = session.getVersionsRefs(doc.getRef());
   assertEquals(labels.length, versionsRefs.size());
 }