use of org.candlepin.model.Owner in project candlepin by candlepin.
the class EntitlementCertificateGeneratorTest method testNonLazyRegenerate.
@Test
public void testNonLazyRegenerate() throws Exception {
Owner owner = TestUtil.createOwner("test-owner", "Test Owner");
Product product = TestUtil.createProduct();
Pool pool = TestUtil.createPool(owner, product);
pool.setSourceSubscription(new SourceSubscription("source-sub-id", "master"));
Map<String, EntitlementCertificate> entCerts = new HashMap<>();
entCerts.put(pool.getId(), new EntitlementCertificate());
when(this.mockEntCertAdapter.generateEntitlementCerts(any(Consumer.class), anyMapOf(String.class, PoolQuantity.class), anyMapOf(String.class, Entitlement.class), anyMapOf(String.class, Product.class), eq(true))).thenReturn(entCerts);
Consumer consumer = TestUtil.createConsumer(owner);
Entitlement entitlement = new Entitlement(pool, consumer, owner, 1);
entitlement.setDirty(true);
this.ecGenerator.regenerateCertificatesOf(entitlement, false);
assertFalse(entitlement.isDirty());
verify(this.mockEntCertAdapter).generateEntitlementCerts(eq(consumer), this.poolQuantityMapCaptor.capture(), this.entMapCaptor.capture(), this.productMapCaptor.capture(), eq(true));
assertEquals(entitlement, this.entMapCaptor.getValue().get(pool.getId()));
assertEquals(product, this.productMapCaptor.getValue().get(pool.getId()));
verify(this.mockEventSink, times(1)).queueEvent(any(Event.class));
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ManifestManagerTest method ensureGenerateAsyncManifestDoesNotRefreshEntitlementsBeforeStartingJob.
@Test
public void ensureGenerateAsyncManifestDoesNotRefreshEntitlementsBeforeStartingJob() throws Exception {
Owner owner = TestUtil.createOwner();
Consumer consumer = this.createMockConsumer(owner, true);
Cdn cdn = new Cdn("test-cdn", "Test CDN", "");
String webAppPrefix = "webapp-prefix";
String apiUrl = "api-url";
when(consumerCurator.verifyAndLookupConsumer(eq(consumer.getUuid()))).thenReturn(consumer);
when(cdnCurator.lookupByLabel(eq(cdn.getLabel()))).thenReturn(cdn);
manager.generateManifestAsync(consumer.getUuid(), owner.getKey(), cdn.getLabel(), webAppPrefix, apiUrl, new HashMap<>());
verify(poolManager, never()).regenerateDirtyEntitlements(anyCollection());
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ManifestManagerTest method testImportStoredManifest.
@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);
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ManifestManagerTest method verifyConsumerIsDistributorBeforeSchedulingManifestGeneration.
@Test
public void verifyConsumerIsDistributorBeforeSchedulingManifestGeneration() throws Exception {
Owner owner = TestUtil.createOwner();
Consumer consumer = this.createMockConsumer(owner, false);
ConsumerType ctype = consumerTypeCurator.getConsumerType(consumer);
Cdn cdn = new Cdn("test-cdn", "Test CDN", "");
String webAppPrefix = "webapp-prefix";
String apiUrl = "api-url";
Map<String, String> extData = new HashMap<>();
when(consumerCurator.verifyAndLookupConsumer(eq(consumer.getUuid()))).thenReturn(consumer);
when(cdnCurator.lookupByLabel(eq(cdn.getLabel()))).thenReturn(cdn);
try {
manager.generateManifestAsync(consumer.getUuid(), owner.getKey(), cdn.getLabel(), webAppPrefix, apiUrl, extData);
fail("Expected ForbiddenException not thrown");
} catch (Exception e) {
assertTrue(e instanceof ForbiddenException);
String expectedMsg = String.format("Unit %s cannot be exported. A manifest cannot be made for " + "units of type \"%s\".", consumer.getUuid(), ctype.getLabel());
assertEquals(e.getMessage(), expectedMsg);
}
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class OwnerManagerTest method testContentAccessSetEmpty.
@Test
public void testContentAccessSetEmpty() {
Owner owner = new Owner();
when(ownerCurator.lockAndLoad(eq(owner))).thenReturn(owner);
when(ownerServiceAdapter.getContentAccessModeList(eq(owner.getKey()))).thenReturn("");
when(ownerServiceAdapter.getContentAccessMode(eq(owner.getKey()))).thenReturn("");
ownerManager.refreshContentAccessMode(ownerServiceAdapter, owner);
Assert.assertEquals(owner.getContentAccessModeList(), ContentAccessCertServiceAdapter.DEFAULT_CONTENT_ACCESS_MODE);
Assert.assertEquals(owner.getContentAccessMode(), ContentAccessCertServiceAdapter.DEFAULT_CONTENT_ACCESS_MODE);
}
Aggregations