CalculPrice { public static final double getGenericPrice(double price, double discount, double taxe, int binaryMask) { if (hasOption(binaryMask, Type.DISCOUNT_COST)) { return getDiscountCost(price, discount); } if (hasOption(binaryMask, Type.TAXE_COST)) { return getTaxCost(price, taxe); } if (hasOption(binaryMask, Type.DISCOUNT)) { price = applyDiscount(price, discount); } if (hasOption(binaryMask, Type.TAXE)) { price = applyTax(price, taxe); } return price; }  static final double getGenericPrice(double price, double discount, double taxe, int binaryMask); static final double removeTaxe(double price, double tax); static final double getDiscountCost(double price, double discount); static final double applyDiscount(double price, double discount); static final double mergeDiscount(double productDiscount, double ticketDiscount); static double applyTax(double price, double taxRate); static double getTaxCost(double price, double taxRate); static double round(double number); static double round(double number, int decimalNumber); static final int DEFAULT_DECIMAL_NUMBER; }
@Test public void getPriceWithDiscountWithoutTaxeTest() { double discount = 0.2d; final double control = 40d; assertEquals(control, getGenericPrice(price, discount, taxe, Type.DISCOUNT)); }
@Test public void getPriceWithTaxeAndDiscount() { double discount = 0.1d; double taxe = 0.055d; final double control = 47.475d; assertEquals(control, getGenericPrice(price, discount, taxe, Type.DISCOUNT | Type.TAXE)); }