use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class OwnerResourceTest method testCreateUeberCertificateRegenerate.
@Test
public void testCreateUeberCertificateRegenerate() {
Principal principal = setupPrincipal(owner, Access.ALL);
Owner owner = TestUtil.createOwner();
UeberCertificate entCert = mock(UeberCertificate.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
ConsumerCurator cc = mock(ConsumerCurator.class);
EntitlementCurator ec = mock(EntitlementCurator.class);
CandlepinPoolManager cpm = mock(CandlepinPoolManager.class);
EntitlementCertificateCurator ecc = mock(EntitlementCertificateCurator.class);
UeberCertificateCurator uc = mock(UeberCertificateCurator.class);
UeberCertificateGenerator ucg = mock(UeberCertificateGenerator.class);
OwnerResource resource = new OwnerResource(oc, pc, null, cc, i18n, null, null, null, null, null, cpm, null, null, null, null, null, ecc, ec, uc, ucg, null, null, null, null, null, null, null, null, null, this.modelTranslator);
when(ucg.generate(eq(owner.getKey()), eq(principal))).thenReturn(entCert);
UeberCertificate result = resource.createUeberCertificate(principal, owner.getKey());
assertEquals(entCert, result);
}
use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class OwnerResourceTest method testConflictOnDelete.
@Test(expected = ConflictException.class)
public void testConflictOnDelete() {
Owner o = mock(Owner.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
OwnerManager ownerManager = mock(OwnerManager.class);
EventFactory eventFactory = mock(EventFactory.class);
OwnerResource or = new OwnerResource(oc, pc, null, null, i18n, null, eventFactory, null, null, null, poolManager, ownerManager, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
ConstraintViolationException ce = new ConstraintViolationException(null, null, null);
PersistenceException pe = new PersistenceException(ce);
Mockito.doThrow(pe).when(ownerManager).cleanupAndDelete(eq(o), eq(true));
or.deleteOwner("testOwner", true, true);
}
use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class ImporterTest method testImportNoConsumerTypesDir.
@Test
public void testImportNoConsumerTypesDir() throws IOException, ImporterException {
OwnerCurator oc = mock(OwnerCurator.class);
Importer i = new Importer(null, null, null, oc, null, null, null, null, config, null, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
Owner owner = mock(Owner.class);
ConflictOverrides co = mock(ConflictOverrides.class);
Map<String, File> importFiles = getTestImportFiles();
importFiles.put(ImportFile.CONSUMER_TYPE.fileName(), null);
String m = i18n.tr("The archive does not contain the " + "required consumer_types directory");
ee.expect(ImporterException.class);
ee.expectMessage(m);
i.importObjects(owner, importFiles, co);
}
use of org.candlepin.model.OwnerCurator 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);
}
use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class ImporterTest method testImportNoMeta.
@Test
public void testImportNoMeta() throws IOException, ImporterException {
OwnerCurator oc = mock(OwnerCurator.class);
Importer i = new Importer(null, null, null, oc, null, null, null, null, config, null, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
Owner owner = mock(Owner.class);
ConflictOverrides co = mock(ConflictOverrides.class);
Map<String, File> importFiles = getTestImportFiles();
importFiles.put(ImportFile.META.fileName(), null);
String m = i18n.tr("The archive does not contain the " + "required meta.json file");
ee.expect(ImporterException.class);
ee.expectMessage(m);
i.importObjects(owner, importFiles, co);
}
Aggregations