Source:
protected void checkAvailabilityOfDocuments(List<String> expectedAvailableDocIds, Instant downloadableUntil, int totalBeingRetrieved) { try (CapturingEventListener listener = new CapturingEventListener( ColdStorageHelper.COLD_STORAGE_CONTENT_AVAILABLE_EVENT_NAME)) { ColdStorageHelper.ColdStorageContentStatus coldStorageContentStatus = ColdStorageHelper.checkColdStorageContentAvailability( session); assertEquals(totalBeingRetrieved, coldStorageContentStatus.getTotalBeingRetrieved()); assertEquals(expectedAvailableDocIds.size(), coldStorageContentStatus.getTotalAvailable()); assertTrue(listener.hasBeenFired(ColdStorageHelper.COLD_STORAGE_CONTENT_AVAILABLE_EVENT_NAME)); assertEquals(expectedAvailableDocIds.size(), listener.streamCapturedEvents().count()); List<String> docEventIds = listener.streamCapturedEvents() .map(event -> { DocumentEventContext docCtx = (DocumentEventContext) event.getContext(); return docCtx.getSourceDocument().getId(); }) .sorted() .collect(Collectors.toList()); expectedAvailableDocIds.sort(Comparator.naturalOrder()); assertEquals(expectedAvailableDocIds, docEventIds); listener.streamCapturedEvents().forEach(event -> { DocumentEventContext docCtx = (DocumentEventContext) event.getContext(); Map<String, Serializable> properties = docCtx.getProperties(); DocumentModel documentModel = session.getDocument(new IdRef(docCtx.getSourceDocument().getId())); assertEquals(String.format("An unexpected deadline for cold storage of document: %s", documentModel), downloadableUntil.toString(), properties.get(ColdStorageHelper.COLD_STORAGE_CONTENT_AVAILABLE_UNTIL_MAIL_TEMPLATE_KEY)); }); } }

Target:
protected void checkAvailabilityOfDocuments(List<String> expectedAvailableDocIds, Instant downloadableUntil, int totalBeingRetrieved) { try (CapturingEventListener listener = new CapturingEventListener( ColdStorageHelper.COLD_STORAGE_CONTENT_AVAILABLE_EVENT_NAME)) { ColdStorageHelper.ColdStorageContentStatus coldStorageContentStatus = ColdStorageHelper.checkColdStorageContentAvailability( session); assertEquals(totalBeingRetrieved, coldStorageContentStatus.getTotalBeingRetrieved()); var expectedSizeOfDocs = expectedAvailableDocIds.size(); assertEquals(expectedSizeOfDocs, coldStorageContentStatus.getTotalAvailable()); assertTrue(listener.hasBeenFired(ColdStorageHelper.COLD_STORAGE_CONTENT_AVAILABLE_EVENT_NAME)); assertEquals(expectedSizeOfDocs, listener.streamCapturedEvents().count()); List<String> docEventIds = listener.streamCapturedEvents() .map(event -> { DocumentEventContext docCtx = (DocumentEventContext) event.getContext(); return docCtx.getSourceDocument().getId(); }) .sorted() .collect(Collectors.toList()); expectedAvailableDocIds.sort(Comparator.naturalOrder()); assertEquals(expectedAvailableDocIds, docEventIds); listener.streamCapturedEvents().forEach(event -> { DocumentEventContext docCtx = (DocumentEventContext) event.getContext(); Map<String, Serializable> properties = docCtx.getProperties(); DocumentModel documentModel = session.getDocument(new IdRef(docCtx.getSourceDocument().getId())); assertEquals(String.format("An unexpected deadline for cold storage of document: %s", documentModel), downloadableUntil.toString(), properties.get(ColdStorageHelper.COLD_STORAGE_CONTENT_AVAILABLE_UNTIL_MAIL_TEMPLATE_KEY)); String expectedDownloadUrl = downloadService.getDownloadUrl(documentModel, ColdStorageHelper.COLD_STORAGE_CONTENT_PROPERTY, null); assertEquals(String.format("An unexpected downloadable url for document: %s", documentModel), expectedDownloadUrl, properties.get(ColdStorageHelper.COLD_STORAGE_CONTENT_ARCHIVE_LOCATION_MAIL_TEMPLATE_KEY)); }); } }