Search in sources :

Example 11 with OwnerCurator

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);
}
Also used : EntitlementCurator(org.candlepin.model.EntitlementCurator) OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) UeberCertificate(org.candlepin.model.UeberCertificate) ProductCurator(org.candlepin.model.ProductCurator) UeberCertificateCurator(org.candlepin.model.UeberCertificateCurator) EntitlementCertificateCurator(org.candlepin.model.EntitlementCertificateCurator) UeberCertificateGenerator(org.candlepin.model.UeberCertificateGenerator) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) ConsumerCurator(org.candlepin.model.ConsumerCurator) CandlepinPoolManager(org.candlepin.controller.CandlepinPoolManager) Test(org.junit.Test)

Example 12 with OwnerCurator

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ProductCurator(org.candlepin.model.ProductCurator) PersistenceException(javax.persistence.PersistenceException) EventFactory(org.candlepin.audit.EventFactory) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) OwnerManager(org.candlepin.controller.OwnerManager) Test(org.junit.Test)

Example 13 with OwnerCurator

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ImportFile(org.candlepin.sync.Importer.ImportFile) File(java.io.File) Test(org.junit.Test)

Example 14 with OwnerCurator

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ExporterMetadataCurator(org.candlepin.model.ExporterMetadataCurator) Reader(java.io.Reader) ImportFile(org.candlepin.sync.Importer.ImportFile) File(java.io.File) Test(org.junit.Test)

Example 15 with OwnerCurator

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ImportFile(org.candlepin.sync.Importer.ImportFile) File(java.io.File) Test(org.junit.Test)

Aggregations

OwnerCurator (org.candlepin.model.OwnerCurator)21 Owner (org.candlepin.model.Owner)20 Test (org.junit.Test)19 ProductCurator (org.candlepin.model.ProductCurator)9 File (java.io.File)8 ImportFile (org.candlepin.sync.Importer.ImportFile)8 Principal (org.candlepin.auth.Principal)4 Date (java.util.Date)3 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)3 UserPrincipal (org.candlepin.auth.UserPrincipal)3 CandlepinPoolManager (org.candlepin.controller.CandlepinPoolManager)3 ActivationKeyDTO (org.candlepin.dto.api.v1.ActivationKeyDTO)3 ConsumerCurator (org.candlepin.model.ConsumerCurator)3 ConsumerType (org.candlepin.model.ConsumerType)3 ConsumerTypeCurator (org.candlepin.model.ConsumerTypeCurator)3 Product (org.candlepin.model.Product)3 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 StandardTranslator (org.candlepin.dto.StandardTranslator)2 ConsumerDTO (org.candlepin.dto.manifest.v1.ConsumerDTO)2