use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyContentOverrideCuratorTest method testCreateOverride.
@Test
public void testCreateOverride() {
ActivationKeyContentOverride override = new ActivationKeyContentOverride(key, "test-repo", "gpgcheck", "1");
assertEquals(override, this.activationKeyContentOverrideCurator.create(override));
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyContentOverrideResourceTest method testActivationKeyGetOverrides.
@Test
public void testActivationKeyGetOverrides() {
List<ActivationKeyContentOverride> overrides = new LinkedList<>();
ActivationKeyContentOverride override = new ActivationKeyContentOverride(key, "label", "name", "value");
overrides.add(override);
when(activationKeyContentOverrideCurator.getList(eq(key))).thenReturn(overrides);
List<ActivationKeyContentOverride> res = akcor.getContentOverrideList(context, principal);
assertEquals(overrides, res);
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class OwnerResource method populateEntity.
/**
* Populates the specified entity with data from the provided DTO. This method will not set the
* ID field.
*
* @param entity
* The entity instance to populate
*
* @param dto
* The DTO containing the data with which to populate the entity
*
* @throws IllegalArgumentException
* if either entity or dto are null
*/
protected void populateEntity(ActivationKey entity, ActivationKeyDTO dto) {
if (entity == null) {
throw new IllegalArgumentException("the activation key model entity is null");
}
if (dto == null) {
throw new IllegalArgumentException("the activation key dto is null");
}
if (dto.getName() != null) {
entity.setName(dto.getName());
}
if (dto.getDescription() != null) {
entity.setDescription(dto.getDescription());
}
if (dto.getServiceLevel() != null) {
entity.setServiceLevel(dto.getServiceLevel());
}
if (dto.getOwner() != null) {
entity.setOwner(lookupOwnerFromDto(dto.getOwner()));
}
if (dto.getServiceLevel() != null) {
if (dto.getServiceLevel().isEmpty()) {
entity.setServiceLevel(null);
} else {
entity.setServiceLevel(dto.getServiceLevel());
}
}
if (dto.getContentOverrides() != null) {
if (dto.getContentOverrides().isEmpty()) {
entity.setContentOverrides(new HashSet<>());
} else {
for (ActivationKeyDTO.ActivationKeyContentOverrideDTO overrideDTO : dto.getContentOverrides()) {
if (overrideDTO != null) {
entity.addContentOverride(new ActivationKeyContentOverride(entity, overrideDTO.getContentLabel(), overrideDTO.getName(), overrideDTO.getValue()));
}
}
}
}
if (dto.getReleaseVersion() != null) {
entity.setReleaseVer(new Release(dto.getReleaseVersion()));
}
if (dto.getPools() != null) {
if (dto.getPools().isEmpty()) {
entity.setPools(new HashSet<>());
} else {
for (ActivationKeyDTO.ActivationKeyPoolDTO poolDTO : dto.getPools()) {
if (poolDTO != null) {
Pool pool = findPool(poolDTO.getPoolId());
entity.addPool(pool, poolDTO.getQuantity());
}
}
}
}
if (dto.getProductIds() != null) {
if (dto.getProductIds().isEmpty()) {
entity.setProducts(new HashSet<>());
} else {
for (String productId : dto.getProductIds()) {
if (productId != null) {
Product product = findProduct(entity.getOwner(), productId);
entity.addProduct(product);
}
}
}
}
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyContentOverrideCuratorTest method testAddOrUpdateUpdatesValue.
@Test
public void testAddOrUpdateUpdatesValue() {
ActivationKeyContentOverride cco1 = new ActivationKeyContentOverride(key, "test-content1", "name1", "value");
activationKeyContentOverrideCurator.create(cco1);
ActivationKeyContentOverride cco2 = new ActivationKeyContentOverride(key, "test-content1", "name1", "value2");
activationKeyContentOverrideCurator.addOrUpdate(key, cco2);
List<ActivationKeyContentOverride> ccoList = activationKeyContentOverrideCurator.listAll().list();
assertEquals(1, ccoList.size());
assertEquals("value2", ccoList.get(0).getValue());
}
use of org.candlepin.model.activationkeys.ActivationKeyContentOverride in project candlepin by candlepin.
the class ActivationKeyContentOverrideCuratorTest method normalCreateAndUpdate.
@Test
public void normalCreateAndUpdate() {
ActivationKeyContentOverride cco = new ActivationKeyContentOverride(key, "test-content", "name", "value");
activationKeyContentOverrideCurator.create(cco);
cco.setValue("value-update");
activationKeyContentOverrideCurator.merge(cco);
ActivationKeyContentOverride cco2 = activationKeyContentOverrideCurator.retrieve(key, "test-content", "name");
assert (cco2 != null);
assertEquals("value-update", cco2.getValue());
}
Aggregations