Skip to content

Commit 975aad7

Browse files
committed
JAVAMONEY-83: Changed context key type from Object to String, removed methods containing defaults.
1 parent 6e79b04 commit 975aad7

File tree

7 files changed

+80
-79
lines changed

7 files changed

+80
-79
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<artifactId>javamoney-tck</artifactId>
2424
<packaging>jar</packaging>
2525

26-
<version>1.0-RC1</version>
26+
<version>1.0-SNAPSHOT</version>
2727

2828
<name>JSR 354 (TCK)</name>
2929
<url>http://java.net/projects/javamoney</url>
@@ -46,7 +46,7 @@
4646
</licenses>
4747

4848
<properties>
49-
<jsr.version>1.0-RC1</jsr.version>
49+
<jsr.version>1.0-SNAPSHOT</jsr.version>
5050
<jdkVersion>1.8</jdkVersion>
5151
<maven.compile.targetLevel>${jdkVersion}</maven.compile.targetLevel>
5252
<maven.compile.sourceLevel>${jdkVersion}</maven.compile.sourceLevel>

src/main/java/org/javamoney/tck/tests/AccessingCurrenciesAmountsRoundingsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public void testAccessRoundingsForCustomCurrencies_Explicit() {
393393
* custom currencies.
394394
*/
395395
@Test(expectedExceptions = NullPointerException.class,
396-
description = "Section 4.2.7: Expected NullPointerException accessing a rounding with " +
396+
description = "4.2.7: Expected NullPointerException accessing a rounding with " +
397397
"'MonetaryRoundings.getRounding(null)'.")
398398
@SpecAssertion(section = "4.2.7", id = "427-C1")
399399
public void testAccessRoundingsForCustomCurrencies_Explicit_Null() {
@@ -409,7 +409,7 @@ public void testAccessRoundingsForCustomCurrencies_Explicit_Null() {
409409
@Test(description = "4.2.7 Ensure correct MonetaryRounding returned for a mathematical RoundingQuery.")
410410
@SpecAssertion(section = "4.2.7", id = "427-C2")
411411
public void testAccessRoundingsWithRoundingContext() {
412-
RoundingQuery ctx = RoundingQueryBuilder.of().setScale(1).setTyped(RoundingMode.UP).build();
412+
RoundingQuery ctx = RoundingQueryBuilder.of().setScale(1).set(RoundingMode.UP).build();
413413
MonetaryOperator r = MonetaryRoundings.getRounding(ctx);
414414
AssertJUnit.assertNotNull("Section 4.2.7: No rounding provided for RoundingQuery: " + ctx, r);
415415
MonetaryAmount m =

src/main/java/org/javamoney/tck/tests/CreatingMonetaryAmountsTest.java

Lines changed: 36 additions & 36 deletions
Large diffs are not rendered by default.

src/main/java/org/javamoney/tck/tests/conversion/ExchangeRatesAndRateProvidersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void testAccessRates_IdentityRatesWithUnitsAndContext() {
181181
@SpecAssertion(id = "433-A2", section = "4.3.3")
182182
public void testPassingOverConversionContextToSPIs() {
183183
ExchangeRateProvider prov = MonetaryConversions.getExchangeRateProvider("TestRateProvider");
184-
ConversionQuery ctx = ConversionQueryBuilder.of().setTyped(Locale.CANADA).set("Foo", "bar").setBaseCurrency(FOO_UNIT)
184+
ConversionQuery ctx = ConversionQueryBuilder.of().set(Locale.CANADA).set("Foo", "bar").setBaseCurrency(FOO_UNIT)
185185
.setTermCurrency(MonetaryCurrencies.getCurrency("XXX")).build();
186186
ExchangeRate rate = prov.getExchangeRate(ctx);
187187
AssertJUnit.assertNotNull("No test rate returned by getExchangeRate(ConversionQuery), " +
@@ -191,7 +191,7 @@ public void testPassingOverConversionContextToSPIs() {
191191
rate.getConversionContext().getText("Foo"));
192192
AssertJUnit.assertEquals(
193193
"Object parameter Locale.class was not correctly passed to ExchangeRateProvider implementation.",
194-
Locale.CANADA, rate.getConversionContext().getTyped(Locale.class));
194+
Locale.CANADA, rate.getConversionContext().get(Locale.class));
195195
}
196196

197197

src/main/java/org/javamoney/tck/tests/conversion/TestExchangeRate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* This class models an exchange rate, which defines the factor the numeric value of a base amount in some currency
2525
* 'A' must be multiplied
26-
* to getTyped the corresponding amount in the terminating currency 'B'. Hereby
26+
* to get the corresponding amount in the terminating currency 'B'. Hereby
2727
* <ul>
2828
* <li>an exchange rate always models one rate from a base (source) to a term
2929
* (target) {@link javax.money.CurrencyUnit}.</li>
@@ -129,10 +129,10 @@ private TestExchangeRate(Builder builder) {
129129
}
130130

131131
/**
132-
* Internal method to setTyped the rate chain, which also ensure that the chain
132+
* Internal method to set the rate chain, which also ensure that the chain
133133
* passed, when not null, contains valid elements.
134134
*
135-
* @param chain the chain to setTyped.
135+
* @param chain the chain to set.
136136
*/
137137
private void setExchangeRateChain(List<ExchangeRate> chain) {
138138
this.chain.clear();

src/main/java/org/javamoney/tck/tests/format/FormattingMonetaryAmountsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void testParseIsIndependentOfImplementation() {
128128
}
129129

130130
/**
131-
* Get/setTyped different amount styles (especially patterns, group
131+
* Get/set different amount styles (especially patterns, group
132132
* sizes, group characters) and compare results with results as from
133133
* RI.
134134
* Also apply patterns without currency invovled.
@@ -172,7 +172,7 @@ public void testParseDifferentStyles() {
172172

173173

174174
/**
175-
* Get/setTyped default currency, try to parse patterns without
175+
* Get/set default currency, try to parse patterns without
176176
* currency information.
177177
*/
178178
@SpecAssertion(section = "4.4.1", id = "441-A6")

src/main/java/org/javamoney/tck/tests/internal/TestRoundingProvider.java

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,30 @@
1616
import java.math.RoundingMode;
1717
import java.util.HashMap;
1818
import java.util.Map;
19+
import java.util.Optional;
1920
import java.util.Set;
2021

2122
/**
2223
* Test ExchangeProvider. Created by Anatole on 26.04.2014.
2324
*/
24-
public class TestRoundingProvider implements RoundingProviderSpi{
25+
public class TestRoundingProvider implements RoundingProviderSpi {
2526

2627
private static final RoundingContext CONTEXT =
2728
RoundingContextBuilder.of(TestRoundingProvider.class.getSimpleName(), "NOSCALE").build();
2829
private static final RoundingContext CONTEXT_CASH =
2930
RoundingContextBuilder.of(TestRoundingProvider.class.getSimpleName(), "cashRounding").build();
3031

31-
private Map<String,MonetaryRounding> customRoundings = new HashMap<>();
32+
private Map<String, MonetaryRounding> customRoundings = new HashMap<>();
3233

33-
public TestRoundingProvider(){
34-
customRoundings.put("NOSCALE", new MonetaryRounding(){
34+
public TestRoundingProvider() {
35+
customRoundings.put("NOSCALE", new MonetaryRounding() {
3536
@Override
36-
public RoundingContext getRoundingContext(){
37+
public RoundingContext getRoundingContext() {
3738
return CONTEXT;
3839
}
3940

4041
@Override
41-
public MonetaryAmount apply(MonetaryAmount value){
42+
public MonetaryAmount apply(MonetaryAmount value) {
4243
return value.getFactory()
4344
.setNumber(value.getNumber().numberValue(BigDecimal.class).setScale(0, RoundingMode.HALF_EVEN))
4445
.create();
@@ -47,46 +48,46 @@ public MonetaryAmount apply(MonetaryAmount value){
4748
}
4849

4950
@Override
50-
public MonetaryRounding getRounding(RoundingQuery context){
51+
public MonetaryRounding getRounding(RoundingQuery context) {
5152
MonetaryRounding customRounding = customRoundings.get(context.getRoundingName());
52-
if(customRounding != null){
53+
if (customRounding != null) {
5354
return customRounding;
5455
}
55-
if(context.getCurrency() == null){
56+
if (context.getCurrency() == null) {
5657
return null;
5758
}
58-
Boolean cashRounding = context.getBoolean("cashRounding", Boolean.FALSE);
59+
Boolean cashRounding = Optional.ofNullable(context.getBoolean("cashRounding")).orElse(Boolean.FALSE);
5960
Long timestamp = context.getTimestampMillis();
60-
if(cashRounding){
61-
if(timestamp != null){
61+
if (cashRounding) {
62+
if (timestamp != null) {
6263
return getCashRounding(context.getCurrency(), timestamp);
6364
}
6465
return getCashRounding(context.getCurrency());
65-
}else{
66-
if("XAU".equals(context.getCurrency().getCurrencyCode())){
67-
if(timestamp != null){
68-
return new MonetaryRounding(){
66+
} else {
67+
if ("XAU".equals(context.getCurrency().getCurrencyCode())) {
68+
if (timestamp != null) {
69+
return new MonetaryRounding() {
6970
@Override
70-
public RoundingContext getRoundingContext(){
71+
public RoundingContext getRoundingContext() {
7172
return CONTEXT;
7273
}
7374

7475
@Override
75-
public MonetaryAmount apply(MonetaryAmount value){
76+
public MonetaryAmount apply(MonetaryAmount value) {
7677
return value.getFactory().setNumber(
7778
value.getNumber().numberValue(BigDecimal.class).setScale(2, RoundingMode.UP))
7879
.create();
7980
}
8081
};
8182
}
82-
return new MonetaryRounding(){
83+
return new MonetaryRounding() {
8384
@Override
84-
public RoundingContext getRoundingContext(){
85+
public RoundingContext getRoundingContext() {
8586
return CONTEXT;
8687
}
8788

8889
@Override
89-
public MonetaryAmount apply(MonetaryAmount value){
90+
public MonetaryAmount apply(MonetaryAmount value) {
9091
return value.getFactory()
9192
.setNumber(value.getNumber().numberValue(BigDecimal.class).setScale(4, RoundingMode.UP))
9293
.create();
@@ -98,16 +99,16 @@ public MonetaryAmount apply(MonetaryAmount value){
9899
}
99100

100101

101-
private MonetaryRounding getCashRounding(CurrencyUnit currency){
102-
if("XAU".equals(currency.getCurrencyCode())){
103-
return new MonetaryRounding(){
102+
private MonetaryRounding getCashRounding(CurrencyUnit currency) {
103+
if ("XAU".equals(currency.getCurrencyCode())) {
104+
return new MonetaryRounding() {
104105
@Override
105-
public RoundingContext getRoundingContext(){
106+
public RoundingContext getRoundingContext() {
106107
return CONTEXT_CASH;
107108
}
108109

109110
@Override
110-
public MonetaryAmount apply(MonetaryAmount value){
111+
public MonetaryAmount apply(MonetaryAmount value) {
111112
return value.getFactory()
112113
.setNumber(value.getNumber().numberValue(BigDecimal.class).setScale(1, RoundingMode.DOWN))
113114
.create();
@@ -117,16 +118,16 @@ public MonetaryAmount apply(MonetaryAmount value){
117118
return null;
118119
}
119120

120-
private MonetaryRounding getCashRounding(CurrencyUnit currency, long timestamp){
121-
if("XAU".equals(currency.getCurrencyCode()) && timestamp < 100){
122-
return new MonetaryRounding(){
121+
private MonetaryRounding getCashRounding(CurrencyUnit currency, long timestamp) {
122+
if ("XAU".equals(currency.getCurrencyCode()) && timestamp < 100) {
123+
return new MonetaryRounding() {
123124
@Override
124-
public RoundingContext getRoundingContext(){
125+
public RoundingContext getRoundingContext() {
125126
return CONTEXT_CASH;
126127
}
127128

128129
@Override
129-
public MonetaryAmount apply(MonetaryAmount value){
130+
public MonetaryAmount apply(MonetaryAmount value) {
130131
return value.getFactory()
131132
.setNumber(value.getNumber().numberValue(BigDecimal.class).setScale(2, RoundingMode.DOWN))
132133
.create();
@@ -137,7 +138,7 @@ public MonetaryAmount apply(MonetaryAmount value){
137138
}
138139

139140
@Override
140-
public Set<String> getRoundingNames(){
141+
public Set<String> getRoundingNames() {
141142
return customRoundings.keySet();
142143
}
143144
}

0 commit comments

Comments
 (0)