3 import java.math.BigDecimal;
4 import java.util.Currency;
5 import junit.framework.TestCase;
6 import org.apidesign.apifest08.currency.Convertor;
7 import org.apidesign.apifest08.currency.InvalidConversionException;
10 /** Write a test that works with version from task A and fails with version B.
12 public class CurrencyTest extends TestCase {
13 public CurrencyTest(String n) {
17 public void testCompatibility() throws Exception {
18 Convertor myOwnImplementationOfConvertor =
19 new MyOwnImplementationOfConvertor();
21 BigDecimal result = myOwnImplementationOfConvertor.convert(
22 Currency.getInstance("CZK"),
23 Currency.getInstance("USD"),
25 assertEquals(1, result.intValue());
28 class MyOwnImplementationOfConvertor implements Convertor {
29 public BigDecimal convert(Currency from, Currency to, BigDecimal amount) throws InvalidConversionException {
30 return amount; // not very smart implementation