Skip to content

Commit bf05608

Browse files
committed
3: Create new ExchangeRateProvider implementations for Bitcoin
Task-Url: http://github.com/JavaMoney/javamoney-shelter/issues/issue/3
1 parent 0efaee6 commit bf05608

File tree

7 files changed

+17
-29
lines changed

7 files changed

+17
-29
lines changed

digital-currency/bitcoin/src/test/groovy/org/javamoney/shelter/bitcoin/provider/BitcoinCurrencyProviderSpec.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import javax.money.CurrencyQuery
99
import javax.money.CurrencyQueryBuilder
1010
import javax.money.CurrencyUnit
1111
import javax.money.MonetaryAmount
12-
import javax.money.MonetaryCurrencies
12+
import javax.money.Monetary
1313
import javax.money.UnknownCurrencyException
1414

1515
/**
@@ -63,9 +63,9 @@ class BitcoinCurrencyProviderSpec extends Specification {
6363
currencies.size() == 0
6464
}
6565

66-
def "BTC can't be found via MonetaryCurrencies" () {
66+
def "BTC can't be found via Monetary" () {
6767
when: "We try to get currency 'BTC' when BitcoinCurrencyProvider is not registered"
68-
CurrencyUnit btc = MonetaryCurrencies.getCurrency("BTC")
68+
CurrencyUnit btc = Monetary.getCurrency("BTC")
6969

7070
then: "An UnknownCurrencyException is thrown"
7171
UnknownCurrencyException e = thrown()

digital-currency/bitcoin/src/test/java/org/javamoney/shelter/bitcoin/provider/BitcoinCurrencyProviderTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
package org.javamoney.shelter.bitcoin.provider;
22

3-
import org.javamoney.moneta.CurrencyUnitBuilder;
4-
import org.javamoney.moneta.Money;
53
import org.junit.Test;
64

7-
import javax.money.CurrencyQuery;
8-
import javax.money.CurrencyQueryBuilder;
9-
import javax.money.CurrencyUnit;
10-
import javax.money.MonetaryAmount;
11-
import javax.money.MonetaryCurrencies;
12-
import javax.money.UnknownCurrencyException;
13-
import java.util.Set;
14-
15-
import static org.junit.Assert.assertEquals;
16-
import static org.junit.Assert.assertNotNull;
175
import static org.junit.Assert.assertTrue;
186

197
/**

digital-currency/bitcoin/src/test/java/org/javamoney/shelter/bitcoin/provider/BitcoinDeConversionDemo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package org.javamoney.shelter.bitcoin.provider;
1616

1717
import javax.money.CurrencyUnit;
18-
import javax.money.MonetaryCurrencies;
18+
import javax.money.Monetary;
1919
import javax.money.MonetaryException;
2020
import javax.money.convert.ExchangeRate;
2121
import org.javamoney.moneta.CurrencyUnitBuilder;
@@ -31,13 +31,13 @@ public static void main(String... arg) throws MonetaryException {
3131
//MtGoxV2ConversionProvider provider = new MtGoxV2ConversionProvider("USD");
3232
BitcoinDeRateProvider provider = new BitcoinDeRateProvider();
3333
provider.loadRate("USD", true);
34-
ExchangeRate rate = provider.getExchangeRate(MonetaryCurrencies.getCurrency("USD"), btc);
34+
ExchangeRate rate = provider.getExchangeRate(Monetary.getCurrency("USD"), btc);
3535
System.out.println("Rate: " + rate);
3636

37-
rate = provider.getExchangeRate(MonetaryCurrencies.getCurrency("EUR"), btc);
37+
rate = provider.getExchangeRate(Monetary.getCurrency("EUR"), btc);
3838
System.out.println("Rate2: " + rate);
3939

40-
rate = provider.getExchangeRate(MonetaryCurrencies.getCurrency("CHF"), btc);
40+
rate = provider.getExchangeRate(Monetary.getCurrency("CHF"), btc);
4141
System.out.println("Rate3: " + rate);
4242
}
4343
}

groovylang-support/groovy-money/src/main/groovy/com/msgilligan/moneta/NumberCategory.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.javamoney.moneta.spi.DefaultNumberValue
66

77
import javax.money.CurrencyUnit
88
import javax.money.MonetaryAmount
9-
import javax.money.MonetaryCurrencies
9+
import javax.money.Monetary
1010
import javax.money.NumberValue
1111

1212
/**
@@ -35,7 +35,7 @@ class NumberCategory {
3535
* @throws UnknownCurrencyException when currency code not found
3636
*/
3737
MonetaryAmount get(String name) {
38-
CurrencyUnit currency = MonetaryCurrencies.getCurrency(name.toUpperCase())
38+
CurrencyUnit currency = Monetary.getCurrency(name.toUpperCase())
3939
return Money.of(this, currency)
4040
}
4141

