ManifestManager { @Transactional public ImportRecord importStoredManifest(Owner targetOwner, String fileId, ConflictOverrides overrides, String uploadedFileName) throws BadRequestException, ImporterException { ManifestFile manifest = manifestFileService.get(fileId); if (manifest == null) { throw new BadRequestException(i18n.tr("The requested manifest file was not found: {0}", fileId)); } ImportRecord importResult = importer.loadStoredExport(manifest, targetOwner, overrides, uploadedFileName); deleteStoredManifest(manifest.getId()); return importResult; } @Inject  ManifestManager(ManifestFileService manifestFileService, Exporter exporter, Importer importer,
        ConsumerCurator consumerCurator, ConsumerTypeCurator consumerTypeCurator,
        EntitlementCurator entitlementCurator, CdnCurator cdnCurator, PoolManager poolManager,
        PrincipalProvider principalProvider, I18n i18n, EventSink eventSink, EventFactory eventFactory); JobConfig generateManifestAsync(String consumerUuid, Owner owner, String cdnLabel,
        String webUrl, String apiUrl, Map<String, String> extensionData); File generateManifest(String consumerUuid, String cdnLabel, String webUrl, String apiUrl,
        Map<String, String> extensionData); JobConfig importManifestAsync(Owner owner, File archive, String uploadedFileName,
        ConflictOverrides overrides); ImportRecord importManifest(Owner owner, File archive, String uploadedFileName,
        ConflictOverrides overrides); void recordImportFailure(Owner owner, Throwable error, String filename); @Transactional ImportRecord importStoredManifest(Owner targetOwner, String fileId, ConflictOverrides overrides,
        String uploadedFileName); @Transactional int cleanup(int maxAgeInMinutes); @Transactional void writeStoredExportToResponse(String exportId, String exportedConsumerUuid,
        HttpServletResponse response); ExportResult generateAndStoreManifest(String consumerUuid, String cdnLabel, String webUrl,
        String apiUrl, Map<String, String> extensionData); @Transactional void deleteStoredManifest(String manifestFileId); File generateEntitlementArchive(Consumer consumer, Set<Long> serials);  }
@Test public void testImportStoredManifest() throws Exception { Owner owner = TestUtil.createOwner(); String fileId = "1234"; String filename = "manifest.zip"; ConflictOverrides overrides = new ConflictOverrides(Conflict.DISTRIBUTOR_CONFLICT); ManifestFile manifest = mock(ManifestFile.class); when(manifest.getId()).thenReturn(fileId); when(fileService.get(eq(fileId))).thenReturn(manifest); manager.importStoredManifest(owner, fileId, overrides, filename); verify(importer).loadStoredExport(eq(manifest), eq(owner), eq(overrides), eq(filename)); verify(fileService).delete(fileId); }
@Test public void testImportStoredManifestThrowsBadRequestWhenManifestNotFound() throws Exception { Owner owner = TestUtil.createOwner(); String fileId = "1234"; String filename = "manifest.zip"; ConflictOverrides overrides = new ConflictOverrides(Conflict.DISTRIBUTOR_CONFLICT); when(fileService.get(eq(fileId))).thenReturn(null); assertThrows(BadRequestException.class, () -> manager.importStoredManifest(owner, fileId, overrides, filename) ); }