use of org.candlepin.model.ExporterMetadataCurator in project candlepin by candlepin.
the class ImporterTest method firstRun.
@Test
public void firstRun() throws Exception {
File f = createFile("meta", "0.0.3", new Date(), "test_user", "prefix");
File actualmeta = createFile("meta.json", "0.0.3", new Date(), "test_user", "prefix");
ExporterMetadataCurator emc = mock(ExporterMetadataCurator.class);
when(emc.lookupByType(ExporterMetadata.TYPE_SYSTEM)).thenReturn(null);
Importer i = new Importer(null, null, null, null, null, null, null, null, null, emc, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
i.validateMetadata(ExporterMetadata.TYPE_SYSTEM, null, actualmeta, new ConflictOverrides());
assertTrue(f.delete());
assertTrue(actualmeta.delete());
verify(emc).create(any(ExporterMetadata.class));
}
use of org.candlepin.model.ExporterMetadataCurator in project candlepin by candlepin.
the class ImporterTest method sameImport.
@Test
public void sameImport() throws Exception {
// actualmeta is the mock for the import itself
Date date = getDateBeforeDays(10);
File actualmeta = createFile("meta.json", "0.0.3", date, "test_user", "prefix");
ExporterMetadataCurator emc = mock(ExporterMetadataCurator.class);
// emc is the mock for lastrun (i.e., the most recent import in CP)
ExporterMetadata em = new ExporterMetadata();
// exact same date = assumed same manifest
em.setExported(date);
em.setId("42");
em.setType(ExporterMetadata.TYPE_SYSTEM);
when(emc.lookupByType(ExporterMetadata.TYPE_SYSTEM)).thenReturn(em);
Importer i = new Importer(null, null, null, null, null, null, null, null, null, emc, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
try {
i.validateMetadata(ExporterMetadata.TYPE_SYSTEM, null, actualmeta, new ConflictOverrides());
fail();
} catch (ImportConflictException e) {
assertFalse(e.message().getConflicts().isEmpty());
assertEquals(1, e.message().getConflicts().size());
assertTrue(e.message().getConflicts().contains(Importer.Conflict.MANIFEST_SAME));
}
}
use of org.candlepin.model.ExporterMetadataCurator in project candlepin by candlepin.
the class ImporterTest method testImportNoDistributorVersions.
@Test
public void testImportNoDistributorVersions() throws IOException, ImporterException {
RulesImporter ri = mock(RulesImporter.class);
doNothing().when(ri).importObject(any(Reader.class));
ExporterMetadataCurator emc = mock(ExporterMetadataCurator.class);
// this is the hook to stop testing. we confirm that the dist version null test
// is passed and then jump out instead of trying to fake the actual file
// processing.
doThrow(new RuntimeException("Done with the test")).when(emc).lookupByTypeAndOwner(any(String.class), any(Owner.class));
OwnerCurator oc = mock(OwnerCurator.class);
Owner owner = mock(Owner.class);
ConflictOverrides co = mock(ConflictOverrides.class);
Map<String, File> importFiles = createAndSetImportFiles();
Importer i = new Importer(null, null, ri, oc, null, null, null, null, config, emc, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
ee.expect(RuntimeException.class);
ee.expectMessage("Done with the test");
i.importObjects(owner, importFiles, co);
}
Aggregations