CalculatedAttributesUtil { public Map<String, String> buildCalculatedAttributes(Pool pool, Date date) { Map<String, String> attrMap = new HashMap<>(); PoolComplianceType type = pool.getComplianceType(); attrMap.put("compliance_type", i18n.tr("{0}{1}", type.getDescription(), (pool.isUnmappedGuestPool() ? " (Temporary)" : "")) ); return attrMap; } @Inject  CalculatedAttributesUtil(QuantityRules quantityRules, I18n i18n); Map<String, String> buildCalculatedAttributes(Pool pool, Date date); void setCalculatedAttributes(List<Pool> poolList, Date date); void setQuantityAttributes(Pool pool, Consumer c, Date date); void setQuantityAttributes(List<Pool> poolList, Consumer c, Date date);  }
@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")); } }
@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")); } }