use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithPersonConsumerType.
@Test(expected = BadRequestException.class)
public void testActivationKeyWithPersonConsumerType() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.REQUIRES_CONSUMER_TYPE, "person");
p.setQuantity(1L);
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool", 1L);
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNonMultiPool.
@Test(expected = BadRequestException.class)
public void testActivationKeyWithNonMultiPool() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.MULTI_ENTITLEMENT, "no");
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool", 2L);
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithSameHostReqPools.
@Test
public void testActivationKeyWithSameHostReqPools() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
PoolManager poolManager = mock(PoolManager.class);
Pool p1 = genPool();
p1.setAttribute(Pool.Attributes.REQUIRES_HOST, "host1");
Pool p2 = genPool();
p2.setAttribute(Pool.Attributes.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, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool1", 1L);
assertEquals(1, ak.getPools().size());
Set<ActivationKeyPool> akPools = new HashSet<>();
akPools.add(new ActivationKeyPool(ak, p1, 1L));
ak.setPools(akPools);
akr.addPoolToKey("testKey", "testPool2", 1L);
assertEquals(2, ak.getPools().size());
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyHostReqPoolThenNonHostReq.
@Test
public void testActivationKeyHostReqPoolThenNonHostReq() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
PoolManager poolManager = mock(PoolManager.class);
Pool p1 = genPool();
p1.setAttribute(Pool.Attributes.REQUIRES_HOST, "host1");
Pool p2 = genPool();
p2.setAttribute(Pool.Attributes.REQUIRES_HOST, "");
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, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool1", 1L);
assertEquals(1, ak.getPools().size());
ak.addPool(p1, 1L);
akr.addPoolToKey("testKey", "testPool2", 1L);
assertEquals(3, ak.getPools().size());
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithLargePoolQuantity.
@Test
public void testActivationKeyWithLargePoolQuantity() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.MULTI_ENTITLEMENT, "yes");
p.setQuantity(10L);
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool", 15L);
}
Aggregations