package io.github.zutherb.appstash.shop.repository.order.model;

import io.github.zutherb.appstash.shop.repository.product.model.Product;
import io.github.zutherb.appstash.shop.repository.product.model.ProductType;
import org.junit.Before;
import org.junit.Test;

import java.math.BigDecimal;

import static org.junit.Assert.assertEquals;

/**
 * @author zuther
 */
public class OrderTest {
    Order order;

    @Before
    public void setUp() throws Exception {
        order = new Order();

        Product product = new Product("1", ProductType.HANDY, "product", 4);

        OrderItem orderItem1 = new OrderItem(product);
        OrderItem orderItem2 = new OrderItem(product);

        order.getOrderItems().add(orderItem1);
        order.getOrderItems().add(orderItem2);
    }

    @Test
    public void testGetProductCount() throws Exception {
        assertEquals(BigDecimal.valueOf(2).compareTo(order.getItemCount()), 0);
    }

    @Test
    public void testGetTotalSum() throws Exception {
        assertEquals(BigDecimal.valueOf(8).compareTo(order.getTotalSum()), 0);
    }
}

@@ -208,16 +208,70 @@
 ctType;%0A
+import io.github.zutherb.appstash.common.util.Config;%0A
 import o
@@ -287,16 +287,16 @@
 Before;%0A
-
 import o
@@ -618,9 +618,9 @@
 t%22, 
-4
+5
 );%0A%0A
@@ -1040,32 +1040,186 @@
 ows Exception %7B%0A
+        double globalDiscount = Double.parseDouble(Config.getProperty(%22GLOBAL_DISCOUNT%22));%0A        double total = 10.0 - (10.0 * (globalDiscount/100.0));%0A
         assertEq
@@ -1246,9 +1246,13 @@
 eOf(
-8
+total
 ).co
@@ -1291,10 +1291,337 @@
 ;%0A    %7D%0A
+    %0A    @Test%0A    public void testGetDiscountSum() throws Exception %7B%0A        double globalDiscount = Double.parseDouble(Config.getProperty(%22GLOBAL_DISCOUNT%22));%0A        double discount = 10.0 * (globalDiscount/100.0);        %0A        assertEquals(BigDecimal.valueOf(discount).compareTo(order.getDiscountSum()), 0);%0A    %7D%0A    %0A
 %7D%0A

Update OrderTest.java