Importer { protected void importDistributorVersions(File[] versionFiles) throws IOException { DistributorVersionImporter importer = new DistributorVersionImporter(distVerCurator); Set<DistributorVersionDTO> distVers = new HashSet<>(); for (File verFile : versionFiles) { Reader reader = null; try { reader = new FileReader(verFile); distVers.add(importer.createObject(mapper, reader)); } finally { if (reader != null) { reader.close(); } } } importer.store(distVers); } @Inject  Importer(ConsumerTypeCurator consumerTypeCurator, ProductCurator productCurator,
        RulesImporter rulesImporter, OwnerCurator ownerCurator, IdentityCertificateCurator idCertCurator,
        ContentCurator contentCurator, PoolManager pm, PKIUtility pki, Configuration config,
        ExporterMetadataCurator emc, CertificateSerialCurator csc, EventSink sink, I18n i18n,
        DistributorVersionCurator distVerCurator, CdnCurator cdnCurator, SyncUtils syncUtils,
        ImportRecordCurator importRecordCurator, SubscriptionReconciler subscriptionReconciler,
        EntitlementCurator entitlementCurator, ContentAccessManager contentAccessManager,
        ModelTranslator translator); ImportRecord loadExport(Owner owner, File archive, ConflictOverrides overrides,
        String uploadedFileName); ImportRecord loadStoredExport(ManifestFile export, Owner owner, ConflictOverrides overrides,
        String uploadedFileName); ImportRecord recordImportSuccess(Owner owner, Map<String, Object> data,
        ConflictOverrides forcedConflicts, String filename); void recordImportFailure(Owner owner, Throwable error, String filename); @SuppressWarnings("checkstyle:methodlength") @Transactional(rollbackOn = {IOException.class, ImporterException.class, RuntimeException.class, ImportConflictException.class}) // WARNING: Keep this method public, otherwise @Transactional is ignored: List<SubscriptionDTO> importObjects(Owner owner, Map<String, File> importFiles,
        ConflictOverrides overrides);  }
@Test public void importDistributorVersionCreate() throws Exception { File[] distVer = new File[1]; distVer[0] = new File(this.tmpFolder, "dist-ver.json"); mapper.writeValue(distVer[0], createTestDistributerVersion()); Importer importer = this.buildImporter(); importer.importDistributorVersions(distVer); verify(this.mockDistributorVersionCurator).create(any(DistributorVersion.class)); verify(this.mockDistributorVersionCurator, never()).merge(any(DistributorVersion.class)); }
@Test public void importDistributorVersionUpdate() throws Exception { doReturn(new DistributorVersion("test-dist-ver")) .when(this.mockDistributorVersionCurator) .findByName(eq("test-dist-ver")); File[] distVer = new File[1]; distVer[0] = new File(this.tmpFolder, "dist-ver.json"); mapper.writeValue(distVer[0], createTestDistributerVersion()); Importer importer = this.buildImporter(); importer.importDistributorVersions(distVer); verify(this.mockDistributorVersionCurator, never()).create(any(DistributorVersion.class)); verify(this.mockDistributorVersionCurator).merge(any(DistributorVersion.class)); }