@Test public void canCalculateCarPolicyPrice() { Map<String, Object> subject = new HashMap<>(); subject.put("NUM_OF_CLAIM", 1); Calculation calculation = new Calculation( "CAR", LocalDate.of(2017, 4, 16), LocalDate.of(2018, 4, 15), Collections.singletonList("C1"), subject); Tariff tariff = TariffsFactory.car(); calculation = tariff.calculatePrice(calculation); assertEquals(new BigDecimal("100"), calculation.getTotalPremium(),"Total premium should be 100"); assertEquals(new BigDecimal("100"), calculation.getCovers().get("C1").getPrice(),"C1 premium should be 100"); }
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);  }