use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ConsumerBindUtil method handleActivationKeyOverrides.
private void handleActivationKeyOverrides(Consumer consumer, Set<ActivationKeyContentOverride> overrides) {
for (ActivationKeyContentOverride akco : overrides) {
ConsumerContentOverride consumerOverride = akco.buildConsumerContentOverride(consumer);
this.consumerContentOverrideCurator.addOrUpdate(consumer, consumerOverride);
}
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyTranslator method populate.
/**
* {@inheritDoc}
*/
@Override
public ActivationKeyDTO populate(ModelTranslator modelTranslator, ActivationKey source, ActivationKeyDTO dest) {
dest = super.populate(modelTranslator, source, dest);
dest.setId(source.getId()).setName(source.getName()).setDescription(source.getDescription()).setServiceLevel(source.getServiceLevel()).setAutoAttach(source.isAutoAttach());
// Process nested objects if we have a model translator to use to the translation...
if (modelTranslator != null) {
Owner owner = source.getOwner();
dest.setOwner(owner != null ? modelTranslator.translate(owner, OwnerDTO.class) : null);
Set<ActivationKeyPool> pools = source.getPools();
if (pools != null && !pools.isEmpty()) {
for (ActivationKeyPool poolEntry : pools) {
if (poolEntry != null) {
dest.addPool(new ActivationKeyDTO.ActivationKeyPoolDTO(poolEntry.getPool().getId(), poolEntry.getQuantity()));
}
}
} else {
dest.setPools(Collections.<ActivationKeyDTO.ActivationKeyPoolDTO>emptySet());
}
Set<Product> products = source.getProducts();
if (products != null && !products.isEmpty()) {
for (Product prod : products) {
if (prod != null) {
dest.addProductId(prod.getId());
}
}
} else {
dest.setProductIds(Collections.<String>emptySet());
}
Set<ActivationKeyContentOverride> overrides = source.getContentOverrides();
if (overrides != null && !overrides.isEmpty()) {
for (ActivationKeyContentOverride override : overrides) {
if (override != null) {
dest.addContentOverride(new ActivationKeyDTO.ActivationKeyContentOverrideDTO(override.getContentLabel(), override.getName(), override.getValue()));
}
}
} else {
dest.setContentOverrides(Collections.<ActivationKeyDTO.ActivationKeyContentOverrideDTO>emptySet());
}
Release release = source.getReleaseVer();
if (release != null) {
dest.setReleaseVersion(release.getReleaseVer());
}
}
return dest;
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(ActivationKey source, ActivationKeyDTO dest, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getId(), dest.getId());
assertEquals(source.getName(), dest.getName());
assertEquals(source.getDescription(), dest.getDescription());
assertEquals(source.getServiceLevel(), dest.getServiceLevel());
assertEquals(source.isAutoAttach(), dest.isAutoAttach());
if (childrenGenerated) {
this.ownerTranslatorTest.verifyOutput(source.getOwner(), dest.getOwner(), true);
for (Product prod : source.getProducts()) {
for (String prodDto : dest.getProductIds()) {
assertNotNull(prodDto);
if (prodDto.equals(prod.getId())) {
// Nothing else to assert on, since prodDto only holds the product id.
}
}
}
for (ActivationKeyPool akPool : source.getPools()) {
for (ActivationKeyDTO.ActivationKeyPoolDTO akPoolDto : dest.getPools()) {
assertNotNull(akPoolDto);
if (akPoolDto.getPoolId().equals(akPool.getId())) {
assertEquals(akPool.getQuantity(), akPoolDto.getQuantity());
}
}
}
for (ActivationKeyContentOverride akOverride : source.getContentOverrides()) {
for (ActivationKeyDTO.ActivationKeyContentOverrideDTO akOverrideDto : dest.getContentOverrides()) {
assertNotNull(akOverrideDto);
if (akOverrideDto.getName().equals(akOverride.getName())) {
assertEquals(akOverrideDto.getContentLabel(), akOverride.getContentLabel());
assertEquals(akOverrideDto.getValue(), akOverride.getValue());
}
}
}
Release releaseSource = source.getReleaseVer();
String releaseDestination = dest.getReleaseVersion();
if (releaseSource != null) {
assertEquals(releaseSource.getReleaseVer(), releaseDestination);
} else {
assertNull(releaseDestination);
}
} else {
assertNull(dest.getOwner());
assertNull(dest.getProductIds());
assertNull(dest.getPools());
assertNull(dest.getContentOverrides());
assertNull(dest.getReleaseVersion());
}
} else {
assertNull(dest);
}
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyContentOverrideCuratorTest method testRetrieveByNameIsCaseInsensitive.
@Test
public void testRetrieveByNameIsCaseInsensitive() {
activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key, "test-repo", "gpgcheck", "1"));
ActivationKeyContentOverride found = activationKeyContentOverrideCurator.retrieve(key, "test-repo", "GPGCheck");
assertNotNull(found);
assertEquals(key, found.getKey());
assertEquals("test-repo", found.getContentLabel());
assertEquals("gpgcheck", found.getName());
assertEquals("1", found.getValue());
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyContentOverrideCuratorTest method testRemoveByNameCaseInsensitive.
@Test
public void testRemoveByNameCaseInsensitive() {
activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key, "test-repo", "gpgcheck", "1"));
activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key, "test-repo", "remaining-override", "remaining"));
activationKeyContentOverrideCurator.removeByName(key, "test-repo", "GpGChecK");
List<ActivationKeyContentOverride> remaining = activationKeyContentOverrideCurator.getList(key);
assertEquals(1, remaining.size());
assertEquals("remaining-override", remaining.get(0).getName());
}
Aggregations