// Path: src/main/java/com/in28minutes/junit/business/ClientBO.java
// public interface ClientBO {
// 
// 	Amount getClientProductsSum(List<Product> products)
// 			throws DifferentCurrenciesException;
// 
// }
// 
// Path: src/main/java/com/in28minutes/junit/business/ClientBOImpl.java
// public class ClientBOImpl implements ClientBO {
// 
// 	public Amount getClientProductsSum(List<Product> products)
// 			throws DifferentCurrenciesException {
// 
// 		if (products.size() == 0)
// 			return new AmountImpl(BigDecimal.ZERO, Currency.EURO);
// 
// 		if (!isCurrencySameForAllProducts(products)) {
// 			throw new DifferentCurrenciesException();
// 		}
// 
// 		BigDecimal productSum = calculateProductSum(products);
// 
// 		Currency firstProductCurrency = products.get(0).getAmount()
// 				.getCurrency();
// 
// 		return new AmountImpl(productSum, firstProductCurrency);
// 	}
// 
// 	private BigDecimal calculateProductSum(List<Product> products) {
// 		BigDecimal sum = BigDecimal.ZERO;
// 		// Calculate Sum of Products
// 		for (Product product : products) {
// 			sum = sum.add(product.getAmount().getValue());
// 		}
// 		return sum;
// 	}
// 
// 	private boolean isCurrencySameForAllProducts(List<Product> products)
// 			throws DifferentCurrenciesException {
// 
// 		Currency firstProductCurrency = products.get(0).getAmount()
// 				.getCurrency();
// 
// 		for (Product product : products) {
// 			boolean currencySameAsFirstProduct = product.getAmount()
// 					.getCurrency().equals(firstProductCurrency);
// 			if (!currencySameAsFirstProduct) {
// 				return false;
// 			}
// 		}
// 
// 		return true;
// 	}
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/Amount.java
// public interface Amount {
// 	BigDecimal getValue();
// 
// 	Currency getCurrency();
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/Currency.java
// public enum Currency {
// 
// 	EURO("EUR"), UNITED_STATES_DOLLAR("USD"), INDIAN_RUPEE("INR");
// 
// 	private final String textValue;
// 
// 	Currency(final String textValue) {
// 		this.textValue = textValue;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return textValue;
// 	}
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/Product.java
// public interface Product {
// 
// 	long getId();
// 
// 	String getName();
// 
// 	ProductType getType();
// 
// 	Amount getAmount();
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/ProductImpl.java
// public class ProductImpl implements Product {
// 
// 	private long id;
// 
// 	private String name;
// 
// 	private ProductType type;
// 
// 	private Amount amount;
// 
// 	public ProductImpl(long id, String name, ProductType type, Amount amount) {
// 		super();
// 		this.id = id;
// 		this.name = name;
// 		this.type = type;
// 		this.amount = amount;
// 	}
// 
// 	@Override
// 	public long getId() {
// 		return id;
// 	}
// 
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 
// 	@Override
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	@Override
// 	public ProductType getType() {
// 		return type;
// 	}
// 
// 	public void setType(ProductType type) {
// 		this.type = type;
// 	}
// 
// 	@Override
// 	public Amount getAmount() {
// 		return amount;
// 	}
// 
// 	public void setAmount(Amount amount) {
// 		this.amount = amount;
// 	}
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.in28minutes.junit.business.ClientBO;
import com.in28minutes.junit.business.ClientBOImpl;
import com.in28minutes.junit.business.exception.DifferentCurrenciesException;
import com.in28minutes.junit.model.Amount;
import com.in28minutes.junit.model.AmountImpl;
import com.in28minutes.junit.model.Currency;
import com.in28minutes.junit.model.Product;
import com.in28minutes.junit.model.ProductImpl;
import com.in28minutes.junit.model.ProductType;

package com.clarity.business;





public class ClientBOTest {

	private ClientBO clientBO = new ClientBOImpl();