groovylang-support/groovy-money/src/test/groovy/JavaMoneySpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import spock.util.mop.Use
1414

1515
import javax.money.CurrencyUnit
1616
import javax.money.MonetaryAmount
17-
import javax.money.MonetaryCurrencies
17+
import javax.money.Monetary
1818
import javax.money.NumberValue
1919

2020
/**
@@ -33,7 +33,7 @@ class JavaMoneySpec extends Specification {
3333

3434
def "get currency unit" () {
3535
when:
36-
CurrencyUnit usDollar = MonetaryCurrencies.getCurrency("USD")
36+
CurrencyUnit usDollar = Monetary.getCurrency("USD")
3737

3838
then:
3939
usDollar.currencyCode == "USD"

groovylang-support/groovy-money/src/test/groovy/NumberCategorySpec.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import spock.util.mop.Use
88

99
import javax.money.CurrencyUnit
1010
import javax.money.MonetaryAmount
11-
import javax.money.MonetaryCurrencies
11+
import javax.money.Monetary
1212

1313

1414
/**
@@ -23,7 +23,7 @@ class NumberCategorySpec extends Specification {
2323
then:
2424
aBuck instanceof MonetaryAmount
2525
aBuck.number == 1
26-
aBuck.currency == MonetaryCurrencies.getCurrency("USD")
26+
aBuck.currency == Monetary.getCurrency("USD")
2727
}
2828

2929
def "can make EUR"() {
@@ -33,7 +33,7 @@ class NumberCategorySpec extends Specification {
3333
then:
3434
amount instanceof MonetaryAmount
3535
amount.number == 1
36-
amount.currency == MonetaryCurrencies.getCurrency("EUR")
36+
amount.currency == Monetary.getCurrency("EUR")
3737
}
3838

3939
def "can make any supported currency via propertyMissing"() {
@@ -43,7 +43,7 @@ class NumberCategorySpec extends Specification {
4343
then:
4444
amount instanceof MonetaryAmount
4545
amount.number == 1
46-
amount.currency == MonetaryCurrencies.getCurrency("JPY")
46+
amount.currency == Monetary.getCurrency("JPY")
4747
}
4848

4949
def "Undefined currency should throw UnknownCurrencyException"() {
@@ -62,7 +62,7 @@ class NumberCategorySpec extends Specification {
6262
then:
6363
amount instanceof MonetaryAmount
6464
amount.number == 0.99
65-
amount.currency == MonetaryCurrencies.getCurrency("USD")
65+
amount.currency == Monetary.getCurrency("USD")
6666
}
6767

6868
@Unroll

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<junit.version>4.8.2</junit.version>
2222
<slf4j.version>1.6.1</slf4j.version>
2323
<!-- JSR versions -->
24-
<jsr.version>1.0-RC3</jsr.version>
24+
<jsr.version>1.0</jsr.version>
2525
<!-- javamoney.version>0.6-SNAPSHOT</javamoney.version -->
2626
</properties>
2727

0 commit comments

Comments
 (0)