S3DownloadService implements DownloadService { void checkPublishedAnalysisState(MetadataEntity entity){ if(!useLegacyMode){ val objectId = entity.getId(); val analysisState = metadataService.getAnalysisStateForMetadata(entity); if (!analysisState.equals(PUBLISHED_ANALYSIS_STATE)){ val message = String.format("Critical Error: cannot complete download for objectId '%s' with " + "analysisState '%s' and analysisId '%s'. " + "Can only download objects that have the analysisState '%s' or when the 'exclude-urls=true' flag is set. Update the file metadata or url parameters and retry.", objectId, analysisState, getAnalysisId(entity), PUBLISHED_ANALYSIS_STATE); log.error(message); throw new NotRetryableException(new IllegalStateException(message)); } } }  @Override ObjectSpecification download(String objectId, long offset, long length, boolean forExternalUse, boolean excludeUrls); ObjectSpecification getSpecification(String objectId); @Override String getSentinelObject();  }
@Test public void test_if_unpublished_file_triggers_error() { val throwable = catchThrowable(() -> s3DownloadService.checkPublishedAnalysisState(metadataEntity)); assertThat(throwable) .hasMessageContaining( format("Critical Error: cannot complete download for objectId '%s' with ", objectId)); }