### Question:
LineItemBuilder { static boolean isPriceBreakdownConsistent( Long unitPrice, BigDecimal quantity, Long totalPrice) { if (unitPrice == null || quantity == null || totalPrice == null) { return true; } BigDecimal expectedPrice = quantity.multiply(BigDecimal.valueOf(unitPrice)); BigDecimal actualPrice = BigDecimal.valueOf(totalPrice); if (expectedPrice.compareTo(BigDecimal.ZERO) == 0) { return totalPrice == 0; } double ratio = actualPrice.divide( expectedPrice, CONSISTENCY_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue(); return Math.abs(ratio - 1.0) < CONSISTENCY_THRESHOLD; } LineItemBuilder();   LineItemBuilder(String currencyCode); LineItemBuilder setCurrencyCode(String currencyCode); LineItemBuilder setUnitPrice(long unitPrice); LineItemBuilder setTotalPrice(long totalPrice); LineItemBuilder setQuantity(BigDecimal quantity); LineItemBuilder setQuantity(double quantity); LineItemBuilder setDescription(String description); LineItemBuilder setRole(int role); LineItem build(); static final Set<Integer> VALID_ROLES; }### Answer:
@Test public void isPriceBreakdownConsistent_whenItemsMultiplyClosely_returnsTrue() { assertTrue(isPriceBreakdownConsistent(1000L, BigDecimal.TEN, 10000L)); }
@Test public void isPriceBreakdownConsistent_whenAnyItemIsNull_returnsTrue() { assertTrue(isPriceBreakdownConsistent(null, BigDecimal.TEN, 1234L)); assertTrue(isPriceBreakdownConsistent(55L, null, 8888L)); assertTrue(isPriceBreakdownConsistent(33L, BigDecimal.ONE, null)); }
@Test public void isPriceBreakdownConsistent_whenItemsAreOffByALot_returnsFalse() { assertFalse(isPriceBreakdownConsistent(55L, BigDecimal.ONE, 56L)); }
@Test public void isPriceBreakdownConsistent_whenItemsAreOffByOnlyALittle_returnsTrue() { assertTrue(isPriceBreakdownConsistent(199L, BigDecimal.ONE, 200L)); }