use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ContentOverrideValidatorTest method setupTest.
@Before
public void setupTest() {
InputStream is = this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
rulesCuratorMock = mock(RulesCurator.class);
config = mock(Configuration.class);
cacheProvider = mock(Provider.class);
cache = mock(JsRunnerRequestCache.class);
Rules rules = new Rules(Util.readFile(is));
when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
when(rulesCuratorMock.getRules()).thenReturn(rules);
when(cacheProvider.get()).thenReturn(cache);
provider = new JsRunnerProvider(rulesCuratorMock, cacheProvider);
overrideRules = new OverrideRules(provider.get(), config, new RulesObjectMapper(new ProductCachedSerializationModule(mockProductCurator)));
validator = new ContentOverrideValidator(i18n, overrideRules);
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class QuantityRulesTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
// Load the default production rules:
InputStream is = this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
Rules rules = new Rules(Util.readFile(is));
when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
when(rulesCuratorMock.getRules()).thenReturn(rules);
when(cacheProvider.get()).thenReturn(cache);
provider = new JsRunnerProvider(rulesCuratorMock, cacheProvider);
translator = new StandardTranslator(consumerTypeCurator, environmentCurator, ownerCuratorMock);
quantityRules = new QuantityRules(provider.get(), new RulesObjectMapper(new ProductCachedSerializationModule(productCurator)), translator);
owner = new Owner("Test Owner " + TestUtil.randomInt());
product = TestUtil.createProduct();
pool = TestUtil.createPool(owner, product);
pool.setId("fakepoolid");
ctype = TestUtil.createConsumerType();
consumer = TestUtil.createConsumer(owner);
when(consumerTypeCurator.find(eq(ctype.getId()))).thenReturn(ctype);
when(consumerTypeCurator.getConsumerType(eq(consumer))).thenReturn(ctype);
Entitlement e = TestUtil.createEntitlement(owner, consumer, pool, new EntitlementCertificate());
Set<Entitlement> entSet = new HashSet<>();
entSet.add(e);
pool.setEntitlements(entSet);
pool.getProduct().setAttribute(Pool.Attributes.MULTI_ENTITLEMENT, "yes");
pool.getProduct().setAttribute(Product.Attributes.STACKING_ID, "1");
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithDiffHostReqPools.
@Test
public void testActivationKeyWithDiffHostReqPools() {
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, "host2");
ak.addPool(p2, 1L);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool1"))).thenReturn(p1);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool1", 1L);
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNegPoolQuantity.
@Test(expected = BadRequestException.class)
public void testActivationKeyWithNegPoolQuantity() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
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", -3L);
}
use of org.candlepin.jackson.ProductCachedSerializationModule in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNonPersonConsumerType.
@Test
public void testActivationKeyWithNonPersonConsumerType() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.REQUIRES_CONSUMER_TYPE, "candlepin");
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);
assertNotNull(akr.addPoolToKey("testKey", "testPool", 1L));
}
Aggregations