# HG changeset patch # User japod@localhost # Date 1222774923 -7200 # Node ID f4b4f95ae1bd46c725ac69775b30552643d55c05 # Parent 5e73778cc1f1c5cbdb928242e4d8ec7305483d17 adding solution 13 diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/build.xml Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,69 @@ + + + + + + Builds, tests, and runs the project. + + + diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/nbproject/build-impl.xml Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,642 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/nbproject/genfiles.properties Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,8 @@ +build.xml.data.CRC32=2ab820eb +build.xml.script.CRC32=58a52595 +build.xml.stylesheet.CRC32=be360661 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=de21ce77 +nbproject/build-impl.xml.script.CRC32=0903858a +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5 diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/nbproject/project.properties Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,67 @@ +application.title=currency +application.vendor=apidesign.org +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/currency.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.src-apifest08=.. +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit_4.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding= +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +jnlp.codebase.type=local +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist +jnlp.descriptor=application +jnlp.enabled=false +jnlp.offline-allowed=false +jnlp.signed=false +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +src.dir=src +test.src.dir=test diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/nbproject/project.xml Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + Currency Convertor Solution 13 + 1.6.5 + + + + + + + + + diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/src/org/apidesign/apifest08/currency/ConversionResult.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/src/org/apidesign/apifest08/currency/ConversionResult.java Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,49 @@ + +package org.apidesign.apifest08.currency; + +import java.math.BigDecimal; + +/** + * Result of currency conversion. Holds converted value and remainder. + *

