use of org.candlepin.model.SourceStack in project candlepin by candlepin.
the class PoolTranslatorTest method initSourceObject.
@Override
protected Pool initSourceObject() {
Pool source = new Pool();
source.setId("pool-id");
source.setOwner(this.ownerTranslatorTest.initSourceObject());
source.setProduct(this.productTranslatorTest.initSourceObject());
source.setDerivedProduct(this.productTranslatorTest.initSourceObject());
Set<Branding> brandingSet = new HashSet<>();
brandingSet.add(this.brandingTranslatorTest.initSourceObject());
source.setBranding(brandingSet);
Entitlement entitlement = new Entitlement();
entitlement.setId("ent-id");
source.setSourceEntitlement(entitlement);
SubscriptionsCertificate subCert = new SubscriptionsCertificate();
subCert.setId("cert-id");
subCert.setKey("cert-key");
subCert.setCert("cert-cert");
subCert.setSerial(new CertificateSerial());
source.setCertificate(subCert);
SourceSubscription sourceSubscription = new SourceSubscription();
sourceSubscription.setId("source-sub-id-1");
sourceSubscription.setSubscriptionId("source-sub-subscription-id-1");
sourceSubscription.setSubscriptionSubKey("source-sub-subscription-sub-key-1");
source.setSourceSubscription(sourceSubscription);
source.setActiveSubscription(true);
source.setCreatedByShare(false);
source.setHasSharedAncestor(true);
source.setQuantity(1L);
source.setStartDate(new Date());
source.setEndDate(new Date());
Map<String, String> attributes = new HashMap<>();
attributes.put(Pool.Attributes.SOURCE_POOL_ID, "true");
source.setAttributes(attributes);
source.setRestrictedToUsername("restricted-to-username-value");
source.setContractNumber("333");
source.setAccountNumber("444");
source.setOrderNumber("555");
source.setConsumed(6L);
source.setExported(7L);
source.setShared(8L);
Map<String, String> calculatedAttributes = new HashMap<>();
calculatedAttributes.put("calc-attribute-key-3", "calc-attribute-value-3");
calculatedAttributes.put("calc-attribute-key-4", "calc-attribute-value-4");
source.setCalculatedAttributes(calculatedAttributes);
source.setUpstreamPoolId("upstream-pool-id-2");
source.setUpstreamEntitlementId("upstream-entitlement-id-2");
source.setUpstreamConsumerId("upstream-consumer-id-2");
source.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
Product derivedProduct = new Product();
derivedProduct.setId("derived-product-id-2");
derivedProduct.setName("derived-product-name-2");
derivedProduct.setAttributes(new HashMap<>());
derivedProduct.setAttribute(Product.Attributes.ARCHITECTURE, "POWER");
derivedProduct.setAttribute(Product.Attributes.STACKING_ID, "2221");
source.setDerivedProduct(derivedProduct);
ProvidedProduct providedProd = new ProvidedProduct();
providedProd.setProductId("provided-product-id-1");
providedProd.setProductName("provided-product-name-1");
Set<ProvidedProduct> providedProducts = new HashSet<>();
providedProducts.add(providedProd);
source.setProvidedProductDtos(providedProducts);
ProvidedProduct derivedProvidedProd = new ProvidedProduct();
derivedProvidedProd.setProductId("derived-provided-product-id-1");
derivedProvidedProd.setProductName("derived-provided-product-name-1");
Set<ProvidedProduct> derivedProvidedProducts = new HashSet<>();
derivedProvidedProducts.add(derivedProvidedProd);
source.setDerivedProvidedProductDtos(derivedProvidedProducts);
Consumer sourceConsumer = new Consumer();
sourceConsumer.setUuid("source-consumer-uuid");
SourceStack sourceStack = new SourceStack();
sourceStack.setSourceStackId("source-stack-source-stack-id-1");
sourceStack.setId("source-stack-id-1");
sourceStack.setSourceConsumer(sourceConsumer);
source.setSourceStack(sourceStack);
return source;
}
use of org.candlepin.model.SourceStack in project candlepin by candlepin.
the class PoolTranslatorTest method initSourceObject.
@Override
protected Pool initSourceObject() {
Pool source = new Pool();
source.setId("pool-id");
source.setOwner(this.ownerTranslatorTest.initSourceObject());
source.setProduct(this.productTranslatorTest.initSourceObject());
source.setDerivedProduct(this.productTranslatorTest.initSourceObject());
Set<Branding> brandingSet = new HashSet<>();
brandingSet.add(this.brandingTranslatorTest.initSourceObject());
source.setBranding(brandingSet);
Entitlement entitlement = new Entitlement();
entitlement.setId("ent-id");
source.setSourceEntitlement(entitlement);
SubscriptionsCertificate subCert = new SubscriptionsCertificate();
subCert.setId("cert-id");
subCert.setKey("cert-key");
subCert.setCert("cert-cert");
subCert.setSerial(new CertificateSerial());
source.setCertificate(subCert);
SourceSubscription sourceSubscription = new SourceSubscription();
sourceSubscription.setId("source-sub-id-1");
sourceSubscription.setSubscriptionId("source-sub-subscription-id-1");
sourceSubscription.setSubscriptionSubKey("source-sub-subscription-sub-key-1");
source.setSourceSubscription(sourceSubscription);
source.setActiveSubscription(true);
source.setCreatedByShare(false);
source.setHasSharedAncestor(true);
source.setQuantity(1L);
source.setStartDate(new Date());
source.setEndDate(new Date());
Map<String, String> attributes = new HashMap<>();
attributes.put(Pool.Attributes.SOURCE_POOL_ID, "true");
source.setAttributes(attributes);
source.setRestrictedToUsername("restricted-to-username-value");
source.setContractNumber("333");
source.setAccountNumber("444");
source.setOrderNumber("555");
source.setConsumed(6L);
source.setExported(7L);
source.setShared(8L);
Map<String, String> calculatedAttributes = new HashMap<>();
calculatedAttributes.put("calc-attribute-key-3", "calc-attribute-value-3");
calculatedAttributes.put("calc-attribute-key-4", "calc-attribute-value-4");
source.setCalculatedAttributes(calculatedAttributes);
source.setUpstreamPoolId("upstream-pool-id-2");
source.setUpstreamEntitlementId("upstream-entitlement-id-2");
source.setUpstreamConsumerId("upstream-consumer-id-2");
source.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
ProvidedProduct providedProd = new ProvidedProduct();
providedProd.setProductId("provided-product-id-1");
providedProd.setProductName("provided-product-name-1");
Set<ProvidedProduct> providedProducts = new HashSet<>();
providedProducts.add(providedProd);
source.setProvidedProductDtos(providedProducts);
ProvidedProduct derivedProvidedProd = new ProvidedProduct();
derivedProvidedProd.setProductId("derived-provided-product-id-1");
derivedProvidedProd.setProductName("derived-provided-product-name-1");
Set<ProvidedProduct> derivedProvidedProducts = new HashSet<>();
derivedProvidedProducts.add(derivedProvidedProd);
source.setDerivedProvidedProductDtos(derivedProvidedProducts);
Consumer sourceConsumer = new Consumer();
sourceConsumer.setUuid("source-consumer-uuid");
SourceStack sourceStack = new SourceStack();
sourceStack.setSourceStackId("source-stack-source-stack-id-1");
sourceStack.setId("source-stack-id-1");
sourceStack.setSourceConsumer(sourceConsumer);
source.setSourceStack(sourceStack);
return source;
}
use of org.candlepin.model.SourceStack in project candlepin by candlepin.
the class PoolManagerTest method testRefreshPoolsSortsStackDerivedPools.
@SuppressWarnings("rawtypes")
@Test
public void testRefreshPoolsSortsStackDerivedPools() {
List<Subscription> subscriptions = new ArrayList<>();
List<Pool> pools = new ArrayList<>();
// Pool has no subscription ID:
Product product = TestUtil.createProduct();
Pool p = TestUtil.createPool(product);
p.setSourceStack(new SourceStack(new Consumer(), "a"));
pools.add(p);
mockSubsList(subscriptions);
mockPoolsList(pools);
Owner owner = getOwner();
when(mockOwnerCurator.lookupByKey(owner.getKey())).thenReturn(owner);
this.mockProductImport(owner, product);
this.mockContentImport(owner, new Content[] {});
CandlepinQuery<Pool> cqmock = mock(CandlepinQuery.class);
when(cqmock.list()).thenReturn(pools);
when(cqmock.iterator()).thenReturn(pools.iterator());
when(mockPoolCurator.listByOwnerAndType(eq(owner), any(PoolType.class))).thenReturn(cqmock);
this.manager.getRefresher(mockSubAdapter, mockOwnerAdapter).add(owner).run();
ArgumentCaptor<List> poolCaptor = ArgumentCaptor.forClass(List.class);
verify(this.poolRulesMock).updatePools(poolCaptor.capture(), any(Map.class));
assertEquals(1, poolCaptor.getValue().size());
assertEquals(p, poolCaptor.getValue().get(0));
}
use of org.candlepin.model.SourceStack in project candlepin by candlepin.
the class PoolManagerTest method testIsManaged.
@Test
@Parameters(method = "getParametersForIsManagedTests")
public void testIsManaged(PoolType type, SourceSubscription srcSub, String upstreamPoolId, boolean hosted, boolean expected) {
Pool pool = TestUtil.createPool(owner, product);
when(mockConfig.getBoolean(eq(ConfigProperties.STANDALONE))).thenReturn(!hosted);
when(mockConfig.getBoolean(eq(ConfigProperties.STANDALONE), anyBoolean())).thenReturn(!hosted);
pool.setSourceSubscription(srcSub);
pool.setUpstreamPoolId(upstreamPoolId);
switch(type) {
case UNMAPPED_GUEST:
pool.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
pool.setAttribute(Pool.Attributes.UNMAPPED_GUESTS_ONLY, "true");
break;
case ENTITLEMENT_DERIVED:
pool.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
pool.setSourceEntitlement(new Entitlement());
break;
case STACK_DERIVED:
pool.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
pool.setSourceStack(new SourceStack());
break;
case BONUS:
pool.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
break;
case DEVELOPMENT:
pool.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
break;
case NORMAL:
default:
}
boolean output = manager.isManaged(pool);
assertEquals(expected, output);
}
use of org.candlepin.model.SourceStack in project candlepin by candlepin.
the class EntitlementResourceTest method getUpstreamCertStackSubPool.
@Test
public void getUpstreamCertStackSubPool() {
Entitlement parentEnt = TestUtil.createEntitlement();
parentEnt.setId("parentEnt");
SubscriptionsCertificate subcert = new SubscriptionsCertificate();
subcert.setCert("HELLO");
subcert.setKey("CERT");
parentEnt.getPool().setCertificate(subcert);
when(entitlementCurator.findUpstreamEntitlementForStack(consumer, "mystack")).thenReturn(parentEnt);
String expected = "HELLOCERT";
// Entitlement from stack sub-pool:
Entitlement e = TestUtil.createEntitlement();
e.setId("entitlementID");
e.getPool().setSourceStack(new SourceStack(consumer, "mystack"));
when(entitlementCurator.find(eq(e.getId()))).thenReturn(e);
String result = entResource.getUpstreamCert(e.getId());
assertEquals(expected, result);
}
Aggregations