[BAEL-6697] code for jacoco fail build
This commit is contained in:
+8
-2
@@ -3,7 +3,13 @@ package com.baeldung.jacocoexclusions.service;
|
||||
public class ProductService {
|
||||
private static final double DISCOUNT = 0.25;
|
||||
|
||||
public double getSalePrice(double originalPrice) {
|
||||
return originalPrice - originalPrice * DISCOUNT;
|
||||
public double getSalePrice(double originalPrice, boolean flag) {
|
||||
double discount;
|
||||
if (flag) {
|
||||
discount = originalPrice - originalPrice * DISCOUNT;
|
||||
} else {
|
||||
discount = originalPrice;
|
||||
}
|
||||
return discount;
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -9,7 +9,13 @@ class ProductServiceUnitTest {
|
||||
@Test
|
||||
public void givenOriginalPrice_whenGetSalePrice_thenReturnsDiscountedPrice() {
|
||||
ProductService productService = new ProductService();
|
||||
double salePrice = productService.getSalePrice(100);
|
||||
double salePrice = productService.getSalePrice(100, true);
|
||||
assertEquals(salePrice, 75);
|
||||
}
|
||||
@Test
|
||||
public void givenOriginalPrice_whenGetSalePriceWithFlagFalse_thenReturnsDiscountedPrice() {
|
||||
ProductService productService = new ProductService();
|
||||
double salePrice = productService.getSalePrice(100, false);
|
||||
assertEquals(salePrice, 100);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user