+ * Converter describes value converted to target value. Remainder describes + * how much from original amount was not possible to convert. Converted never loses any (small) money + * in conversion error (rounding), but instead of rounding is converts only as much as possible and keeps rest as remainder. + * + * @author arnostvalicek + */ +public class ConversionResult { + private BigDecimal converted; + private BigDecimal remainder; + + /** + * Get converted value. + * @return Returns converted value. + */ + public BigDecimal getConverted() { + return converted; + } + + void setConverted(BigDecimal converted) { + this.converted = converted; + } + + + /** + * Get remainder of conversion. Remainder is set if part of converted amount which can't be converted + * because this target currency precision can't handle small numbers. Remainder value is in from currency + *

+ * Converter never loses any precision in conversion. Remainer describes how much of amount can't be converted. + * If we substract remainder from amount we will be able to get exact conversion. + * + * @return Returns remainder of conversion. + */ + public BigDecimal getRemainder() { + return remainder; + } + + void setRemainder(BigDecimal remainder) { + this.remainder = remainder; + } + +} diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/src/org/apidesign/apifest08/currency/Convertor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/src/org/apidesign/apifest08/currency/Convertor.java Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,105 @@ +package org.apidesign.apifest08.currency; + +import java.math.BigDecimal; +import java.math.MathContext; +import java.math.RoundingMode; + +/** Convertor able to convert amount from one currency to other currency. + * + * Exchange rate is provided by {@link ExchangeRateProvider}. + */ +public class Convertor { + boolean remainderAllowed = false; //if false, remained is not allowed (should be true ideally, but can't handle it now) + ExchangeRateProvider exchangeRateProvider; + + private Convertor() { + + } + + /** + * Static method used to create convertor. + * + * @param exchangeRateProvider {@link ExchangeRateProvider} used to get exchange rate. + * + * @return Returns Convertor which can be used to convert money. + */ + public static Convertor createConvertor(ExchangeRateProvider exchangeRateProvider) { + Convertor c = new Convertor(); + + c.exchangeRateProvider = exchangeRateProvider; + return c; + } + + /** + * Convert amount from fromCurrency to toCurrency as specified + * in ExchangeRateProvider. + * + * @param amount Amount which should be converted. Can't be negative value (can be zero or positive). + * @return Return ConversionResult which holds conversion result. + */ + public ConversionResult convert(BigDecimal amount) { + return convertValue(amount, false); + } + + /** + * Convert amount from toCurrency to fromCurrency as specified + * in ExchangeRateProvider. This is reverted order than suggested by names of currency fields in ExchangeRate. + * + * @param amount Amount which should be converted. Can't be negative value (can be zero or positive). + * @return Return ConversionResult which holds conversion result. + */ + public ConversionResult convertBack(BigDecimal amount) { + return convertValue(amount, true); + } + + private ConversionResult convertValue(BigDecimal amount, boolean convertBack) throws RuntimeException { + ConversionResult result = new ConversionResult(); + + ExchangeRate rate = exchangeRateProvider.getExchangeRate(); + int fromFranctionDigits = exchangeRateProvider.getFromCurrency().getDefaultFractionDigits(); + int toFractionDigits = exchangeRateProvider.getToCurrency().getDefaultFractionDigits(); + + if (toFractionDigits!=2) { + throw new RuntimeException("Can't process currency with defaultFractionDigits!=2, "+exchangeRateProvider.getToCurrency()+" has "+toFractionDigits+" defaultFractionDigits"); + } + if (fromFranctionDigits!=2) { + throw new RuntimeException("Can't process currency with defaultFractionDigits!=2, "+exchangeRateProvider.getFromCurrency()+" has "+fromFranctionDigits+" defaultFractionDigits"); + } + + if (amount.signum()==-1) { + throw new RuntimeException("Can convert only non-negative value, current value is "+amount); + } + + + MathContext context = new MathContext(0, RoundingMode.DOWN); + + BigDecimal from; + BigDecimal to; + if (convertBack) { + //converting in reverted way + to = rate.getFromValue(); + from = rate.getToValue(); + } else { + //converting in mornak way + from = rate.getFromValue(); + to = rate.getToValue(); + } + + BigDecimal amountCent = amount.movePointRight(2); + + final BigDecimal multiplied = amountCent.multiply(to,context); + BigDecimal[] division = multiplied.divideAndRemainder(from,context); + + if (!remainderAllowed && !(BigDecimal.ZERO.equals(division[1]))) { + throw new RuntimeException("Remained is not allowed - remaining amount is " + division[1]+ " cents"); + } else { + result.setRemainder(BigDecimal.ZERO); + } + + final BigDecimal converted = division[0].movePointLeft(2); + result.setConverted(converted); + //result.setRemainder(...); + + return result; + } +} diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/src/org/apidesign/apifest08/currency/ConvertorCurrency.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/src/org/apidesign/apifest08/currency/ConvertorCurrency.java Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,46 @@ + +package org.apidesign.apifest08.currency; + +import java.util.Currency; + +/** + * Desription of currency. + * + * Java has similar class {@link java.util.Currency}, but original class is not flexible + * enough, we use our own implementation of currency. + * + * @author arnostvalicek + */ +public class ConvertorCurrency { + + private Currency currency; + + private void setJavaCurrency(Currency javaCurrency) { + this.currency = javaCurrency; + } + + /** + * Static method providing instance of ConvertorCurrency base of currency code. + * + * @param currencyCode Code of required currency. + * @return Returns required ConvertorCurrency + */ + public static ConvertorCurrency getInstance(String currencyCode) { + ConvertorCurrency convertorCurrency = new ConvertorCurrency(); + convertorCurrency.setJavaCurrency(Currency.getInstance(currencyCode)); + return convertorCurrency; + } + + /** + * Gets the default number of fraction digits used with this currency. For example, the default number of fraction digits for the Euro is 2, while for the Japanese Yen it's 0. + * @return Returns the default number of fraction digits used with this currency. + */ + public int getDefaultFractionDigits() { + return currency.getDefaultFractionDigits(); + } + + @Override + public String toString() { + return getClass() + " based on " + (currency != null ? currency.toString() : "NO-BASE-CURRENCY"); + } +} diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,41 @@ + +package org.apidesign.apifest08.currency; + +import java.math.BigDecimal; + +/** + * Exchange rate value. Contains from and to value. + * + * @author arnostvalicek + */ +public class ExchangeRate { + private BigDecimal numberFor; + private BigDecimal numberGet; + + public ExchangeRate(BigDecimal fromValue, BigDecimal toValue) { + this.numberFor = fromValue; + this.numberGet = toValue; + } + + @Override + public String toString() { + return "for "+numberFor+" recieve "+numberGet+" @"+getClass().getName(); + } + + public BigDecimal getFromValue() { + return numberFor; + } + + public BigDecimal getToValue() { + return numberGet; + } + + +// public ExchangeRate createExchangeRate(BigDecimal forValue, BigDecimal getValue) { +// ExchangeRate rate = new ExchangeRate(forValue, getValue); +// return rate; +// } + + + +} diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/src/org/apidesign/apifest08/currency/ExchangeRateProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/src/org/apidesign/apifest08/currency/ExchangeRateProvider.java Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,62 @@ + +package org.apidesign.apifest08.currency; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * Exchange rate provider - can provide fixed exchange rate which does not depend + * on date (method {@link #getExchangeRate()} ) or exchange rate based on date (method {@link #getExchangeRate(java.util.Date) }). + * + * + * @author arnostvalicek + */ +public class ExchangeRateProvider { + BigDecimal fromValue, toValue; + ConvertorCurrency fromCurrency, toCurrency; + + /** + * Simple constructor for ExchangeRateProviderM which can provide fixed exchange rate. + * + * Describes conversion from to to currency. + * + * @param fromValue From value. BigDecimal value, precision should be set to currency precision. + * @param fromCurrency From currency. + * @param toValue To value. BigDecimal value, precision should be set to currency precision. + * @param toCurrency To currency. + */ + public ExchangeRateProvider(BigDecimal fromValue, ConvertorCurrency fromCurrency, BigDecimal toValue, ConvertorCurrency toCurrency) { + this.fromValue = fromValue; + this.toValue = toValue; + this.fromCurrency = fromCurrency; + this.toCurrency = toCurrency; + } + + /** + * Get fixed exange rate for currencies (from->to). + * @return Returns exchange rate. + */ + public ExchangeRate getExchangeRate() { + return new ExchangeRate(fromValue, toValue); + } + + /** + * Get exchange rate for currencies (from->to) based on provided date. + * @param date Date for which exchange rate should be provided. + * @return Returns exchange rate + */ + public ExchangeRate getExchangeRate(Date date) { + return new ExchangeRate(fromValue, toValue); + } + + + ConvertorCurrency getFromCurrency() { + return fromCurrency; + } + + ConvertorCurrency getToCurrency() { + return toCurrency; + } + + +} diff -r 5e73778cc1f1 -r f4b4f95ae1bd task1/solution13/test/org/apidesign/apifest08/test/Task1Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task1/solution13/test/org/apidesign/apifest08/test/Task1Test.java Tue Sep 30 13:42:03 2008 +0200 @@ -0,0 +1,209 @@ +package org.apidesign.apifest08.test; + +import java.math.BigDecimal; +import junit.framework.TestCase; +import org.apidesign.apifest08.currency.ConversionResult; +import org.apidesign.apifest08.currency.Convertor; +import org.apidesign.apifest08.currency.ConvertorCurrency; +import org.apidesign.apifest08.currency.ExchangeRateProvider; + +/** Finish the Convertor API, and then write bodies of methods inside + * of this class to match the given tasks. To fullfil your task, use the + * API define in the org.apidesign.apifest08.currency package. + * Do not you reflection, or other hacks as your code + * shall run without any runtime permissions. + */ +public class Task1Test extends TestCase { + public Task1Test(String testName) { + super(testName); + } + + @Override + protected void setUp() throws Exception { + } + + @Override + protected void tearDown() throws Exception { + } + + /** Create convertor that understands two currencies, CZK and + * USD. Make 1 USD == 17 CZK. + * + * Creation of the convertor shall not require subclassing of any class + * or interface on the client side. + * + * @return prepared convertor ready for converting USD to CZK and CZK to USD + */ + public Convertor createCZKtoUSD() { + ConvertorCurrency fromCurrency = ConvertorCurrency.getInstance("CZK"); + ConvertorCurrency toCurrency = ConvertorCurrency.getInstance("USD"); + ExchangeRateProvider exchangeRateProvider = new ExchangeRateProvider(new BigDecimal(17), fromCurrency, new BigDecimal(1), toCurrency); + + return Convertor.createConvertor(exchangeRateProvider); + } + + /** Create convertor that understands two currencies, CZK and + * SKK. Make 100 SKK == 80 CZK. + * + * Creation of the convertor shall not require subclassing of any class + * or interface on the client side. + * + * @return prepared convertor ready for converting SKK to CZK and CZK to SKK + */ + public Convertor createSKKtoCZK() { + ConvertorCurrency fromCurrency = ConvertorCurrency.getInstance("SKK"); + ConvertorCurrency toCurrency = ConvertorCurrency.getInstance("CZK"); + ExchangeRateProvider exchangeRateProvider = new ExchangeRateProvider(new BigDecimal(100), fromCurrency, new BigDecimal(80), toCurrency); + + return Convertor.createConvertor(exchangeRateProvider); + } + + + public Convertor createCZKtoYEN() { + ConvertorCurrency fromCurrency = ConvertorCurrency.getInstance("CZK"); + ConvertorCurrency toCurrency = ConvertorCurrency.getInstance("JPY"); + ExchangeRateProvider exchangeRateProvider = new ExchangeRateProvider(new BigDecimal(1), fromCurrency, new BigDecimal(1), toCurrency); + + return Convertor.createConvertor(exchangeRateProvider); + } + + /** Use the convertor from createCZKtoUSD method and do few conversions + * with it. + */ + public void testCurrencyCZKUSD() throws Exception { + Convertor convertCzkUsd = createCZKtoUSD(); + + { + // convert $1 to CZK using c: + ConversionResult result = convertCzkUsd.convertBack(new BigDecimal(1)); + assertEquals("Result is 17 CZK", new BigDecimal("17.00"), result.getConverted()); + assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder()); + } + + { + // convert 17CKZ to $ using c: + ConversionResult result = convertCzkUsd.convert(new BigDecimal(17)); + assertEquals("Result is 1 $", new BigDecimal("1.00"), result.getConverted()); + assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder()); + } + + { + // convert $5 to CZK using c: + ConversionResult result = convertCzkUsd.convertBack(new BigDecimal(5)); + assertEquals("Result is 85 CZK", new BigDecimal("85.00"), result.getConverted()); + assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder()); + } + + { + // convert $8 to CZK + ConversionResult result = convertCzkUsd.convertBack(new BigDecimal(8)); + assertEquals("Result is 136 CZK", new BigDecimal("136.00"), result.getConverted()); + assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder()); + } + + { + // convert 1003CZK to USD + ConversionResult result = convertCzkUsd.convert(new BigDecimal(1003)); + assertEquals("Result is 59 USD", new BigDecimal("59.00"), result.getConverted()); + assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder()); + } + } + + /** Use the convertor from createSKKtoCZK method and do few conversions + * with it. + */ + public void testCurrencySKKCZK() throws Exception { + Convertor convertSkkCzk = createSKKtoCZK(); + { + // convert 100SKK using c: + ConversionResult result = convertSkkCzk.convert(new BigDecimal(100)); + assertEquals("Result is 80 CZK", new BigDecimal("80.00"), result.getConverted()); + } + { + // convert 80CZK using c: + ConversionResult result = convertSkkCzk.convertBack(new BigDecimal(80)); + assertEquals("Result is 100 SKK", new BigDecimal("100.00"), result.getConverted()); + } + + { + // convert 16CZK using c: + ConversionResult result = convertSkkCzk.convertBack(new BigDecimal(16)); + assertEquals("Result is 20 SKK", new BigDecimal("20.00"), result.getConverted()); + } + + { + // convert 500SKK to CZK + ConversionResult result = convertSkkCzk.convert(new BigDecimal(500)); + assertEquals("Result is 400 CZK", new BigDecimal("400.00"), result.getConverted()); + assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder()); + } + + { + // convert 501SKK to CZK + ConversionResult result = convertSkkCzk.convert(new BigDecimal(501)); + assertEquals("Result is 400 CZK", new BigDecimal("400.80"), result.getConverted()); + assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder()); + + } + } + + /** + * Convert SKK to CZK. Convertor can't convert whole amout (can't convert one SKK cent to CZK). Remaining + * amount is stored in remainder result. + * + * Test is currently failing, because implementation can't handle this case. + */ +// public void testConvertSmallUnits_failing() { +// Convertor convertSkkCzk = createSKKtoCZK(); +// { +// // convert 501SKK to CZK +// ConversionResult result = convertSkkCzk.convert(new BigDecimal("501.01")); +// assertEquals("Result is 400 CZK", new BigDecimal("400.80"), result.getConverted()); +// assertEquals("No Remainer", new BigDecimal("0.01"), result.getRemainder()); +// +// } +// +// } + + /** + * Test converting from CZK to JPY. Remained has scale of CZK. + * + * This test is currently failing, because converter implementation currently can't handle conversion from "cent" to "no-cent" currency. + */ +// public void testConvertCzkToJpy_failing() { +// Convertor convertSkkCzk = createCZKtoYEN(); +// { +// // convert 501SKK to CZK +// ConversionResult result = convertSkkCzk.convert(new BigDecimal("120.00")); +// assertEquals("Result is 120 YEN", new BigDecimal("120"), result.getConverted()); +// assertEquals("No Remainer", new BigDecimal("0.00"), result.getRemainder()); +// +// } +// } + + /** + * Test converting from JPY to CZK. Remained has scale of JPY. + * + * This test is currently failing, because converter implementation currently can't handle conversion from "cent" to "no-cent" currency. + */ +// public void testConvertJpyToCzk_failing() { +// Convertor convertSkkCzk = createCZKtoYEN(); +// { +// // convert 501SKK to CZK +// ConversionResult result = convertSkkCzk.convert(new BigDecimal("120.00")); +// assertEquals("Result is 120 YEN", new BigDecimal("120"), result.getConverted()); +// assertEquals("No Remainer", new BigDecimal("0"), result.getRemainder()); +// +// } +// } + + public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception { + Convertor c = createCZKtoUSD(); + // convert $5 to SKK, the API shall say this is not possible + // convert 500 SKK to CZK, the API shall say this is not possible + // ... no api for required call, should be here? + } + + +} +