assertNotNull(akr.addPoolToKey("testKey", "testPool", 1L));
}
@Test
public void testActivationKeyWithSameHostReqPools() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
PoolManager poolManager = mock(PoolManager.class);
Pool p1 = genPool();
p1.setAttribute("requires_host", "host1");
Pool p2 = genPool();
p2.setAttribute("requires_host", "host1");
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool1"))).thenReturn(p1);
when(poolManager.find(eq("testPool2"))).thenReturn(p2);
ActivationKeyResource akr = new ActivationKeyResource(
akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null);
akr.addPoolToKey("testKey", "testPool1", 1L);
assertEquals(1, ak.getPools().size());
Set<ActivationKeyPool> akPools = new HashSet<ActivationKeyPool>();
akPools.add(new ActivationKeyPool(ak, p1, 1L));
ak.setPools(akPools);
akr.addPoolToKey("testKey", "testPool2", 1L);
assertEquals(2, ak.getPools().size());
}