import junit.framework.TestCase;

import java.util.List;
import java.util.logging.Logger;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.SQLException;
import java.math.BigDecimal;

public class ProductShipperV1Test extends TestCase {
    private ProductShipperV1 productShipper;
    private Product product;

    protected void setUp() throws Exception {
        productShipper = new ProductShipperV1();
        product = new Product();
    }

    public void testCalculateChargesWithEvenNumberOfKilosProduct() {
        product.setWeightInKilograms(3);

        assertEquals(new BigDecimal(3.75), productShipper.calculateShippingCharges(product));

    }

    public void testCalculateChargesWithFractionalWeightProduct() {
        product.setWeightInKilograms(1.5f);

        assertEquals(new BigDecimal(1.875), productShipper.calculateShippingCharges(product));

    }

    public void testCalculateChargesThrowsExceptionWithZeroWeightProduct() {
        product.setWeightInKilograms(0f);

        try {
            productShipper.calculateShippingCharges(product);
            fail("Expected exception not thrown");
        } catch (IllegalArgumentException expected) {
            assertTrue(true);
        }

    }

    public void testCalculateChargesThrowsExceptionWithNegativeWeightProduct() {
        product.setWeightInKilograms(-1.25f);

        try {
            productShipper.calculateShippingCharges(product);
            fail("Expected exception not thrown");
        } catch (IllegalArgumentException expected) {
            assertTrue(true);
        }

    }
}
