From 9d66fb3ecd99d8dd1932665944f1de8b2caa2606 Mon Sep 17 00:00:00 2001 From: atsticks Date: Sun, 8 Mar 2015 10:19:01 +0100 Subject: [PATCH] Merged changes due to lost repo connection. Should reestablish 1.0-RC3. --- .gitignore | 4 +- README.txt | 7 +- pom.xml | 47 ++++-- .../tck/JSR354TestConfiguration.java | 2 +- .../java/org/javamoney/tck/TCKRunner.java | 88 +++++------- .../java/org/javamoney/tck/TCKTestSetup.java | 32 ++--- .../javamoney/tck/TCKValidationException.java | 14 +- .../java/org/javamoney/tck/TestUtils.java | 134 ++++++++---------- .../tests/FunctionalExtensionPointsTest.java | 16 +-- .../tck/tests/ModellingCurrenciesTest.java | 48 +++---- .../org/javamoney/tck/tests/TCKSetupTest.java | 6 +- .../tests/conversion/ProviderChainsTest.java | 22 +-- .../internal/TestMonetaryAmountBuilder.java | 30 ++-- .../TestMonetaryAmountFactoryProvider.java | 12 +- .../tck/tests/internal/TestNumberValue.java | 40 +++--- .../tck/tests/internal/TestRateProvider.java | 40 +++--- .../tck/tests/internal/TestRateProvider1.java | 20 +-- .../tck/tests/internal/TestRateProvider2.java | 20 +-- 18 files changed, 297 insertions(+), 285 deletions(-) diff --git a/.gitignore b/.gitignore index 8a30ef3..778c95d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -money-tck.iml -.project -.classpath +../../git/jsr354-tck/money-tck.iml target/ test-output/ *.iml diff --git a/README.txt b/README.txt index 05c2532..9a4a3e7 100644 --- a/README.txt +++ b/README.txt @@ -16,9 +16,14 @@ To setup the TCK with your implementation you must follow the following steps: To execute the TCK, simply execute -mvn clean test site + mvn clean test site 5) Go to target/site - there you will find your TCK test results. + + +As jump-start you can clone https://github.com/JavaMoney/jsr354-ritest . + +The JSR 354 Team. diff --git a/pom.xml b/pom.xml index 64f57b8..9f687e4 100644 --- a/pom.xml +++ b/pom.xml @@ -17,13 +17,13 @@ org.javamoney javamoney-parent - 1.0-RC2 + 1.0-RC3 javamoney-tck jar - 1.0-SNAPSHOT + 1.0-RC3 JSR 354 (TCK) http://java.net/projects/javamoney @@ -46,7 +46,7 @@ - 1.0-SNAPSHOT + 1.0-RC3 1.8 ${jdkVersion} ${jdkVersion} @@ -389,6 +389,21 @@ org.asciidoctor asciidoctor-maven-plugin + 1.5.2 + + + org.asciidoctor + asciidoctorj-pdf + 1.5.0-alpha.6 + + + + src/main/asciidoc + ${project.basedir} + src/main/asciidoc/images/ + true + + output-html @@ -398,16 +413,28 @@ target/docs - highlightjs + coderay html - true - arc/main/asciidoc/images - + + output-pdf + prepare-package + + process-asciidoc + + + pdf + + coderay + + + + + - + + + diff --git a/src/main/java/org/javamoney/tck/JSR354TestConfiguration.java b/src/main/java/org/javamoney/tck/JSR354TestConfiguration.java index 43e3478..a27e296 100644 --- a/src/main/java/org/javamoney/tck/JSR354TestConfiguration.java +++ b/src/main/java/org/javamoney/tck/JSR354TestConfiguration.java @@ -22,7 +22,7 @@ * * @author Anatole Tresch */ -public interface JSR354TestConfiguration{ +public interface JSR354TestConfiguration { /** * Return a collection with all {@link MonetaryAmount} classes that are implemented. The list diff --git a/src/main/java/org/javamoney/tck/TCKRunner.java b/src/main/java/org/javamoney/tck/TCKRunner.java index e0bb06a..162ecaa 100644 --- a/src/main/java/org/javamoney/tck/TCKRunner.java +++ b/src/main/java/org/javamoney/tck/TCKRunner.java @@ -34,8 +34,8 @@ * Main class for executing the JSR 354 TCK. * Created by Anatole on 12.06.2014. */ -public class TCKRunner extends XmlSuite{ - public TCKRunner(){ +public class TCKRunner extends XmlSuite { + public TCKRunner() { setName("JSR354-TCK 1.0"); XmlTest test = new XmlTest(this); test.setName("TCK/Test Setup"); @@ -55,7 +55,7 @@ public TCKRunner(){ test.setXmlClasses(classes); } - public static void main(String... args){ + public static void main(String... args) { System.out.println("-- JSR 354 TCK started --"); List suites = new ArrayList<>(); suites.add(new TCKRunner()); @@ -72,7 +72,7 @@ public static void main(String... args){ System.out.println("-- JSR 354 TCK finished --"); } - public static final class TCKReporter extends TestListenerAdapter{ + public static final class TCKReporter extends TestListenerAdapter { private int count = 0; private int skipped = 0; private int failed = 0; @@ -81,101 +81,92 @@ public static final class TCKReporter extends TestListenerAdapter{ private StringWriter internalBuffer = new StringWriter(3000); private FileWriter w; - public TCKReporter(File file){ - try{ - if(!file.exists()){ + public TCKReporter(File file) { + try { + if (!file.exists()) { file.createNewFile(); } w = new FileWriter(file); w.write("*****************************************************************************************\n"); w.write("**** JSR 354 - Money & Currency, Technical Compatibility Kit, version 1.0\n"); w.write("*****************************************************************************************\n\n"); - w.write("Executed on " + new java.util.Date() +"\n\n" ); + w.write("Executed on " + new java.util.Date() + "\n\n"); // System.out: internalBuffer.write("*****************************************************************************************\n"); internalBuffer.write("**** JSR 354 - Money & Currency, Technical Compatibility Kit, version 1.0\n"); internalBuffer.write("*****************************************************************************************\n\n"); internalBuffer.write("Executed on " + new java.util.Date() + "\n\n"); - } - catch(IOException e){ + } catch (IOException e) { e.printStackTrace(); System.exit(-1); } } @Override - public void onTestFailure(ITestResult tr){ + public void onTestFailure(ITestResult tr) { failed++; - String location = tr.getTestClass().getRealClass().getSimpleName()+'#'+tr.getMethod().getMethodName(); - try{ + String location = tr.getTestClass().getRealClass().getSimpleName() + '#' + tr.getMethod().getMethodName(); + try { Method realTestMethod = tr.getMethod().getMethod(); Test testAnnot = realTestMethod.getAnnotation(Test.class); - if(testAnnot!=null && testAnnot.description()!=null && !testAnnot.description().isEmpty()){ - if(tr.getThrowable()!=null){ + if (testAnnot != null && testAnnot.description() != null && !testAnnot.description().isEmpty()) { + if (tr.getThrowable() != null) { StringWriter sw = new StringWriter(); PrintWriter w = new PrintWriter(sw); tr.getThrowable().printStackTrace(w); w.flush(); - log("[FAILED] " + testAnnot.description() + "("+location+"):\n"+sw.toString()); - } - else{ - log("[FAILED] " + testAnnot.description()+ "("+location+")"); + log("[FAILED] " + testAnnot.description() + "(" + location + "):\n" + sw.toString()); + } else { + log("[FAILED] " + testAnnot.description() + "(" + location + ")"); } - } - else{ + } else { - if(tr.getThrowable()!=null){ + if (tr.getThrowable() != null) { StringWriter sw = new StringWriter(); PrintWriter w = new PrintWriter(sw); tr.getThrowable().printStackTrace(w); w.flush(); - log("[FAILED] " + location + ":\n"+sw.toString()); - } - else{ + log("[FAILED] " + location + ":\n" + sw.toString()); + } else { log("[FAILED] " + location); } } - } - catch(IOException e){ + } catch (IOException e) { throw new IllegalStateException("IO Error", e); } } @Override - public void onTestSkipped(ITestResult tr){ + public void onTestSkipped(ITestResult tr) { skipped++; - String location = tr.getTestClass().getRealClass().getSimpleName()+'#'+tr.getMethod().getMethodName(); - try{ + String location = tr.getTestClass().getRealClass().getSimpleName() + '#' + tr.getMethod().getMethodName(); + try { Method realTestMethod = tr.getMethod().getMethod(); Test specAssert = realTestMethod.getAnnotation(Test.class); - if(specAssert!=null && specAssert.description()!=null && !specAssert.description().isEmpty()){ - log("[SKIPPED] " + specAssert.description()+ "("+location+")"); - } - else{ + if (specAssert != null && specAssert.description() != null && !specAssert.description().isEmpty()) { + log("[SKIPPED] " + specAssert.description() + "(" + location + ")"); + } else { log("[SKIPPED] " + location); } - } - catch(IOException e){ + } catch (IOException e) { throw new IllegalStateException("IO Error", e); } } @Override - public void onTestSuccess(ITestResult tr){ + public void onTestSuccess(ITestResult tr) { success++; - String location = tr.getTestClass().getRealClass().getSimpleName()+'#'+tr.getMethod().getMethodName(); - try{ + String location = tr.getTestClass().getRealClass().getSimpleName() + '#' + tr.getMethod().getMethodName(); + try { Method realTestMethod = tr.getMethod().getMethod(); Test specAssert = realTestMethod.getAnnotation(Test.class); - if(specAssert!=null && specAssert.description()!=null && !specAssert.description().isEmpty()){ - log("[SUCCESS] " + specAssert.description()+ "("+location+")"); - } - else{ + if (specAssert != null && specAssert.description() != null && !specAssert.description().isEmpty()) { + log("[SUCCESS] " + specAssert.description() + "(" + location + ")"); + } else { log("[SUCCESS] " + location); } - } - catch(IOException e){ + } catch (IOException e) { throw new IllegalStateException("IO Error", e); } } @@ -188,8 +179,8 @@ private void log(String text) throws IOException { internalBuffer.write('\n'); } - public void writeSummary(){ - try{ + public void writeSummary() { + try { log("\nJSR 354 TCP version 1.0 Summary"); log("-------------------------------"); log("\nTOTAL TESTS EXECUTED : " + count); @@ -201,8 +192,7 @@ public void writeSummary(){ internalBuffer.flush(); System.out.println(); System.out.println(internalBuffer); - } - catch(IOException e){ + } catch (IOException e) { throw new IllegalStateException("IO Error", e); } } diff --git a/src/main/java/org/javamoney/tck/TCKTestSetup.java b/src/main/java/org/javamoney/tck/TCKTestSetup.java index 0982312..51c48c7 100644 --- a/src/main/java/org/javamoney/tck/TCKTestSetup.java +++ b/src/main/java/org/javamoney/tck/TCKTestSetup.java @@ -13,24 +13,24 @@ public final class TCKTestSetup { - private static JSR354TestConfiguration TEST_CONFIG = loadTestConfiguration(); + private static JSR354TestConfiguration TEST_CONFIG = loadTestConfiguration(); - private TCKTestSetup() { - } + private TCKTestSetup() { + } - private static JSR354TestConfiguration loadTestConfiguration() { - try { - return ServiceLoader.load(JSR354TestConfiguration.class).iterator() - .next(); - } catch (Exception e) { - throw new IllegalStateException("No valid implementation of " - + JSR354TestConfiguration.class.getName() - + " is registered with the ServiceLoader."); - } - } + private static JSR354TestConfiguration loadTestConfiguration() { + try { + return ServiceLoader.load(JSR354TestConfiguration.class).iterator() + .next(); + } catch (Exception e) { + throw new IllegalStateException("No valid implementation of " + + JSR354TestConfiguration.class.getName() + + " is registered with the ServiceLoader."); + } + } - public static JSR354TestConfiguration getTestConfiguration() { - return TEST_CONFIG; - } + public static JSR354TestConfiguration getTestConfiguration() { + return TEST_CONFIG; + } } diff --git a/src/main/java/org/javamoney/tck/TCKValidationException.java b/src/main/java/org/javamoney/tck/TCKValidationException.java index 45904c7..8100f1e 100644 --- a/src/main/java/org/javamoney/tck/TCKValidationException.java +++ b/src/main/java/org/javamoney/tck/TCKValidationException.java @@ -11,14 +11,14 @@ public final class TCKValidationException extends RuntimeException { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public TCKValidationException(String message) { - super(message); - } + public TCKValidationException(String message) { + super(message); + } - public TCKValidationException(String message, Throwable e) { - super(message, e); - } + public TCKValidationException(String message, Throwable e) { + super(message, e); + } } diff --git a/src/main/java/org/javamoney/tck/TestUtils.java b/src/main/java/org/javamoney/tck/TestUtils.java index 3b07199..0220997 100644 --- a/src/main/java/org/javamoney/tck/TestUtils.java +++ b/src/main/java/org/javamoney/tck/TestUtils.java @@ -29,73 +29,71 @@ import java.util.Random; -public class TestUtils{ +public class TestUtils { private static final StringBuffer warnings = new StringBuffer(); - private TestUtils(){ + private TestUtils() { } - public static BigDecimal createNumberWithPrecision(MonetaryAmountFactory f, int precision){ - if(precision == 0){ + public static BigDecimal createNumberWithPrecision(MonetaryAmountFactory f, int precision) { + if (precision == 0) { precision = new Random().nextInt(100); } StringBuilder b = new StringBuilder(precision + 1); - for(int i = 0; i < precision; i++){ + for (int i = 0; i < precision; i++) { b.append(String.valueOf(i % 10)); } return new BigDecimal(b.toString(), MathContext.UNLIMITED); } - public static BigDecimal createNumberWithScale(MonetaryAmountFactory f, int scale){ + public static BigDecimal createNumberWithScale(MonetaryAmountFactory f, int scale) { StringBuilder b = new StringBuilder(scale + 2); b.append("9."); - for(int i = 0; i < scale; i++){ + for (int i = 0; i < scale; i++) { b.append(String.valueOf(i % 10)); } return new BigDecimal(b.toString(), MathContext.UNLIMITED); } - public static void testSerializable(String section, Class c){ - if(!Serializable.class.isAssignableFrom(c)){ + public static void testSerializable(String section, Class c) { + if (!Serializable.class.isAssignableFrom(c)) { throw new TCKValidationException(section + ": Class must be serializable: " + c.getName()); } } - public static void testImmutable(String section, Class c){ - try{ + public static void testImmutable(String section, Class c) { + try { MutabilityAssert.assertInstancesOf(c, MutabilityMatchers.areImmutable(), AllowedReason - .provided(Currency.class, MonetaryAmount.class, - CurrencyUnit.class, NumberValue.class, - MonetaryOperator.class, MonetaryQuery.class) - .areAlsoImmutable(), AllowedReason.allowingForSubclassing(), - AllowedReason.allowingNonFinalFields()); - } - catch(Exception e){ + .provided(Currency.class, MonetaryAmount.class, + CurrencyUnit.class, NumberValue.class, + MonetaryOperator.class, MonetaryQuery.class) + .areAlsoImmutable(), AllowedReason.allowingForSubclassing(), + AllowedReason.allowingNonFinalFields()); + } catch (Exception e) { throw new TCKValidationException(section + ": Class is not immutable: " + c.getName(), e); } } - public static void testSerializable(String section, Object o){ - if(!(o instanceof Serializable)){ + public static void testSerializable(String section, Object o) { + if (!(o instanceof Serializable)) { throw new TCKValidationException(section + ": Class must be serializable: " + o.getClass().getName()); } - try( - ObjectOutputStream oos = new ObjectOutputStream(new ByteArrayOutputStream())){ + try ( + ObjectOutputStream oos = new ObjectOutputStream(new ByteArrayOutputStream())) { oos.writeObject(o); - } - catch(Exception e){ + } catch (Exception e) { throw new TCKValidationException( "Class must be serializable, but serialization failed: " + o.getClass().getName(), e); } } - public static void testImplementsInterface(String section, Class type, Class iface){ - for(Class ifa : type.getInterfaces()){ - if(ifa.equals(iface)){ + public static void testImplementsInterface(String section, Class type, Class iface) { + for (Class ifa : type.getInterfaces()) { + if (ifa.equals(iface)) { return; } } @@ -103,14 +101,14 @@ public static void testImplementsInterface(String section, Class type, Class ifa } public static void testHasPublicMethod(String section, Class type, Class returnType, String name, - Class... paramTypes){ + Class... paramTypes) { Class current = type; - while(current != null){ - for(Method m : current.getDeclaredMethods()){ - if(returnType.equals(returnType) && + while (current != null) { + for (Method m : current.getDeclaredMethods()) { + if (returnType.equals(returnType) && m.getName().equals(name) && ((m.getModifiers() & Modifier.PUBLIC) != 0) && - Arrays.equals(m.getParameterTypes(), paramTypes)){ + Arrays.equals(m.getParameterTypes(), paramTypes)) { return; } } @@ -122,15 +120,15 @@ public static void testHasPublicMethod(String section, Class type, Class returnT } public static void testHasPublicStaticMethod(String section, Class type, Class returnType, String name, - Class... paramTypes){ + Class... paramTypes) { Class current = type; - while(current != null){ - for(Method m : current.getDeclaredMethods()){ - if(returnType.equals(returnType) && + while (current != null) { + for (Method m : current.getDeclaredMethods()) { + if (returnType.equals(returnType) && m.getName().equals(name) && ((m.getModifiers() & Modifier.PUBLIC) != 0) && ((m.getModifiers() & Modifier.STATIC) != 0) && - Arrays.equals(m.getParameterTypes(), paramTypes)){ + Arrays.equals(m.getParameterTypes(), paramTypes)) { return; } } @@ -142,13 +140,13 @@ public static void testHasPublicStaticMethod(String section, Class type, Class r } public static void testHasNotPublicMethod(String section, Class type, Class returnType, String name, - Class... paramTypes){ + Class... paramTypes) { Class current = type; - while(current != null){ - for(Method m : current.getDeclaredMethods()){ - if(returnType.equals(returnType) && + while (current != null) { + for (Method m : current.getDeclaredMethods()) { + if (returnType.equals(returnType) && m.getName().equals(name) && - Arrays.equals(m.getParameterTypes(), paramTypes)){ + Arrays.equals(m.getParameterTypes(), paramTypes)) { throw new TCKValidationException( section + ": Class must NOT implement method " + name + '(' + Arrays.toString(paramTypes) + "): " + returnType.getName() + ", but does: " + type.getName()); @@ -158,36 +156,34 @@ public static void testHasNotPublicMethod(String section, Class type, Class retu } } - public static void testComparable(String section, Class type){ + public static void testComparable(String section, Class type) { testImplementsInterface(section, type, Comparable.class); } public static void assertValue(String section, Object value, String methodName, Object instance) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, - InvocationTargetException{ + InvocationTargetException { Method m = instance.getClass().getDeclaredMethod(methodName); Assert.assertEquals(section + ": " + m.getName() + '(' + instance + ") returned invalid value:", value, - m.invoke(instance)); + m.invoke(instance)); } - public static boolean testImmutableOpt(String section, Class type){ - try{ + public static boolean testImmutableOpt(String section, Class type) { + try { testImmutable(section, type); return true; - } - catch(Exception e){ + } catch (Exception e) { warnings.append(section).append(": Recommendation failed: Class should be immutable: ") .append(type.getName()).append(", details: ").append(e.getMessage()).append("\n"); return false; } } - public static boolean testSerializableOpt(String section, Class type){ - try{ + public static boolean testSerializableOpt(String section, Class type) { + try { testSerializable(section, type); return true; - } - catch(Exception e){ + } catch (Exception e) { warnings.append(section).append(": Recommendation failed: Class should be serializable: ") .append(type.getName()).append(", details: ").append(e.getMessage()).append("\n"); return false; @@ -195,12 +191,11 @@ public static boolean testSerializableOpt(String section, Class type){ } public static boolean testHasPublicStaticMethodOpt(String section, Class type, Class returnType, String methodName, - Class... paramTypes){ - try{ + Class... paramTypes) { + try { testHasPublicStaticMethod(section, type, returnType, methodName, paramTypes); return true; - } - catch(Exception e){ + } catch (Exception e) { warnings.append(section).append(": Recommendation failed: Missing method [public static ") .append(methodName).append('(').append(Arrays.toString(paramTypes)).append("):") .append(returnType.getName()).append("] on: ").append(type.getName()).append("\n"); @@ -208,12 +203,11 @@ public static boolean testHasPublicStaticMethodOpt(String section, Class type, C } } - public static boolean testSerializableOpt(String section, Object instance){ - try{ + public static boolean testSerializableOpt(String section, Object instance) { + try { testSerializable(section, instance); return true; - } - catch(Exception e){ + } catch (Exception e) { warnings.append(section) .append(": Recommendation failed: Class is serializable, but serialization failed: ") .append(instance.getClass().getName()).append("\n"); @@ -221,40 +215,38 @@ public static boolean testSerializableOpt(String section, Object instance){ } } - public static void resetWarnings(){ + public static void resetWarnings() { warnings.setLength(0); } - public static String getWarnings(){ + public static String getWarnings() { return warnings.toString(); } - public static MonetaryAmount createAmountWithScale(int scale){ + public static MonetaryAmount createAmountWithScale(int scale) { MonetaryAmountFactoryQuery tgtContext = MonetaryAmountFactoryQueryBuilder.of().setMaxScale(scale).build(); MonetaryAmountFactory exceedingFactory; - try{ + try { exceedingFactory = MonetaryAmounts.getAmountFactory(tgtContext); AssertJUnit.assertNotNull(exceedingFactory); MonetaryAmountFactory bigFactory = MonetaryAmounts.getAmountFactory(exceedingFactory.getAmountType()); return bigFactory.setCurrency("CHF").setNumber(createNumberWithScale(bigFactory, scale)).create(); - } - catch(MonetaryException e){ + } catch (MonetaryException e) { return null; } } - public static MonetaryAmount createAmountWithPrecision(int precision){ + public static MonetaryAmount createAmountWithPrecision(int precision) { MonetaryAmountFactoryQuery tgtContext = MonetaryAmountFactoryQueryBuilder.of().setPrecision(precision).build(); MonetaryAmountFactory exceedingFactory; - try{ + try { exceedingFactory = MonetaryAmounts.getAmountFactory(tgtContext); AssertJUnit.assertNotNull(exceedingFactory); MonetaryAmountFactory bigFactory = MonetaryAmounts.getAmountFactory(exceedingFactory.getAmountType()); return bigFactory.setCurrency("CHF").setNumber(createNumberWithPrecision(bigFactory, precision)).create(); - } - catch(MonetaryException e){ + } catch (MonetaryException e) { return null; } } diff --git a/src/main/java/org/javamoney/tck/tests/FunctionalExtensionPointsTest.java b/src/main/java/org/javamoney/tck/tests/FunctionalExtensionPointsTest.java index 2578aca..e3ccdda 100644 --- a/src/main/java/org/javamoney/tck/tests/FunctionalExtensionPointsTest.java +++ b/src/main/java/org/javamoney/tck/tests/FunctionalExtensionPointsTest.java @@ -29,7 +29,7 @@ * Created by Anatole on 10.03.14. */ @SpecVersion(spec = "JSR 354", version = "1.0.0") -public class FunctionalExtensionPointsTest{ +public class FunctionalExtensionPointsTest { // *************************** A. Monetary Operator Implementation Requirements *************** @@ -40,23 +40,23 @@ public class FunctionalExtensionPointsTest{ */ @SpecAssertion(section = "4.2.4", id = "424-A1") @Test(description = "4.2.4 Ensures the result of all operators under test is of the same class as the input.") - public void testOperatorReturnTypeEqualsParameter(){ + public void testOperatorReturnTypeEqualsParameter() { Collection operators = TCKTestSetup.getTestConfiguration().getMonetaryOperators4Test(); assertNotNull(operators, - "No operators (null) to test returned from TestConfiguration.getMonetaryOperators4Test()."); - for(Class type : MonetaryAmounts.getAmountTypes()){ - if(type.equals(TestAmount.class)){ + "No operators (null) to test returned from TestConfiguration.getMonetaryOperators4Test()."); + for (Class type : MonetaryAmounts.getAmountTypes()) { + if (type.equals(TestAmount.class)) { continue; } MonetaryAmountFactory f = getAmountFactory(type); f.setCurrency("CHF"); f.setNumber(200.10); MonetaryAmount m = f.create(); - for(MonetaryOperator op : operators){ + for (MonetaryOperator op : operators) { MonetaryAmount m2 = m.with(op); assertEquals(m2.getClass(), m.getClass(), - "Operator returned type with different type, which is not allowed: " + - op.getClass().getName()); + "Operator returned type with different type, which is not allowed: " + + op.getClass().getName()); } } } diff --git a/src/main/java/org/javamoney/tck/tests/ModellingCurrenciesTest.java b/src/main/java/org/javamoney/tck/tests/ModellingCurrenciesTest.java index 7a02bd8..9868381 100644 --- a/src/main/java/org/javamoney/tck/tests/ModellingCurrenciesTest.java +++ b/src/main/java/org/javamoney/tck/tests/ModellingCurrenciesTest.java @@ -24,7 +24,7 @@ @SpecVersion(spec = "JSR 354", version = "1.0.0") -public class ModellingCurrenciesTest{ +public class ModellingCurrenciesTest { /** * Ensure at least one javax.money.CurrencyUnit implementation @@ -32,7 +32,7 @@ public class ModellingCurrenciesTest{ */ @SpecAssertion(section = "4.2.1", id = "421-A1") @Test(description = "4.2.1 Ensure TCK has CurrencyUnit classes configured.") - public void testEnsureCurrencyUnit(){ + public void testEnsureCurrencyUnit() { AssertJUnit.assertTrue("TCK Configuration not available.", TCKTestSetup.getTestConfiguration() != null); AssertJUnit.assertTrue(TCKTestSetup.getTestConfiguration().getCurrencyClasses().size() > 0); } @@ -45,8 +45,8 @@ public void testEnsureCurrencyUnit(){ */ @SpecAssertion(section = "4.2.1", id = "421-A2") @Test(description = "4.2.1 Test currencies provided equal at least currencies from java.util.Currency.") - public void testEqualISOCurrencies(){ - for(Currency currency : Currency.getAvailableCurrencies()){ + public void testEqualISOCurrencies() { + for (Currency currency : Currency.getAvailableCurrencies()) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(currency.getCurrencyCode()); AssertJUnit.assertNotNull(unit); CurrencyUnit unit2 = MonetaryCurrencies.getCurrency(currency.getCurrencyCode()); @@ -61,8 +61,8 @@ public void testEqualISOCurrencies(){ */ @SpecAssertion(section = "4.2.1", id = "421-A3") @Test(description = "4.2.1 Test currencies provided have correct ISO 3-letter currency codes.") - public void testEnforce3LetterCode4ISO(){ - for(Currency currency : Currency.getAvailableCurrencies()){ + public void testEnforce3LetterCode4ISO() { + for (Currency currency : Currency.getAvailableCurrencies()) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(currency.getCurrencyCode()); AssertJUnit.assertNotNull(unit); AssertJUnit.assertEquals(currency.getCurrencyCode(), unit.getCurrencyCode()); @@ -75,8 +75,8 @@ public void testEnforce3LetterCode4ISO(){ */ @SpecAssertion(section = "4.2.1", id = "421-A4") @Test(description = "4.2.1 Test currencies provided have correct default fraction digits and numeric code.") - public void testISOCodes(){ - for(Currency currency : Currency.getAvailableCurrencies()){ + public void testISOCodes() { + for (Currency currency : Currency.getAvailableCurrencies()) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(currency.getCurrencyCode()); AssertJUnit.assertEquals(currency.getCurrencyCode(), unit.getCurrencyCode()); AssertJUnit.assertEquals(currency.getDefaultFractionDigits(), unit.getDefaultFractionDigits()); @@ -89,11 +89,11 @@ public void testISOCodes(){ */ @SpecAssertion(section = "4.2.1", id = "421-B1") @Test(description = "4.2.1 Ensure registered CurrencyUnit classes implement hashCode.") - public void testCurrencyClassesEqualsHashcode(){ - for(Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()){ + public void testCurrencyClassesEqualsHashcode() { + for (Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()) { TestUtils.testHasPublicMethod("Section 4.2.1", type, int.class, "hashCode"); } - for(String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}){ + for (String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(code); TestUtils.testHasPublicMethod("Section 4.2.1", unit.getClass(), int.class, "hashCode"); } @@ -104,10 +104,10 @@ public void testCurrencyClassesEqualsHashcode(){ */ @SpecAssertion(section = "4.2.1", id = "421-B2") @Test(description = "4.2.1 Ensure registered CurrencyUnit classes implement equals.") - public void testImplementsEquals(){ + public void testImplementsEquals() { List firstUnits = new ArrayList<>(); List secondUnits = new ArrayList<>(); - for(String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}){ + for (String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(code); AssertJUnit.assertNotNull(unit); TestUtils.testHasPublicMethod("Section 4.2.1", unit.getClass(), boolean.class, "equals", Object.class); @@ -116,11 +116,11 @@ public void testImplementsEquals(){ AssertJUnit.assertNotNull(unit2); secondUnits.add(unit2); } - for(String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}){ + for (String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(code); TestUtils.testHasPublicMethod("Section 4.2.1", unit.getClass(), boolean.class, "equals", Object.class); } - for(int i = 0; i < firstUnits.size(); i++){ + for (int i = 0; i < firstUnits.size(); i++) { AssertJUnit.assertEquals(firstUnits.get(i), secondUnits.get(i)); } } @@ -130,11 +130,11 @@ public void testImplementsEquals(){ */ @SpecAssertion(section = "4.2.1", id = "421-B3") @Test(description = "4.2.1 Ensure registered CurrencyUnit classes are Comparable.") - public void testCurrencyClassesComparable(){ - for(Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()){ + public void testCurrencyClassesComparable() { + for (Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()) { TestUtils.testComparable("Section 4.2.1", type); } - for(String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}){ + for (String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(code); TestUtils.testComparable("Section 4.2.1", unit.getClass()); } @@ -145,11 +145,11 @@ public void testCurrencyClassesComparable(){ */ @SpecAssertion(section = "4.2.1", id = "421-B4") @Test(description = "4.2.1 Ensure registered CurrencyUnit classes are immutable.") - public void testIsImmutable(){ - for(Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()){ + public void testIsImmutable() { + for (Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()) { TestUtils.testImmutable("Section 4.2.1", type); } - for(String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}){ + for (String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(code); TestUtils.testImmutable("Section 4.2.1", unit.getClass()); } @@ -160,11 +160,11 @@ public void testIsImmutable(){ */ @SpecAssertion(section = "4.2.1", id = "421-B6") @Test(description = "4.2.1 Ensure registered CurrencyUnit classes are serializable.") - public void testImplementsSerializable(){ - for(Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()){ + public void testImplementsSerializable() { + for (Class type : TCKTestSetup.getTestConfiguration().getCurrencyClasses()) { TestUtils.testSerializable("Section 4.2.1", type); } - for(String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}){ + for (String code : new String[]{"CHF", "USD", "EUR", "GBP", "USS"}) { CurrencyUnit unit = MonetaryCurrencies.getCurrency(code); TestUtils.testSerializable("Section 4.2.1", unit); } diff --git a/src/main/java/org/javamoney/tck/tests/TCKSetupTest.java b/src/main/java/org/javamoney/tck/tests/TCKSetupTest.java index 71201ea..3731807 100644 --- a/src/main/java/org/javamoney/tck/tests/TCKSetupTest.java +++ b/src/main/java/org/javamoney/tck/tests/TCKSetupTest.java @@ -18,14 +18,14 @@ import java.util.Collection; @SpecVersion(spec = "JSR 354", version = "1.0.0") -public class TCKSetupTest{ +public class TCKSetupTest { @SpecAssertion( section = "0", id = "Setup", note = "Tests that a TestConfiguration is registered with the JDK's ServiceLoader.") @Test(description = "TCK Setup: ensure TCK Configuration is registered and available.") - public void testTestSetup(){ + public void testTestSetup() { AssertJUnit.assertTrue("TCK Configuration not available.", TCKTestSetup.getTestConfiguration() != null); AssertJUnit.assertNotNull(TCKTestSetup.getTestConfiguration()); } @@ -36,7 +36,7 @@ public void testTestSetup(){ note = "Checks that TestConfiguration.getAmountClasses() returns a non empty collection of amount " + "implementations") @Test(description = "TChecks that MonetaryAmount classes are registered for testing.") - public void testTestAmountConfiguration(){ + public void testTestAmountConfiguration() { Collection amountClasses = TCKTestSetup.getTestConfiguration().getAmountClasses(); AssertJUnit.assertNotNull("TCK Test Configuration amount classes are null.", amountClasses); AssertJUnit.assertFalse("TCK Test Configuration amount classes is empty.", amountClasses.isEmpty()); diff --git a/src/main/java/org/javamoney/tck/tests/conversion/ProviderChainsTest.java b/src/main/java/org/javamoney/tck/tests/conversion/ProviderChainsTest.java index a578aa8..78b6d4a 100644 --- a/src/main/java/org/javamoney/tck/tests/conversion/ProviderChainsTest.java +++ b/src/main/java/org/javamoney/tck/tests/conversion/ProviderChainsTest.java @@ -25,7 +25,7 @@ * Created by Anatole on 10.03.14. */ @SpecVersion(spec = "JSR 354", version = "1.0.0") -public class ProviderChainsTest{ +public class ProviderChainsTest { // ********************** A. Test Basic MonetaryConversions Accessors ********************************* @@ -35,7 +35,7 @@ public class ProviderChainsTest{ */ @Test(description = "4.3.4 Test correct rate evaluation for different conversion provider chains.") @SpecAssertion(id = "434-A1", section = "4.3.4") - public void testCorrectRateEvaluationInChain_diffProviders(){ + public void testCorrectRateEvaluationInChain_diffProviders() { ExchangeRateProvider prov1 = MonetaryConversions .getExchangeRateProvider("TestRateProvider1", "TestRateProvider2", "TestRateProvider3"); ExchangeRate rate = prov1.getExchangeRate("CHF", "EUR"); @@ -68,7 +68,7 @@ public void testCorrectRateEvaluationInChain_diffProviders(){ prov1 = MonetaryConversions .getExchangeRateProvider("TestRateProvider3", "TestRateProvider2", "TestRateProvider1", - "TestRateProvider02"); + "TestRateProvider02"); rate = prov1.getExchangeRate("CHF", "EUR"); AssertJUnit.assertEquals("Invalid ExchangeRateProvider selected.", rate.getFactor().intValueExact(), 1); rate = prov1.getExchangeRate("EUR", "USD"); @@ -86,7 +86,7 @@ public void testCorrectRateEvaluationInChain_diffProviders(){ @Test(description = "4.3.4 Test correct rate evaluation for different conversion provider chains, " + "with duplicate provider entries.") @SpecAssertion(id = "434-A1", section = "4.3.4") - public void testCorrectRateEvaluationInChain_sameProviders(){ + public void testCorrectRateEvaluationInChain_sameProviders() { ExchangeRateProvider prov1 = MonetaryConversions .getExchangeRateProvider("TestRateProvider1", "TestRateProvider1", "TestRateProvider1"); ExchangeRate rate = prov1.getExchangeRate("CHF", "EUR"); @@ -108,7 +108,7 @@ public void testCorrectRateEvaluationInChain_sameProviders(){ @Test(description = "4.3.4 Test correct rate evaluation for different conversion provider chains, " + "with historic rates.") @SpecAssertion(id = "434-A2", section = "4.3.4") - public void testCorrectRateEvaluationInChainHistoric(){ + public void testCorrectRateEvaluationInChainHistoric() { ExchangeRateProvider prov1 = MonetaryConversions .getExchangeRateProvider("TestRateProvider1", "TestRateProvider2", "TestRateProvider3"); ExchangeRate rate = prov1.getExchangeRate("CHF", "EUR"); @@ -130,18 +130,18 @@ public void testCorrectRateEvaluationInChainHistoric(){ */ @Test(description = "4.3.4 Test availability of TCK provided providers.") @SpecAssertion(id = "434-A3", section = "4.3.4") - public void testTCKRateChainAvailability(){ + public void testTCKRateChainAvailability() { Collection provNames = MonetaryConversions.getProviderNames(); AssertJUnit.assertTrue("TCK ExchangeRateProvider is not registered: TestRateProvider", - provNames.contains("TestRateProvider")); + provNames.contains("TestRateProvider")); AssertJUnit.assertTrue("TCK ExchangeRateProvider is not registered:TestRateProvider1", - provNames.contains("TestRateProvider1")); + provNames.contains("TestRateProvider1")); AssertJUnit.assertTrue("TCK ExchangeRateProvider is not registered: TestRateProvider2", - provNames.contains("TestRateProvider2")); + provNames.contains("TestRateProvider2")); AssertJUnit.assertTrue("TCK ExchangeRateProvider is not registered: TestRateProvider3", - provNames.contains("TestRateProvider3")); + provNames.contains("TestRateProvider3")); AssertJUnit.assertTrue("TCK ExchangeRateProvider is not registered: TestRateProvider02", - provNames.contains("TestRateProvider02")); + provNames.contains("TestRateProvider02")); } } diff --git a/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountBuilder.java b/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountBuilder.java index 8dbe28a..5398ef7 100644 --- a/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountBuilder.java +++ b/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountBuilder.java @@ -11,84 +11,84 @@ import javax.money.*; -public final class TestMonetaryAmountBuilder implements MonetaryAmountFactory{ +public final class TestMonetaryAmountBuilder implements MonetaryAmountFactory { private Number value; private CurrencyUnit currency; - public static TestAmount getAmount(final Number number, final CurrencyUnit currency){ + public static TestAmount getAmount(final Number number, final CurrencyUnit currency) { return new TestAmount(number, currency); } @Override - public Class getAmountType(){ + public Class getAmountType() { return TestAmount.class; } @Override - public MonetaryAmountFactory setCurrency(String currencyCode){ + public MonetaryAmountFactory setCurrency(String currencyCode) { this.currency = MonetaryCurrencies.getCurrency(currencyCode); return this; } @Override - public MonetaryAmountFactory setCurrency(CurrencyUnit currency){ + public MonetaryAmountFactory setCurrency(CurrencyUnit currency) { this.currency = currency; return this; } @Override - public MonetaryAmountFactory setNumber(double number){ + public MonetaryAmountFactory setNumber(double number) { this.value = number; return this; } @Override - public MonetaryAmountFactory setNumber(long number){ + public MonetaryAmountFactory setNumber(long number) { this.value = number; return this; } @Override - public MonetaryAmountFactory setNumber(Number number){ + public MonetaryAmountFactory setNumber(Number number) { this.value = number; return this; } @Override - public NumberValue getMaxNumber(){ + public NumberValue getMaxNumber() { return null; } @Override - public NumberValue getMinNumber(){ + public NumberValue getMinNumber() { return null; } @Override - public MonetaryAmountFactory setContext(MonetaryContext monetaryContext){ + public MonetaryAmountFactory setContext(MonetaryContext monetaryContext) { return this; } @Override - public MonetaryAmountFactory setAmount(MonetaryAmount amount){ + public MonetaryAmountFactory setAmount(MonetaryAmount amount) { setCurrency(amount.getCurrency()); setNumber(amount.getNumber()); return this; } @Override - public TestAmount create(){ + public TestAmount create() { return new TestAmount(value, currency); } @Override - public MonetaryContext getDefaultMonetaryContext(){ + public MonetaryContext getDefaultMonetaryContext() { return TestAmount.MONETARY_CONTEXT; } @Override - public MonetaryContext getMaximalMonetaryContext(){ + public MonetaryContext getMaximalMonetaryContext() { return TestAmount.MONETARY_CONTEXT; } } \ No newline at end of file diff --git a/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountFactoryProvider.java b/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountFactoryProvider.java index 81da058..38332ed 100644 --- a/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountFactoryProvider.java +++ b/src/main/java/org/javamoney/tck/tests/internal/TestMonetaryAmountFactoryProvider.java @@ -16,30 +16,30 @@ /** * Created by Anatole on 19.04.2014. */ -public final class TestMonetaryAmountFactoryProvider implements MonetaryAmountFactoryProviderSpi{ +public final class TestMonetaryAmountFactoryProvider implements MonetaryAmountFactoryProviderSpi { @Override - public QueryInclusionPolicy getQueryInclusionPolicy(){ + public QueryInclusionPolicy getQueryInclusionPolicy() { return QueryInclusionPolicy.DIRECT_REFERENCE_ONLY; } @Override - public Class getAmountType(){ + public Class getAmountType() { return TestAmount.class; } @Override - public MonetaryAmountFactory createMonetaryAmountFactory(){ + public MonetaryAmountFactory createMonetaryAmountFactory() { return new TestMonetaryAmountBuilder(); } @Override - public MonetaryContext getDefaultMonetaryContext(){ + public MonetaryContext getDefaultMonetaryContext() { return TestAmount.MONETARY_CONTEXT; } @Override - public MonetaryContext getMaximalMonetaryContext(){ + public MonetaryContext getMaximalMonetaryContext() { return TestAmount.MONETARY_CONTEXT; } } diff --git a/src/main/java/org/javamoney/tck/tests/internal/TestNumberValue.java b/src/main/java/org/javamoney/tck/tests/internal/TestNumberValue.java index 067f632..ea5d319 100644 --- a/src/main/java/org/javamoney/tck/tests/internal/TestNumberValue.java +++ b/src/main/java/org/javamoney/tck/tests/internal/TestNumberValue.java @@ -18,60 +18,60 @@ /** * Created by Anatole on 26.04.2014. */ -public final class TestNumberValue extends NumberValue{ +public final class TestNumberValue extends NumberValue { private static final long serialVersionUID = 1L; private BigDecimal value; - public TestNumberValue(Number value){ + public TestNumberValue(Number value) { Objects.requireNonNull(value); this.value = new BigDecimal(String.valueOf(value)); } @Override - public long longValue(){ + public long longValue() { return value.longValue(); } @Override - public int intValue(){ + public int intValue() { return value.intValue(); } @Override - public float floatValue(){ + public float floatValue() { return value.floatValue(); } @Override - public double doubleValue(){ + public double doubleValue() { return value.doubleValue(); } @Override - public T numberValueExact(Class numberType){ + public T numberValueExact(Class numberType) { return null; } @Override - public long getAmountFractionNumerator(){ + public long getAmountFractionNumerator() { return 0; } @Override - public long getAmountFractionDenominator(){ + public long getAmountFractionDenominator() { return 0; } @Override - public T numberValue(Class numberType){ - if(numberType.equals(Integer.class)){ + public T numberValue(Class numberType) { + if (numberType.equals(Integer.class)) { return (T) Integer.valueOf(value.intValue()); } - if(numberType.equals(BigInteger.class)){ + if (numberType.equals(BigInteger.class)) { return (T) BigInteger.valueOf(value.intValue()); } - if(numberType.equals(BigDecimal.class)){ + if (numberType.equals(BigDecimal.class)) { return (T) BigDecimal.valueOf(value.doubleValue()); } throw new UnsupportedOperationException(numberType.getCanonicalName()); @@ -83,37 +83,37 @@ public NumberValue round(MathContext mathContext) { } @Override - public long longValueExact(){ + public long longValueExact() { return value.longValue(); } @Override - public int intValueExact(){ + public int intValueExact() { return value.intValue(); } @Override - public int getScale(){ + public int getScale() { return value.scale(); } @Override - public int getPrecision(){ + public int getPrecision() { return value.precision(); } @Override - public Class getNumberType(){ + public Class getNumberType() { return BigDecimal.class; } @Override - public double doubleValueExact(){ + public double doubleValueExact() { return value.doubleValue(); } @Override - public String toString(){ + public String toString() { return this.value.toString(); } } diff --git a/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider.java b/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider.java index 3c44bf0..95e544f 100644 --- a/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider.java +++ b/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider.java @@ -20,16 +20,16 @@ /** * Test ExchangeProvider. Created by Anatole on 26.04.2014. */ -public class TestRateProvider implements ExchangeRateProvider{ +public class TestRateProvider implements ExchangeRateProvider { private ProviderContext PC = ProviderContextBuilder.of("TestRateProvider", RateType.OTHER).build(); private ConversionContext CC = ConversionContextBuilder.create(PC, RateType.OTHER).build(); private CurrencyUnit TERM = new TestCurrencyUnit("FOO"); - private CurrencyConversion CONVERSION = new CurrencyConversion(){ + private CurrencyConversion CONVERSION = new CurrencyConversion() { @Override - public CurrencyUnit getCurrency(){ + public CurrencyUnit getCurrency() { return TERM; } @@ -39,7 +39,7 @@ public ConversionContext getContext() { } @Override - public ExchangeRate getExchangeRate(MonetaryAmount sourceAmount){ + public ExchangeRate getExchangeRate(MonetaryAmount sourceAmount) { return new TestExchangeRate.Builder(CC).setFactor(new TestNumberValue(2)) .setBase(sourceAmount.getCurrency()).setTerm(TERM).build(); } @@ -50,7 +50,7 @@ public ExchangeRateProvider getExchangeRateProvider() { } @Override - public MonetaryAmount apply(MonetaryAmount value){ + public MonetaryAmount apply(MonetaryAmount value) { return value.multiply(2).getFactory().setCurrency(TERM).create(); } }; @@ -61,14 +61,14 @@ public ProviderContext getContext() { } @Override - public boolean isAvailable(CurrencyUnit base, CurrencyUnit term){ + public boolean isAvailable(CurrencyUnit base, CurrencyUnit term) { Objects.requireNonNull(base); Objects.requireNonNull(term); return "FOO".equals(term.getCurrencyCode()) || "XXX".equals(term.getCurrencyCode()); } @Override - public boolean isAvailable(ConversionQuery conversionContext){ + public boolean isAvailable(ConversionQuery conversionContext) { Objects.requireNonNull(conversionContext); Objects.requireNonNull(conversionContext.getCurrency()); return "FOO".equals(conversionContext.getCurrency().getCurrencyCode()) || @@ -76,14 +76,14 @@ public boolean isAvailable(ConversionQuery conversionContext){ } @Override - public boolean isAvailable(String baseCode, String termCode){ + public boolean isAvailable(String baseCode, String termCode) { return "Foo".equals(termCode) || "XXX".equals(termCode); } @Override - public ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term){ - if(isAvailable(base, term)){ + public ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term) { + if (isAvailable(base, term)) { return new TestExchangeRate.Builder(CC).setFactor(new TestNumberValue(2)).setBase(base).setTerm(term) .build(); } @@ -91,8 +91,8 @@ public ExchangeRate getExchangeRate(CurrencyUnit base, CurrencyUnit term){ } @Override - public ExchangeRate getExchangeRate(ConversionQuery conversionQuery){ - if(isAvailable(conversionQuery)){ + public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { + if (isAvailable(conversionQuery)) { return new TestExchangeRate.Builder( ConversionContextBuilder.create(getContext(), RateType.OTHER).importContext(conversionQuery) .build()).setFactor(new TestNumberValue(2)).setBase(conversionQuery.getBaseCurrency()) @@ -102,34 +102,34 @@ public ExchangeRate getExchangeRate(ConversionQuery conversionQuery){ } @Override - public ExchangeRate getExchangeRate(String baseCode, String termCode){ - if(isAvailable(baseCode, termCode)){ + public ExchangeRate getExchangeRate(String baseCode, String termCode) { + if (isAvailable(baseCode, termCode)) { return getExchangeRate(MonetaryCurrencies.getCurrency(baseCode), TERM); } return null; } @Override - public ExchangeRate getReversed(ExchangeRate rate){ + public ExchangeRate getReversed(ExchangeRate rate) { return null; } @Override - public CurrencyConversion getCurrencyConversion(CurrencyUnit term){ + public CurrencyConversion getCurrencyConversion(CurrencyUnit term) { return CONVERSION; } @Override - public CurrencyConversion getCurrencyConversion(ConversionQuery conversionQuery){ - if(isAvailable(conversionQuery)){ + public CurrencyConversion getCurrencyConversion(ConversionQuery conversionQuery) { + if (isAvailable(conversionQuery)) { return CONVERSION; } return null; } @Override - public CurrencyConversion getCurrencyConversion(String termCode){ - if(TERM.getCurrencyCode().equals(termCode)){ + public CurrencyConversion getCurrencyConversion(String termCode) { + if (TERM.getCurrencyCode().equals(termCode)) { return CONVERSION; } return null; diff --git a/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider1.java b/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider1.java index 295ee4a..9f2a3f7 100644 --- a/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider1.java +++ b/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider1.java @@ -19,23 +19,23 @@ /** * CTest ExchangeProvider. reated by Anatole on 26.04.2014. */ -public class TestRateProvider1 implements ExchangeRateProvider{ +public class TestRateProvider1 implements ExchangeRateProvider { public static final int FACTOR = 1; private static ProviderContext PC = ProviderContextBuilder.of("TestRateProvider1", RateType.OTHER).build(); private static ConversionContext CC = ConversionContextBuilder.create(PC, RateType.OTHER).build(); - private static final class Conversion implements CurrencyConversion{ + private static final class Conversion implements CurrencyConversion { private CurrencyUnit term; - private Conversion(CurrencyUnit term){ + private Conversion(CurrencyUnit term) { Objects.requireNonNull(term); this.term = term; } @Override - public CurrencyUnit getCurrency(){ + public CurrencyUnit getCurrency() { return term; } @@ -45,13 +45,13 @@ public ConversionContext getContext() { } @Override - public ExchangeRate getExchangeRate(MonetaryAmount sourceAmount){ + public ExchangeRate getExchangeRate(MonetaryAmount sourceAmount) { return new TestExchangeRate.Builder(CC).setFactor(new TestNumberValue(FACTOR)) .setBase(sourceAmount.getCurrency()).setTerm(term).build(); } @Override - public MonetaryAmount apply(MonetaryAmount value){ + public MonetaryAmount apply(MonetaryAmount value) { return value.getFactory().setCurrency(term).create(); } @@ -67,7 +67,7 @@ public ProviderContext getContext() { } @Override - public boolean isAvailable(ConversionQuery conversionQuery){ + public boolean isAvailable(ConversionQuery conversionQuery) { Objects.requireNonNull(conversionQuery); Objects.requireNonNull(conversionQuery.getBaseCurrency()); Objects.requireNonNull(conversionQuery.getCurrency()); @@ -75,11 +75,11 @@ public boolean isAvailable(ConversionQuery conversionQuery){ } @Override - public ExchangeRate getExchangeRate(ConversionQuery conversionQuery){ + public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { Objects.requireNonNull(conversionQuery); Objects.requireNonNull(conversionQuery.getBaseCurrency()); Objects.requireNonNull(conversionQuery.getCurrency()); - if(isAvailable(conversionQuery)){ + if (isAvailable(conversionQuery)) { return new TestExchangeRate.Builder(getClass().getSimpleName(), RateType.OTHER) .setFactor(new TestNumberValue(FACTOR)).setBase(conversionQuery.getBaseCurrency()) .setTerm(conversionQuery.getCurrency()).build(); @@ -88,7 +88,7 @@ public ExchangeRate getExchangeRate(ConversionQuery conversionQuery){ } @Override - public CurrencyConversion getCurrencyConversion(ConversionQuery query){ + public CurrencyConversion getCurrencyConversion(ConversionQuery query) { Objects.requireNonNull(query); Objects.requireNonNull(query.getCurrency()); return new Conversion(query.getCurrency()); diff --git a/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider2.java b/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider2.java index 4dda414..2fb8fb7 100644 --- a/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider2.java +++ b/src/main/java/org/javamoney/tck/tests/internal/TestRateProvider2.java @@ -20,23 +20,23 @@ /** * Test ExchangeProvider. Created by Anatole on 26.04.2014. */ -public class TestRateProvider2 implements ExchangeRateProvider{ +public class TestRateProvider2 implements ExchangeRateProvider { public static final int FACTOR = 2; private static ProviderContext PC = ProviderContextBuilder.of("TestRateProvider2", RateType.OTHER).build(); private static ConversionContext CC = ConversionContextBuilder.create(PC, RateType.OTHER).build(); - private static final class Conversion implements CurrencyConversion{ + private static final class Conversion implements CurrencyConversion { private CurrencyUnit term; - private Conversion(CurrencyUnit term){ + private Conversion(CurrencyUnit term) { Objects.requireNonNull(term); this.term = term; } @Override - public CurrencyUnit getCurrency(){ + public CurrencyUnit getCurrency() { return term; } @@ -46,13 +46,13 @@ public ConversionContext getContext() { } @Override - public ExchangeRate getExchangeRate(MonetaryAmount sourceAmount){ + public ExchangeRate getExchangeRate(MonetaryAmount sourceAmount) { return new TestExchangeRate.Builder(CC).setFactor(new TestNumberValue(FACTOR)) .setBase(sourceAmount.getCurrency()).setTerm(term).build(); } @Override - public MonetaryAmount apply(MonetaryAmount value){ + public MonetaryAmount apply(MonetaryAmount value) { return value.multiply(FACTOR).getFactory().setCurrency(term).create(); } @@ -68,7 +68,7 @@ public ProviderContext getContext() { } @Override - public boolean isAvailable(ConversionQuery conversionQuery){ + public boolean isAvailable(ConversionQuery conversionQuery) { Objects.requireNonNull(conversionQuery); Objects.requireNonNull(conversionQuery.getBaseCurrency()); Objects.requireNonNull(conversionQuery.getCurrency()); @@ -76,8 +76,8 @@ public boolean isAvailable(ConversionQuery conversionQuery){ } @Override - public ExchangeRate getExchangeRate(ConversionQuery conversionQuery){ - if(isAvailable(conversionQuery)){ + public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { + if (isAvailable(conversionQuery)) { if (conversionQuery.get(LocalDate.class) != null) { return new TestExchangeRate.Builder("TestRateProvider2", RateType.OTHER) .setFactor(new TestNumberValue(FACTOR * 100)).setBase(conversionQuery.getBaseCurrency()) @@ -91,7 +91,7 @@ public ExchangeRate getExchangeRate(ConversionQuery conversionQuery){ } @Override - public CurrencyConversion getCurrencyConversion(ConversionQuery conversionContext){ + public CurrencyConversion getCurrencyConversion(ConversionQuery conversionContext) { Objects.requireNonNull(conversionContext); Objects.requireNonNull(conversionContext.getCurrency()); return new Conversion(conversionContext.getCurrency());