	@Test
	public void testClientProductSum() throws DifferentCurrenciesException {

		List<Product> products = new ArrayList<Product>();

		products.add(new ProductImpl(100, "Product 15",
				ProductType.BANK_GUARANTEE, new AmountImpl(
						new BigDecimal("5.0"), Currency.EURO)));

		products.add(new ProductImpl(120, "Product 20",
				ProductType.BANK_GUARANTEE, new AmountImpl(
						new BigDecimal("6.0"), Currency.EURO)));


// Path: src/main/java/com/in28minutes/junit/business/ClientBO.java
// public interface ClientBO {
// 
// 	Amount getClientProductsSum(List<Product> products)
// 			throws DifferentCurrenciesException;
// 
// }
// 
// Path: src/main/java/com/in28minutes/junit/business/ClientBOImpl.java
// public class ClientBOImpl implements ClientBO {
// 
// 	public Amount getClientProductsSum(List<Product> products)
// 			throws DifferentCurrenciesException {
// 
// 		if (products.size() == 0)
// 			return new AmountImpl(BigDecimal.ZERO, Currency.EURO);
// 
// 		if (!isCurrencySameForAllProducts(products)) {
// 			throw new DifferentCurrenciesException();
// 		}
// 
// 		BigDecimal productSum = calculateProductSum(products);
// 
// 		Currency firstProductCurrency = products.get(0).getAmount()
// 				.getCurrency();
// 
// 		return new AmountImpl(productSum, firstProductCurrency);
// 	}
// 
// 	private BigDecimal calculateProductSum(List<Product> products) {
// 		BigDecimal sum = BigDecimal.ZERO;
// 		// Calculate Sum of Products
// 		for (Product product : products) {
// 			sum = sum.add(product.getAmount().getValue());
// 		}
// 		return sum;
// 	}
// 
// 	private boolean isCurrencySameForAllProducts(List<Product> products)
// 			throws DifferentCurrenciesException {
// 
// 		Currency firstProductCurrency = products.get(0).getAmount()
// 				.getCurrency();
// 
// 		for (Product product : products) {
// 			boolean currencySameAsFirstProduct = product.getAmount()
// 					.getCurrency().equals(firstProductCurrency);
// 			if (!currencySameAsFirstProduct) {
// 				return false;
// 			}
// 		}
// 
// 		return true;
// 	}
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/Amount.java
// public interface Amount {
// 	BigDecimal getValue();
// 
// 	Currency getCurrency();
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/Currency.java
// public enum Currency {
// 
// 	EURO("EUR"), UNITED_STATES_DOLLAR("USD"), INDIAN_RUPEE("INR");
// 
// 	private final String textValue;
// 
// 	Currency(final String textValue) {
// 		this.textValue = textValue;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return textValue;
// 	}
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/Product.java
// public interface Product {
// 
// 	long getId();
// 
// 	String getName();
// 
// 	ProductType getType();
// 
// 	Amount getAmount();
// }
// 
// Path: src/main/java/com/in28minutes/junit/model/ProductImpl.java
// public class ProductImpl implements Product {
// 
// 	private long id;
// 
// 	private String name;
// 
// 	private ProductType type;
// 
// 	private Amount amount;
// 
// 	public ProductImpl(long id, String name, ProductType type, Amount amount) {
// 		super();
// 		this.id = id;
// 		this.name = name;
// 		this.type = type;
// 		this.amount = amount;
// 	}
// 
// 	@Override
// 	public long getId() {
// 		return id;
// 	}
// 
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 
// 	@Override
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	@Override
// 	public ProductType getType() {
// 		return type;
// 	}
// 
// 	public void setType(ProductType type) {
// 		this.type = type;
// 	}
// 
// 	@Override
// 	public Amount getAmount() {
// 		return amount;
// 	}
// 
// 	public void setAmount(Amount amount) {
// 		this.amount = amount;
// 	}
// }


// Path: src/test/java/com/clarity/business/ClientBOTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.in28minutes.junit.business.ClientBO;
import com.in28minutes.junit.business.ClientBOImpl;
import com.in28minutes.junit.business.exception.DifferentCurrenciesException;
import com.in28minutes.junit.model.Amount;
import com.in28minutes.junit.model.AmountImpl;
import com.in28minutes.junit.model.Currency;
import com.in28minutes.junit.model.Product;
import com.in28minutes.junit.model.ProductImpl;
import com.in28minutes.junit.model.ProductType;

package com.clarity.business;





public class ClientBOTest {

	private ClientBO clientBO = new ClientBOImpl();

	@Test
	public void testClientProductSum() throws DifferentCurrenciesException {

		List<Product> products = new ArrayList<Product>();

		products.add(new ProductImpl(100, "Product 15",
				ProductType.BANK_GUARANTEE, new AmountImpl(
						new BigDecimal("5.0"), Currency.EURO)));

		products.add(new ProductImpl(120, "Product 20",
				ProductType.BANK_GUARANTEE, new AmountImpl(
						new BigDecimal("6.0"), Currency.EURO)));


		Amount temp = clientBO.getClientProductsSum(products);
