use of org.candlepin.model.Pool.PoolComplianceType in project candlepin by candlepin.
the class CalculatedAttributesUtilTest method testCalculatedAttributesPresent.
@Test
public void testCalculatedAttributesPresent() {
for (PoolComplianceType type : PoolComplianceType.values()) {
when(mockPool.getComplianceType()).thenReturn(type);
Date date = new Date();
Map<String, String> attrs = attrUtil.buildCalculatedAttributes(mockPool, date);
assertTrue(attrs.containsKey("compliance_type"));
}
SuggestedQuantity suggested = new SuggestedQuantity();
suggested.setSuggested(1L);
suggested.setIncrement(1L);
Map<String, SuggestedQuantity> suggestedMap = new HashMap<>();
suggestedMap.put(pool1.getId(), suggested);
when(quantityRules.getSuggestedQuantities(any(List.class), any(Consumer.class), any(Date.class))).thenReturn(suggestedMap);
Date date = new Date();
attrUtil.setQuantityAttributes(pool1, consumer, date);
assertTrue(pool1.getCalculatedAttributes().containsKey("suggested_quantity"));
assertTrue(pool1.getCalculatedAttributes().containsKey("quantity_increment"));
}
use of org.candlepin.model.Pool.PoolComplianceType in project candlepin by candlepin.
the class CalculatedAttributesUtilTest method testCalculatedAttributesNotSoTemporary.
@Test
public void testCalculatedAttributesNotSoTemporary() {
for (PoolComplianceType type : PoolComplianceType.values()) {
when(mockPool.getComplianceType()).thenReturn(type);
when(mockPool.isUnmappedGuestPool()).thenReturn(false);
Date date = new Date();
Map<String, String> attrs = attrUtil.buildCalculatedAttributes(mockPool, date);
assertTrue(attrs.containsKey("compliance_type"));
assertEquals(type.getDescription(), attrs.get("compliance_type"));
}
}
use of org.candlepin.model.Pool.PoolComplianceType in project candlepin by candlepin.
the class CalculatedAttributesUtilTest method testCalculatedAttributesTemporary.
@Test
public void testCalculatedAttributesTemporary() {
for (PoolComplianceType type : PoolComplianceType.values()) {
when(mockPool.getComplianceType()).thenReturn(type);
when(mockPool.isUnmappedGuestPool()).thenReturn(true);
Date date = new Date();
Map<String, String> attrs = attrUtil.buildCalculatedAttributes(mockPool, date);
assertTrue(attrs.containsKey("compliance_type"));
assertEquals(type.getDescription() + " (Temporary)", attrs.get("compliance_type"));
}
}
use of org.candlepin.model.Pool.PoolComplianceType in project candlepin by candlepin.
the class CalculatedAttributesUtil method buildCalculatedAttributes.
public Map<String, String> buildCalculatedAttributes(Pool pool, Date date) {
Map<String, String> attrMap = new HashMap<>();
PoolComplianceType type = pool.getComplianceType();
// TODO: Check that this doesn't break our translation stuff. We may need to have the
// description strings translated instead.
attrMap.put("compliance_type", i18n.tr("{0}{1}", type.getDescription(), (pool.isUnmappedGuestPool() ? " (Temporary)" : "")));
return attrMap;
}
Aggregations