use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method consumerHavingEqualRamAsProductShouldNotGenerateWarning.
@Test
public void consumerHavingEqualRamAsProductShouldNotGenerateWarning() {
// Fact specified in kb
Pool pool = setupArchTest("ram", "2", "memory.memtotal", "2000000");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PreEntitlementRulesTest method testCommaSplitArchesTrailingComma.
@Test
public void testCommaSplitArchesTrailingComma() {
Pool pool = setupArchTest("arch", "x86_64,x86_64,", "uname.machine", "x86_64");
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PoolManagerTest method testBatchRevokeCleansUpCorrectPoolsWithSourceEnt.
@Test
public void testBatchRevokeCleansUpCorrectPoolsWithSourceEnt() throws Exception {
Consumer c = TestUtil.createConsumer(owner);
Pool pool2 = TestUtil.createPool(owner, product);
Entitlement e = new Entitlement(pool, c, owner, 1);
Entitlement e2 = new Entitlement(pool2, c, owner, 1);
Entitlement e3 = new Entitlement(pool2, c, owner, 1);
List<Entitlement> entsToDelete = new ArrayList<>();
entsToDelete.add(e);
entsToDelete.add(e2);
List<Pool> poolsWithSource = createPoolsWithSourceEntitlement(e, product);
poolsWithSource.get(0).getEntitlements().add(e3);
Set<Pool> poolsWithSourceAsSet = new HashSet<>(poolsWithSource);
when(mockPoolCurator.listBySourceEntitlements(entsToDelete)).thenReturn(poolsWithSourceAsSet);
PreUnbindHelper preHelper = mock(PreUnbindHelper.class);
ValidationResult result = new ValidationResult();
when(preHelper.getResult()).thenReturn(result);
when(mockConfig.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
when(mockPoolCurator.lockAndLoad(eq(pool))).thenReturn(pool);
when(mockPoolCurator.lockAndLoad(eq(pool2))).thenReturn(pool2);
manager.revokeEntitlements(entsToDelete);
entsToDelete.add(e3);
verify(entitlementCurator).batchDelete(eq(entsToDelete));
verify(mockPoolCurator).batchDelete(eq(poolsWithSourceAsSet), anySetOf(String.class));
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PoolManagerTest method testCleanupExpiredPools.
@Test
public void testCleanupExpiredPools() {
Pool p = createPoolWithEntitlements();
p.setSubscriptionId("subid");
List<Pool> pools = new LinkedList<>();
pools.add(p);
when(mockPoolCurator.lockAndLoad(any(Pool.class))).thenReturn(p);
when(mockPoolCurator.listExpiredPools(anyInt())).thenReturn(pools);
when(mockPoolCurator.entitlementsIn(p)).thenReturn(new ArrayList<>(p.getEntitlements()));
Subscription sub = new Subscription();
sub.setId(p.getSubscriptionId());
when(mockSubAdapter.getSubscription(any(String.class))).thenReturn(sub);
when(mockSubAdapter.isReadOnly()).thenReturn(false);
PreUnbindHelper preHelper = mock(PreUnbindHelper.class);
ValidationResult result = new ValidationResult();
when(preHelper.getResult()).thenReturn(result);
manager.cleanupExpiredPools();
// And the pool should be deleted:
when(mockPoolCurator.lockAndLoadByIds(anyCollection())).thenReturn(pools);
}
use of org.candlepin.policy.ValidationResult in project candlepin by candlepin.
the class PoolManagerTest method testRevokeCleansUpPoolsWithSourceEnt.
@Test
public void testRevokeCleansUpPoolsWithSourceEnt() throws Exception {
Entitlement e = new Entitlement(pool, TestUtil.createConsumer(owner), owner, 1);
List<Pool> poolsWithSource = createPoolsWithSourceEntitlement(e, product);
CandlepinQuery<Pool> cqmock = mock(CandlepinQuery.class);
when(cqmock.list()).thenReturn(poolsWithSource);
when(mockPoolCurator.listBySourceEntitlement(e)).thenReturn(cqmock);
PreUnbindHelper preHelper = mock(PreUnbindHelper.class);
ValidationResult result = new ValidationResult();
when(preHelper.getResult()).thenReturn(result);
when(mockConfig.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
when(mockPoolCurator.lockAndLoad(any(Pool.class))).thenReturn(pool);
manager.revokeEntitlement(e);
List<Entitlement> entsToDelete = Arrays.asList(e);
verify(entitlementCurator).batchDelete(eq(entsToDelete));
}
Aggregations