use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class DatabaseTestFixture method createDistributor.
protected Consumer createDistributor(Owner owner) {
ConsumerType type = this.createConsumerType(true);
Consumer consumer = new Consumer("test-distributor", "test-user", owner, type);
return this.consumerCurator.create(consumer);
}
use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class DatabaseTestFixture method createEnvironment.
protected Environment createEnvironment(Owner owner, String id, String name, String description, Collection<Consumer> consumers, Collection<Content> content) {
Environment environment = new Environment(id, name, owner);
environment.setDescription(description);
if (content != null) {
for (Content elem : content) {
EnvironmentContent envContent = new EnvironmentContent(environment, elem, true);
// Impl note:
// At the time of writing, this line is redundant. But if we ever fix environment,
// this will be good to have as a backup.
environment.getEnvironmentContent().add(envContent);
}
}
environment = this.environmentCurator.create(environment);
// Update consumers to point to the new environment
if (consumers != null) {
for (Consumer consumer : consumers) {
consumer.setEnvironmentId(environment.getId());
this.consumerCurator.merge(consumer);
}
}
return environment;
}
use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class EntitlementTranslator method populate.
/**
* {@inheritDoc}
*/
@Override
public EntitlementDTO populate(ModelTranslator modelTranslator, Entitlement source, EntitlementDTO dest) {
dest = super.populate(modelTranslator, source, dest);
dest.setId(source.getId());
dest.setQuantity(source.getQuantity());
dest.setDeletedFromPool(source.deletedFromPool());
dest.setStartDate(source.getStartDate());
dest.setEndDate(source.getEndDate());
if (modelTranslator != null) {
Owner owner = source.getOwner();
dest.setOwner(owner != null ? modelTranslator.translate(owner, OwnerDTO.class) : null);
Pool pool = source.getPool();
dest.setPool(pool != null ? modelTranslator.translate(pool, PoolDTO.class) : null);
Consumer consumer = source.getConsumer();
dest.setConsumer(consumer != null ? modelTranslator.translate(consumer, ConsumerDTO.class) : null);
Set<EntitlementCertificate> certs = source.getCertificates();
if (certs != null && !certs.isEmpty()) {
for (Certificate cert : certs) {
if (cert != null) {
dest.addCertificate(modelTranslator.translate(cert, CertificateDTO.class));
}
}
} else {
dest.setCertificates(Collections.emptySet());
}
}
return dest;
}
use of org.candlepin.model.Consumer 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.Consumer 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;
}
Aggregations