@Test public void canCalculateTravelPolicyPrice() { Map<String, Object> subject = new HashMap<>(); subject.put("NUM_OF_ADULTS", new BigDecimal("1")); subject.put("NUM_OF_CHILDREN", new BigDecimal("1")); subject.put("DESTINATION", "EUR"); Calculation calculation = new Calculation( "TRI", LocalDate.of(2017, 4, 16), LocalDate.of(2017, 4, 20), Arrays.asList("C1", "C2", "C3"), subject); Tariff tariff = TariffsFactory.travel(); calculation = tariff.calculatePrice(calculation); assertEquals(new BigDecimal("98.00"), calculation.getTotalPremium(), "Total premium should be 78"); assertEquals(new BigDecimal("26.00"), calculation.getCovers().get("C1").getPrice(), "C1 premium should be 26"); assertEquals(new BigDecimal("52.00"), calculation.getCovers().get("C2").getPrice(), "C2 should be 52"); assertEquals(new BigDecimal("20.00"), calculation.getCovers().get("C3").getPrice(),"C3 should be 20"); }
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);  }