@Test public void canCalculateHousePolicyPrice() { Map<String, Object> subject = new HashMap<>(); subject.put("TYP", "APT"); subject.put("AREA", new BigDecimal("95")); subject.put("NUM_OF_CLAIM", 1); subject.put("FLOOD", "NO"); Calculation calculation = new Calculation( "HSI", LocalDate.of(2017, 4, 16), LocalDate.of(2018, 4, 15), Arrays.asList("C1", "C2", "C3"), subject); Tariff tariff = TariffsFactory.house(); calculation = tariff.calculatePrice(calculation); assertEquals(new BigDecimal("172.50"), calculation.getTotalPremium(),"Total premium should be 172.50"); assertEquals(new BigDecimal("118.75"), calculation.getCovers().get("C1").getPrice(),"C1 premium should be 118.75"); assertEquals(new BigDecimal("23.75"), calculation.getCovers().get("C2").getPrice(),"C2 should be 23.75"); assertEquals(new BigDecimal("30"), calculation.getCovers().get("C3").getPrice(),"C3 should be 30"); }
public Calculation calculatePrice(Calculation calculation) { calcBasePrices(calculation); applyDiscounts(calculation); buildResponse(calculation); return calculation; }
Tariff { public Calculation calculatePrice(Calculation calculation) { calcBasePrices(calculation); applyDiscounts(calculation); buildResponse(calculation); return calculation; } }
Tariff { public Calculation calculatePrice(Calculation calculation) { calcBasePrices(calculation); applyDiscounts(calculation); buildResponse(calculation); return calculation; } Tariff( String code); }
Tariff { public Calculation calculatePrice(Calculation calculation) { calcBasePrices(calculation); applyDiscounts(calculation); buildResponse(calculation); return calculation; } Tariff( String code); BasePremiumCalculationRuleList rules(); DiscountMarkupRuleList discountMarkupRules(); Calculation calculatePrice(Calculation calculation); }
Tariff { public Calculation calculatePrice(Calculation calculation) { calcBasePrices(calculation); applyDiscounts(calculation); buildResponse(calculation); return calculation; } Tariff( String code); BasePremiumCalculationRuleList rules(); DiscountMarkupRuleList discountMarkupRules(); Calculation calculatePrice(Calculation calculation);  }