From 2b0e1a78b30a33bf6ee8b7a21ec081cc7452a402 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Sun, 18 Aug 2024 10:11:09 +0100 Subject: [PATCH] Migrate to AssertJ --- .../java/org/joda/money/TestBigMoney.java | 188 +++++++++--------- .../java/org/joda/money/TestCurrencyUnit.java | 24 +-- .../joda/money/TestCurrencyUnitExtension.java | 4 +- src/test/java/org/joda/money/TestMoney.java | 144 +++++++------- .../money/format/TestMoneyAmountStyle.java | 2 +- .../joda/money/format/TestMoneyFormatter.java | 16 +- .../format/TestMoneyFormatterBuilder.java | 46 ++--- .../money/format/TestMoneyParseContext.java | 2 +- 8 files changed, 213 insertions(+), 213 deletions(-) diff --git a/src/test/java/org/joda/money/TestBigMoney.java b/src/test/java/org/joda/money/TestBigMoney.java index 53d71d1..4a89899 100644 --- a/src/test/java/org/joda/money/TestBigMoney.java +++ b/src/test/java/org/joda/money/TestBigMoney.java @@ -978,7 +978,7 @@ void test_getCurrencyUnit_EUR() { @Test void test_withCurrencyUnit_Currency() { BigMoney test = GBP_2_34.withCurrencyUnit(USD); - assertThat(test.toString()).isEqualTo("USD 2.34"); + assertThat(test).hasToString("USD 2.34"); } @Test @@ -990,7 +990,7 @@ void test_withCurrencyUnit_Currency_same() { @Test void test_withCurrencyUnit_Currency_differentCurrencyScale() { BigMoney test = GBP_2_34.withCurrencyUnit(JPY); - assertThat(test.toString()).isEqualTo("JPY 2.34"); + assertThat(test).hasToString("JPY 2.34"); } @Test @@ -1363,21 +1363,21 @@ void test_withAmount_double_same() { void test_plus_Iterable_BigMoneyProvider() { Iterable iterable = Arrays.asList(GBP_2_33, GBP_1_23); BigMoney test = GBP_2_34.plus(iterable); - assertThat(test.toString()).isEqualTo("GBP 5.90"); + assertThat(test).hasToString("GBP 5.90"); } @Test void test_plus_Iterable_BigMoney() { Iterable iterable = Arrays.asList(GBP_2_33, GBP_1_23); BigMoney test = GBP_2_34.plus(iterable); - assertThat(test.toString()).isEqualTo("GBP 5.90"); + assertThat(test).hasToString("GBP 5.90"); } @Test void test_plus_Iterable_Money() { Iterable iterable = Arrays.asList(GBP_2_33.toMoney(), GBP_1_23.toMoney()); BigMoney test = GBP_2_34.plus(iterable); - assertThat(test.toString()).isEqualTo("GBP 5.90"); + assertThat(test).hasToString("GBP 5.90"); } @Test @@ -1389,7 +1389,7 @@ public BigMoney toBigMoney() { } }); BigMoney test = GBP_2_34.plus(iterable); - assertThat(test.toString()).isEqualTo("GBP 5.90"); + assertThat(test).hasToString("GBP 5.90"); } @Test @@ -1443,28 +1443,28 @@ void test_plus_BigMoneyProvider_zero() { @Test void test_plus_BigMoneyProvider_positive() { BigMoney test = GBP_2_34.plus(GBP_1_23); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plus_BigMoneyProvider_negative() { BigMoney test = GBP_2_34.plus(GBP_M1_23); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plus_BigMoneyProvider_scale() { BigMoney test = GBP_2_34.plus(BigMoney.parse("GBP 1.111")); - assertThat(test.toString()).isEqualTo("GBP 3.451"); + assertThat(test).hasToString("GBP 3.451"); assertThat(test.getScale()).isEqualTo(3); } @Test void test_plus_BigMoneyProvider_Money() { BigMoney test = GBP_2_34.plus(BigMoney.ofMinor(GBP, 1)); - assertThat(test.toString()).isEqualTo("GBP 2.35"); + assertThat(test).hasToString("GBP 2.35"); assertThat(test.getScale()).isEqualTo(2); } @@ -1504,21 +1504,21 @@ void test_plus_BigDecimal_zero() { @Test void test_plus_BigDecimal_positive() { BigMoney test = GBP_2_34.plus(bd("1.23")); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plus_BigDecimal_negative() { BigMoney test = GBP_2_34.plus(bd("-1.23")); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plus_BigDecimal_scale() { BigMoney test = GBP_2_34.plus(bd("1.235")); - assertThat(test.toString()).isEqualTo("GBP 3.575"); + assertThat(test).hasToString("GBP 3.575"); assertThat(test.getScale()).isEqualTo(3); } @@ -1540,21 +1540,21 @@ void test_plus_double_zero() { @Test void test_plus_double_positive() { BigMoney test = GBP_2_34.plus(1.23d); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plus_double_negative() { BigMoney test = GBP_2_34.plus(-1.23d); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plus_double_scale() { BigMoney test = GBP_2_34.plus(1.234d); - assertThat(test.toString()).isEqualTo("GBP 3.574"); + assertThat(test).hasToString("GBP 3.574"); assertThat(test.getScale()).isEqualTo(3); } @@ -1570,14 +1570,14 @@ void test_plusMajor_zero() { @Test void test_plusMajor_positive() { BigMoney test = GBP_2_34.plusMajor(123); - assertThat(test.toString()).isEqualTo("GBP 125.34"); + assertThat(test).hasToString("GBP 125.34"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plusMajor_negative() { BigMoney test = GBP_2_34.plusMajor(-123); - assertThat(test.toString()).isEqualTo("GBP -120.66"); + assertThat(test).hasToString("GBP -120.66"); assertThat(test.getScale()).isEqualTo(2); } @@ -1593,21 +1593,21 @@ void test_plusMinor_zero() { @Test void test_plusMinor_positive() { BigMoney test = GBP_2_34.plusMinor(123); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plusMinor_negative() { BigMoney test = GBP_2_34.plusMinor(-123); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_plusMinor_scale() { BigMoney test = BigMoney.parse("GBP 12").plusMinor(123); - assertThat(test.toString()).isEqualTo("GBP 13.23"); + assertThat(test).hasToString("GBP 13.23"); assertThat(test.getScale()).isEqualTo(2); } @@ -1623,19 +1623,19 @@ void test_plusRetainScale_BigMoneyProviderRoundingMode_zero() { @Test void test_plusRetainScale_BigMoneyProviderRoundingMode_positive() { BigMoney test = GBP_2_34.plusRetainScale(BigMoney.parse("GBP 1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plusRetainScale_BigMoneyProviderRoundingMode_negative() { BigMoney test = GBP_2_34.plusRetainScale(BigMoney.parse("GBP -1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_plusRetainScale_BigMoneyProviderRoundingMode_roundDown() { BigMoney test = GBP_2_34.plusRetainScale(BigMoney.parse("GBP 1.235"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1668,19 +1668,19 @@ void test_plusRetainScale_BigDecimalRoundingMode_zero() { @Test void test_plusRetainScale_BigDecimalRoundingMode_positive() { BigMoney test = GBP_2_34.plusRetainScale(bd("1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plusRetainScale_BigDecimalRoundingMode_negative() { BigMoney test = GBP_2_34.plusRetainScale(bd("-1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_plusRetainScale_BigDecimalRoundingMode_roundDown() { BigMoney test = GBP_2_34.plusRetainScale(bd("1.235"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1713,19 +1713,19 @@ void test_plusRetainScale_doubleRoundingMode_zero() { @Test void test_plusRetainScale_doubleRoundingMode_positive() { BigMoney test = GBP_2_34.plusRetainScale(1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plusRetainScale_doubleRoundingMode_negative() { BigMoney test = GBP_2_34.plusRetainScale(-1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_plusRetainScale_doubleRoundingMode_roundDown() { BigMoney test = GBP_2_34.plusRetainScale(1.235d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1747,21 +1747,21 @@ void test_plusRetainScale_doubleRoundingMode_nullRoundingMode() { void test_minus_Iterable_BigMoneyProvider() { Iterable iterable = Arrays.asList(GBP_2_33, GBP_1_23); BigMoney test = GBP_2_34.minus(iterable); - assertThat(test.toString()).isEqualTo("GBP -1.22"); + assertThat(test).hasToString("GBP -1.22"); } @Test void test_minus_Iterable_BigMoney() { Iterable iterable = Arrays.asList(GBP_2_33, GBP_1_23); BigMoney test = GBP_2_34.minus(iterable); - assertThat(test.toString()).isEqualTo("GBP -1.22"); + assertThat(test).hasToString("GBP -1.22"); } @Test void test_minus_Iterable_Money() { Iterable iterable = Arrays.asList(GBP_2_33.toMoney(), GBP_1_23.toMoney()); BigMoney test = GBP_2_34.minus(iterable); - assertThat(test.toString()).isEqualTo("GBP -1.22"); + assertThat(test).hasToString("GBP -1.22"); } @Test @@ -1773,7 +1773,7 @@ public BigMoney toBigMoney() { } }); BigMoney test = GBP_2_34.minus(iterable); - assertThat(test.toString()).isEqualTo("GBP -1.22"); + assertThat(test).hasToString("GBP -1.22"); } @Test @@ -1827,28 +1827,28 @@ void test_minus_BigMoneyProvider_zero() { @Test void test_minus_BigMoneyProvider_positive() { BigMoney test = GBP_2_34.minus(GBP_1_23); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minus_BigMoneyProvider_negative() { BigMoney test = GBP_2_34.minus(GBP_M1_23); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minus_BigMoneyProvider_scale() { BigMoney test = GBP_2_34.minus(BigMoney.parse("GBP 1.111")); - assertThat(test.toString()).isEqualTo("GBP 1.229"); + assertThat(test).hasToString("GBP 1.229"); assertThat(test.getScale()).isEqualTo(3); } @Test void test_minus_BigMoneyProvider_Money() { BigMoney test = GBP_2_34.minus(BigMoney.ofMinor(GBP, 1)); - assertThat(test.toString()).isEqualTo("GBP 2.33"); + assertThat(test).hasToString("GBP 2.33"); assertThat(test.getScale()).isEqualTo(2); } @@ -1888,21 +1888,21 @@ void test_minus_BigDecimal_zero() { @Test void test_minus_BigDecimal_positive() { BigMoney test = GBP_2_34.minus(bd("1.23")); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minus_BigDecimal_negative() { BigMoney test = GBP_2_34.minus(bd("-1.23")); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minus_BigDecimal_scale() { BigMoney test = GBP_2_34.minus(bd("1.235")); - assertThat(test.toString()).isEqualTo("GBP 1.105"); + assertThat(test).hasToString("GBP 1.105"); assertThat(test.getScale()).isEqualTo(3); } @@ -1924,21 +1924,21 @@ void test_minus_double_zero() { @Test void test_minus_double_positive() { BigMoney test = GBP_2_34.minus(1.23d); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minus_double_negative() { BigMoney test = GBP_2_34.minus(-1.23d); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minus_double_scale() { BigMoney test = GBP_2_34.minus(1.235d); - assertThat(test.toString()).isEqualTo("GBP 1.105"); + assertThat(test).hasToString("GBP 1.105"); assertThat(test.getScale()).isEqualTo(3); } @@ -1954,14 +1954,14 @@ void test_minusMajor_zero() { @Test void test_minusMajor_positive() { BigMoney test = GBP_2_34.minusMajor(123); - assertThat(test.toString()).isEqualTo("GBP -120.66"); + assertThat(test).hasToString("GBP -120.66"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minusMajor_negative() { BigMoney test = GBP_2_34.minusMajor(-123); - assertThat(test.toString()).isEqualTo("GBP 125.34"); + assertThat(test).hasToString("GBP 125.34"); assertThat(test.getScale()).isEqualTo(2); } @@ -1977,21 +1977,21 @@ void test_minusMinor_zero() { @Test void test_minusMinor_positive() { BigMoney test = GBP_2_34.minusMinor(123); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minusMinor_negative() { BigMoney test = GBP_2_34.minusMinor(-123); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_minusMinor_scale() { BigMoney test = BigMoney.parse("GBP 12").minusMinor(123); - assertThat(test.toString()).isEqualTo("GBP 10.77"); + assertThat(test).hasToString("GBP 10.77"); assertThat(test.getScale()).isEqualTo(2); } @@ -2007,19 +2007,19 @@ void test_minusRetainScale_BigMoneyProviderRoundingMode_zero() { @Test void test_minusRetainScale_BigMoneyProviderRoundingMode_positive() { BigMoney test = GBP_2_34.minusRetainScale(BigMoney.parse("GBP 1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minusRetainScale_BigMoneyProviderRoundingMode_negative() { BigMoney test = GBP_2_34.minusRetainScale(BigMoney.parse("GBP -1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_minusRetainScale_BigMoneyProviderRoundingMode_roundDown() { BigMoney test = GBP_2_34.minusRetainScale(BigMoney.parse("GBP 1.235"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 1.10"); + assertThat(test).hasToString("GBP 1.10"); } @Test @@ -2052,19 +2052,19 @@ void test_minusRetainScale_BigDecimalRoundingMode_zero() { @Test void test_minusRetainScale_BigDecimalRoundingMode_positive() { BigMoney test = GBP_2_34.minusRetainScale(bd("1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minusRetainScale_BigDecimalRoundingMode_negative() { BigMoney test = GBP_2_34.minusRetainScale(bd("-1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_minusRetainScale_BigDecimalRoundingMode_roundDown() { BigMoney test = GBP_2_34.minusRetainScale(bd("1.235"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 1.10"); + assertThat(test).hasToString("GBP 1.10"); } @Test @@ -2097,19 +2097,19 @@ void test_minusRetainScale_doubleRoundingMode_zero() { @Test void test_minusRetainScale_doubleRoundingMode_positive() { BigMoney test = GBP_2_34.minusRetainScale(1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minusRetainScale_doubleRoundingMode_negative() { BigMoney test = GBP_2_34.minusRetainScale(-1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_minusRetainScale_doubleRoundingMode_roundDown() { BigMoney test = GBP_2_34.minusRetainScale(1.235d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 1.10"); + assertThat(test).hasToString("GBP 1.10"); } @Test @@ -2136,14 +2136,14 @@ void test_multipliedBy_BigDecimal_one() { @Test void test_multipliedBy_BigDecimal_positive() { BigMoney test = GBP_2_33.multipliedBy(bd("2.5")); - assertThat(test.toString()).isEqualTo("GBP 5.825"); + assertThat(test).hasToString("GBP 5.825"); assertThat(test.getScale()).isEqualTo(3); } @Test void test_multipliedBy_BigDecimal_negative() { BigMoney test = GBP_2_33.multipliedBy(bd("-2.5")); - assertThat(test.toString()).isEqualTo("GBP -5.825"); + assertThat(test).hasToString("GBP -5.825"); assertThat(test.getScale()).isEqualTo(3); } @@ -2165,14 +2165,14 @@ void test_multipliedBy_doubleRoundingMode_one() { @Test void test_multipliedBy_doubleRoundingMode_positive() { BigMoney test = GBP_2_33.multipliedBy(2.5d); - assertThat(test.toString()).isEqualTo("GBP 5.825"); + assertThat(test).hasToString("GBP 5.825"); assertThat(test.getScale()).isEqualTo(3); } @Test void test_multipliedBy_doubleRoundingMode_negative() { BigMoney test = GBP_2_33.multipliedBy(-2.5d); - assertThat(test.toString()).isEqualTo("GBP -5.825"); + assertThat(test).hasToString("GBP -5.825"); assertThat(test.getScale()).isEqualTo(3); } @@ -2188,14 +2188,14 @@ void test_multipliedBy_long_one() { @Test void test_multipliedBy_long_positive() { BigMoney test = GBP_2_34.multipliedBy(3); - assertThat(test.toString()).isEqualTo("GBP 7.02"); + assertThat(test).hasToString("GBP 7.02"); assertThat(test.getScale()).isEqualTo(2); } @Test void test_multipliedBy_long_negative() { BigMoney test = GBP_2_34.multipliedBy(-3); - assertThat(test.toString()).isEqualTo("GBP -7.02"); + assertThat(test).hasToString("GBP -7.02"); assertThat(test.getScale()).isEqualTo(2); } @@ -2211,19 +2211,19 @@ void test_multiplyRetainScale_BigDecimalRoundingMode_one() { @Test void test_multiplyRetainScale_BigDecimalRoundingMode_positive() { BigMoney test = GBP_2_33.multiplyRetainScale(bd("2.5"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 5.82"); + assertThat(test).hasToString("GBP 5.82"); } @Test void test_multiplyRetainScale_BigDecimalRoundingMode_positive_halfUp() { BigMoney test = GBP_2_33.multiplyRetainScale(bd("2.5"), RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 5.83"); + assertThat(test).hasToString("GBP 5.83"); } @Test void test_multiplyRetainScale_BigDecimalRoundingMode_negative() { BigMoney test = GBP_2_33.multiplyRetainScale(bd("-2.5"), RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -5.83"); + assertThat(test).hasToString("GBP -5.83"); } @Test @@ -2250,19 +2250,19 @@ void test_multiplyRetainScale_doubleRoundingMode_one() { @Test void test_multiplyRetainScale_doubleRoundingMode_positive() { BigMoney test = GBP_2_33.multiplyRetainScale(2.5d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 5.82"); + assertThat(test).hasToString("GBP 5.82"); } @Test void test_multiplyRetainScale_doubleRoundingMode_positive_halfUp() { BigMoney test = GBP_2_33.multiplyRetainScale(2.5d, RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 5.83"); + assertThat(test).hasToString("GBP 5.83"); } @Test void test_multiplyRetainScale_doubleRoundingMode_negative() { BigMoney test = GBP_2_33.multiplyRetainScale(-2.5d, RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -5.83"); + assertThat(test).hasToString("GBP -5.83"); } @Test @@ -2283,19 +2283,19 @@ void test_dividedBy_BigDecimalRoundingMode_one() { @Test void test_dividedBy_BigDecimalRoundingMode_positive() { BigMoney test = GBP_2_34.dividedBy(bd("2.5"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.93"); + assertThat(test).hasToString("GBP 0.93"); } @Test void test_dividedBy_BigDecimalRoundingMode_positive_halfUp() { BigMoney test = GBP_2_34.dividedBy(bd("2.5"), RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 0.94"); + assertThat(test).hasToString("GBP 0.94"); } @Test void test_dividedBy_BigDecimalRoundingMode_negative() { BigMoney test = GBP_2_34.dividedBy(bd("-2.5"), RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -0.94"); + assertThat(test).hasToString("GBP -0.94"); } @Test @@ -2322,19 +2322,19 @@ void test_dividedBy_doubleRoundingMode_one() { @Test void test_dividedBy_doubleRoundingMode_positive() { BigMoney test = GBP_2_34.dividedBy(2.5d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.93"); + assertThat(test).hasToString("GBP 0.93"); } @Test void test_dividedBy_doubleRoundingMode_positive_halfUp() { BigMoney test = GBP_2_34.dividedBy(2.5d, RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 0.94"); + assertThat(test).hasToString("GBP 0.94"); } @Test void test_dividedBy_doubleRoundingMode_negative() { BigMoney test = GBP_2_34.dividedBy(-2.5d, RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -0.94"); + assertThat(test).hasToString("GBP -0.94"); } @Test @@ -2355,25 +2355,25 @@ void test_dividedBy_long_one() { @Test void test_dividedBy_long_positive() { BigMoney test = GBP_2_34.dividedBy(3, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.78"); + assertThat(test).hasToString("GBP 0.78"); } @Test void test_dividedBy_long_positive_roundDown() { BigMoney test = GBP_2_35.dividedBy(3, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.78"); + assertThat(test).hasToString("GBP 0.78"); } @Test void test_dividedBy_long_positive_roundUp() { BigMoney test = GBP_2_35.dividedBy(3, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 0.79"); + assertThat(test).hasToString("GBP 0.79"); } @Test void test_dividedBy_long_negative() { BigMoney test = GBP_2_34.dividedBy(-3, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP -0.78"); + assertThat(test).hasToString("GBP -0.78"); } //----------------------------------------------------------------------- @@ -2388,13 +2388,13 @@ void test_negated_zero() { @Test void test_negated_positive() { BigMoney test = GBP_2_34.negated(); - assertThat(test.toString()).isEqualTo("GBP -2.34"); + assertThat(test).hasToString("GBP -2.34"); } @Test void test_negated_negative() { BigMoney test = BigMoney.parse("GBP -2.34").negated(); - assertThat(test.toString()).isEqualTo("GBP 2.34"); + assertThat(test).hasToString("GBP 2.34"); } //----------------------------------------------------------------------- @@ -2409,7 +2409,7 @@ void test_abs_positive() { @Test void test_abs_negative() { BigMoney test = BigMoney.parse("GBP -2.34").abs(); - assertThat(test.toString()).isEqualTo("GBP 2.34"); + assertThat(test).hasToString("GBP 2.34"); } //----------------------------------------------------------------------- @@ -2430,37 +2430,37 @@ void test_round_2up() { @Test void test_round_1down() { BigMoney test = GBP_2_34.rounded(1, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 2.30"); + assertThat(test).hasToString("GBP 2.30"); } @Test void test_round_1up() { BigMoney test = GBP_2_34.rounded(1, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 2.40"); + assertThat(test).hasToString("GBP 2.40"); } @Test void test_round_0down() { BigMoney test = GBP_2_34.rounded(0, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 2.00"); + assertThat(test).hasToString("GBP 2.00"); } @Test void test_round_0up() { BigMoney test = GBP_2_34.rounded(0, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 3.00"); + assertThat(test).hasToString("GBP 3.00"); } @Test void test_round_M1down() { BigMoney test = BigMoney.parse("GBP 432.34").rounded(-1, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 430.00"); + assertThat(test).hasToString("GBP 430.00"); } @Test void test_round_M1up() { BigMoney test = BigMoney.parse("GBP 432.34").rounded(-1, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 440.00"); + assertThat(test).hasToString("GBP 440.00"); } @Test @@ -2475,7 +2475,7 @@ void test_round_3() { @Test void test_convertedTo_CurrencyUnit_BigDecimal_positive() { BigMoney test = GBP_2_33.convertedTo(EUR, bd("2.5")); - assertThat(test.toString()).isEqualTo("EUR 5.825"); + assertThat(test).hasToString("EUR 5.825"); } @Test @@ -2514,13 +2514,13 @@ void test_convertedTo_CurrencyUnit_BigDecimal_nullBigDecimal() { @Test void test_convertRetainScale_CurrencyUnit_BigDecimal_RoundingMode_positive() { BigMoney test = BigMoney.parse("GBP 2.2").convertRetainScale(EUR, bd("2.5"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("EUR 5.5"); + assertThat(test).hasToString("EUR 5.5"); } @Test void test_convertRetainScale_CurrencyUnit_BigDecimal_RoundingMode_roundHalfUp() { BigMoney test = BigMoney.parse("GBP 2.21").convertRetainScale(EUR, bd("2.5"), RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("EUR 5.53"); + assertThat(test).hasToString("EUR 5.53"); } @Test @@ -2847,13 +2847,13 @@ void test_equals_false() { @Test void test_toString_positive() { BigMoney test = BigMoney.of(GBP, BIGDEC_2_34); - assertThat(test.toString()).isEqualTo("GBP 2.34"); + assertThat(test).hasToString("GBP 2.34"); } @Test void test_toString_negative() { BigMoney test = BigMoney.of(EUR, BIGDEC_M5_78); - assertThat(test.toString()).isEqualTo("EUR -5.78"); + assertThat(test).hasToString("EUR -5.78"); } } diff --git a/src/test/java/org/joda/money/TestCurrencyUnit.java b/src/test/java/org/joda/money/TestCurrencyUnit.java index 7f1b9aa..67196e8 100644 --- a/src/test/java/org/joda/money/TestCurrencyUnit.java +++ b/src/test/java/org/joda/money/TestCurrencyUnit.java @@ -191,9 +191,9 @@ void test_registeredCurrencies_crossCheck() { @Test void test_registeredCountries() { List countryList = CurrencyUnit.registeredCountries(); - assertThat(countryList.contains("GB")).isTrue(); - assertThat(countryList.contains("EU")).isTrue(); - assertThat(countryList.contains("US")).isTrue(); + assertThat(countryList).contains("GB"); + assertThat(countryList).contains("EU"); + assertThat(countryList).contains("US"); } @Test @@ -513,7 +513,7 @@ void test_getNumeric3Code_AMD() { @Test void test_getNumeric3Code_XFU() { CurrencyUnit test = CurrencyUnit.of("XFU"); - assertThat(test.getNumeric3Code()).isEqualTo(""); + assertThat(test.getNumeric3Code()).isEmpty(); } //----------------------------------------------------------------------- @@ -531,10 +531,10 @@ void test_getNumericCode_GBP() { @Test void test_getCurrencyCodes_GBP() { Set test = CurrencyUnit.of("GBP").getCountryCodes(); - assertThat(test.contains("GB")).isTrue(); - assertThat(test.contains("IM")).isTrue(); - assertThat(test.contains("JE")).isTrue(); - assertThat(test.contains("GG")).isTrue(); + assertThat(test).contains("GB"); + assertThat(test).contains("IM"); + assertThat(test).contains("JE"); + assertThat(test).contains("GG"); } //----------------------------------------------------------------------- @@ -600,7 +600,7 @@ void test_getSymbol_JPY() { try { Locale.setDefault(Locale.UK); CurrencyUnit test = CurrencyUnit.of("JPY"); - assertThat(test.getSymbol().contains("JP")).isTrue(); + assertThat(test.getSymbol()).contains("JP"); } finally { Locale.setDefault(loc); } @@ -651,7 +651,7 @@ void test_getSymbol_Locale_GBP_France() { try { Locale.setDefault(Locale.UK); CurrencyUnit test = CurrencyUnit.of("GBP"); - assertThat(test.getSymbol(Locale.FRANCE).contains("GB")).isTrue(); + assertThat(test.getSymbol(Locale.FRANCE)).contains("GB"); } finally { Locale.setDefault(loc); } @@ -675,7 +675,7 @@ void test_getSymbol_Locale_USD_France() { try { Locale.setDefault(Locale.UK); CurrencyUnit test = CurrencyUnit.of("USD"); - assertThat(test.getSymbol(Locale.FRANCE).contains("US")).isTrue(); + assertThat(test.getSymbol(Locale.FRANCE)).contains("US"); } finally { Locale.setDefault(loc); } @@ -789,7 +789,7 @@ void test_equals_false() { @Test void test_toString() { CurrencyUnit test = CurrencyUnit.of("GBP"); - assertThat(test.toString()).isEqualTo("GBP"); + assertThat(test).hasToString("GBP"); } } diff --git a/src/test/java/org/joda/money/TestCurrencyUnitExtension.java b/src/test/java/org/joda/money/TestCurrencyUnitExtension.java index 42f05ef..35e9526 100644 --- a/src/test/java/org/joda/money/TestCurrencyUnitExtension.java +++ b/src/test/java/org/joda/money/TestCurrencyUnitExtension.java @@ -89,8 +89,8 @@ void test_CurrencyMissing() { void test_CurrencyEURChanged() { CurrencyUnit currency = CurrencyUnit.ofCountry("HU"); assertThat(currency).isEqualTo(CurrencyUnit.EUR); - assertThat(CurrencyUnit.EUR.getCountryCodes().contains("HU")).isTrue(); - assertThat(CurrencyUnit.of("HUF").getCountryCodes().isEmpty()).isTrue(); + assertThat(CurrencyUnit.EUR.getCountryCodes()).contains("HU"); + assertThat(CurrencyUnit.of("HUF").getCountryCodes()).isEmpty(); } } diff --git a/src/test/java/org/joda/money/TestMoney.java b/src/test/java/org/joda/money/TestMoney.java index 14ba63e..ef1e500 100644 --- a/src/test/java/org/joda/money/TestMoney.java +++ b/src/test/java/org/joda/money/TestMoney.java @@ -878,7 +878,7 @@ void test_getCurrencyUnit_EUR() { @Test void test_withCurrencyUnit_Currency() { Money test = GBP_2_34.withCurrencyUnit(USD); - assertThat(test.toString()).isEqualTo("USD 2.34"); + assertThat(test).hasToString("USD 2.34"); } @Test @@ -905,13 +905,13 @@ void test_withCurrencyUnit_Currency_nullCurrency() { @Test void test_withCurrencyUnit_CurrencyRoundingMode_DOWN() { Money test = GBP_2_34.withCurrencyUnit(JPY, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("JPY 2"); + assertThat(test).hasToString("JPY 2"); } @Test void test_withCurrencyUnit_CurrencyRoundingMode_UP() { Money test = GBP_2_34.withCurrencyUnit(JPY, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("JPY 3"); + assertThat(test).hasToString("JPY 3"); } @Test @@ -1153,7 +1153,7 @@ void test_isNegativeOrZero() { @Test void test_withAmount_BigDecimal() { Money test = GBP_2_34.withAmount(BIGDEC_M5_78); - assertThat(test.toString()).isEqualTo("GBP -5.78"); + assertThat(test).hasToString("GBP -5.78"); } @Test @@ -1180,7 +1180,7 @@ void test_withAmount_BigDecimal_nullBigDecimal() { @Test void test_withAmount_BigDecimalRoundingMode() { Money test = GBP_2_34.withAmount(BIGDEC_M5_78, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP -5.78"); + assertThat(test).hasToString("GBP -5.78"); } @Test @@ -1219,7 +1219,7 @@ void test_withAmount_BigDecimalRoundingMode_nullRoundingMode() { @Test void test_withAmount_double() { Money test = GBP_2_34.withAmount(-5.78d); - assertThat(test.toString()).isEqualTo("GBP -5.78"); + assertThat(test).hasToString("GBP -5.78"); } @Test @@ -1240,7 +1240,7 @@ void test_withAmount_double_invalidScale() { @Test void test_withAmount_doubleRoundingMode() { Money test = GBP_2_34.withAmount(-5.78d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP -5.78"); + assertThat(test).hasToString("GBP -5.78"); } @Test @@ -1274,7 +1274,7 @@ void test_withAmount_doubleRoundingMode_nullRoundingMode() { void test_plus_Iterable() { Iterable iterable = Arrays.asList(GBP_2_33, GBP_1_23); Money test = GBP_2_34.plus(iterable); - assertThat(test.toString()).isEqualTo("GBP 5.90"); + assertThat(test).hasToString("GBP 5.90"); } @Test @@ -1324,13 +1324,13 @@ void test_plus_Money_zero() { @Test void test_plus_Money_positive() { Money test = GBP_2_34.plus(GBP_1_23); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plus_Money_negative() { Money test = GBP_2_34.plus(GBP_M1_23); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test @@ -1365,13 +1365,13 @@ void test_plus_BigDecimal_zero() { @Test void test_plus_BigDecimal_positive() { Money test = GBP_2_34.plus(new BigDecimal("1.23")); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plus_BigDecimal_negative() { Money test = GBP_2_34.plus(new BigDecimal("-1.23")); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test @@ -1398,19 +1398,19 @@ void test_plus_BigDecimalRoundingMode_zero() { @Test void test_plus_BigDecimalRoundingMode_positive() { Money test = GBP_2_34.plus(new BigDecimal("1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plus_BigDecimalRoundingMode_negative() { Money test = GBP_2_34.plus(new BigDecimal("-1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_plus_BigDecimalRoundingMode_roundDown() { Money test = GBP_2_34.plus(new BigDecimal("1.235"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1443,13 +1443,13 @@ void test_plus_double_zero() { @Test void test_plus_double_positive() { Money test = GBP_2_34.plus(1.23d); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plus_double_negative() { Money test = GBP_2_34.plus(-1.23d); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test @@ -1470,19 +1470,19 @@ void test_plus_doubleRoundingMode_zero() { @Test void test_plus_doubleRoundingMode_positive() { Money test = GBP_2_34.plus(1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plus_doubleRoundingMode_negative() { Money test = GBP_2_34.plus(-1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_plus_doubleRoundingMode_roundDown() { Money test = GBP_2_34.plus(1.235d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1509,13 +1509,13 @@ void test_plusMajor_zero() { @Test void test_plusMajor_positive() { Money test = GBP_2_34.plusMajor(123); - assertThat(test.toString()).isEqualTo("GBP 125.34"); + assertThat(test).hasToString("GBP 125.34"); } @Test void test_plusMajor_negative() { Money test = GBP_2_34.plusMajor(-123); - assertThat(test.toString()).isEqualTo("GBP -120.66"); + assertThat(test).hasToString("GBP -120.66"); } //----------------------------------------------------------------------- @@ -1530,13 +1530,13 @@ void test_plusMinor_zero() { @Test void test_plusMinor_positive() { Money test = GBP_2_34.plusMinor(123); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_plusMinor_negative() { Money test = GBP_2_34.plusMinor(-123); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } //----------------------------------------------------------------------- @@ -1546,7 +1546,7 @@ void test_plusMinor_negative() { void test_minus_Iterable() { Iterable iterable = Arrays.asList(GBP_2_33, GBP_1_23); Money test = GBP_2_34.minus(iterable); - assertThat(test.toString()).isEqualTo("GBP -1.22"); + assertThat(test).hasToString("GBP -1.22"); } @Test @@ -1596,13 +1596,13 @@ void test_minus_Money_zero() { @Test void test_minus_Money_positive() { Money test = GBP_2_34.minus(GBP_1_23); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minus_Money_negative() { Money test = GBP_2_34.minus(GBP_M1_23); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1637,13 +1637,13 @@ void test_minus_BigDecimal_zero() { @Test void test_minus_BigDecimal_positive() { Money test = GBP_2_34.minus(new BigDecimal("1.23")); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minus_BigDecimal_negative() { Money test = GBP_2_34.minus(new BigDecimal("-1.23")); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1670,19 +1670,19 @@ void test_minus_BigDecimalRoundingMode_zero() { @Test void test_minus_BigDecimalRoundingMode_positive() { Money test = GBP_2_34.minus(new BigDecimal("1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minus_BigDecimalRoundingMode_negative() { Money test = GBP_2_34.minus(new BigDecimal("-1.23"), RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_minus_BigDecimalRoundingMode_roundDown() { Money test = GBP_2_34.minus(new BigDecimal("1.235"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 1.10"); + assertThat(test).hasToString("GBP 1.10"); } @Test @@ -1715,13 +1715,13 @@ void test_minus_double_zero() { @Test void test_minus_double_positive() { Money test = GBP_2_34.minus(1.23d); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minus_double_negative() { Money test = GBP_2_34.minus(-1.23d); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test @@ -1742,19 +1742,19 @@ void test_minus_doubleRoundingMode_zero() { @Test void test_minus_doubleRoundingMode_positive() { Money test = GBP_2_34.minus(1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minus_doubleRoundingMode_negative() { Money test = GBP_2_34.minus(-1.23d, RoundingMode.UNNECESSARY); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } @Test void test_minus_doubleRoundingMode_roundDown() { Money test = GBP_2_34.minus(1.235d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 1.10"); + assertThat(test).hasToString("GBP 1.10"); } @Test @@ -1781,13 +1781,13 @@ void test_minusMajor_zero() { @Test void test_minusMajor_positive() { Money test = GBP_2_34.minusMajor(123); - assertThat(test.toString()).isEqualTo("GBP -120.66"); + assertThat(test).hasToString("GBP -120.66"); } @Test void test_minusMajor_negative() { Money test = GBP_2_34.minusMajor(-123); - assertThat(test.toString()).isEqualTo("GBP 125.34"); + assertThat(test).hasToString("GBP 125.34"); } //----------------------------------------------------------------------- @@ -1802,13 +1802,13 @@ void test_minusMinor_zero() { @Test void test_minusMinor_positive() { Money test = GBP_2_34.minusMinor(123); - assertThat(test.toString()).isEqualTo("GBP 1.11"); + assertThat(test).hasToString("GBP 1.11"); } @Test void test_minusMinor_negative() { Money test = GBP_2_34.minusMinor(-123); - assertThat(test.toString()).isEqualTo("GBP 3.57"); + assertThat(test).hasToString("GBP 3.57"); } //----------------------------------------------------------------------- @@ -1823,19 +1823,19 @@ void test_multipliedBy_BigDecimalRoundingMode_one() { @Test void test_multipliedBy_BigDecimalRoundingMode_positive() { Money test = GBP_2_33.multipliedBy(new BigDecimal("2.5"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 5.82"); + assertThat(test).hasToString("GBP 5.82"); } @Test void test_multipliedBy_BigDecimalRoundingMode_positive_halfUp() { Money test = GBP_2_33.multipliedBy(new BigDecimal("2.5"), RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 5.83"); + assertThat(test).hasToString("GBP 5.83"); } @Test void test_multipliedBy_BigDecimalRoundingMode_negative() { Money test = GBP_2_33.multipliedBy(new BigDecimal("-2.5"), RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -5.83"); + assertThat(test).hasToString("GBP -5.83"); } @Test @@ -1862,19 +1862,19 @@ void test_multipliedBy_doubleRoundingMode_one() { @Test void test_multipliedBy_doubleRoundingMode_positive() { Money test = GBP_2_33.multipliedBy(2.5d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 5.82"); + assertThat(test).hasToString("GBP 5.82"); } @Test void test_multipliedBy_doubleRoundingMode_positive_halfUp() { Money test = GBP_2_33.multipliedBy(2.5d, RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 5.83"); + assertThat(test).hasToString("GBP 5.83"); } @Test void test_multipliedBy_doubleRoundingMode_negative() { Money test = GBP_2_33.multipliedBy(-2.5d, RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -5.83"); + assertThat(test).hasToString("GBP -5.83"); } @Test @@ -1895,13 +1895,13 @@ void test_multipliedBy_long_one() { @Test void test_multipliedBy_long_positive() { Money test = GBP_2_34.multipliedBy(3); - assertThat(test.toString()).isEqualTo("GBP 7.02"); + assertThat(test).hasToString("GBP 7.02"); } @Test void test_multipliedBy_long_negative() { Money test = GBP_2_34.multipliedBy(-3); - assertThat(test.toString()).isEqualTo("GBP -7.02"); + assertThat(test).hasToString("GBP -7.02"); } //----------------------------------------------------------------------- @@ -1916,19 +1916,19 @@ void test_dividedBy_BigDecimalRoundingMode_one() { @Test void test_dividedBy_BigDecimalRoundingMode_positive() { Money test = GBP_2_34.dividedBy(new BigDecimal("2.5"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.93"); + assertThat(test).hasToString("GBP 0.93"); } @Test void test_dividedBy_BigDecimalRoundingMode_positive_halfUp() { Money test = GBP_2_34.dividedBy(new BigDecimal("2.5"), RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 0.94"); + assertThat(test).hasToString("GBP 0.94"); } @Test void test_dividedBy_BigDecimalRoundingMode_negative() { Money test = GBP_2_34.dividedBy(new BigDecimal("-2.5"), RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -0.94"); + assertThat(test).hasToString("GBP -0.94"); } @Test @@ -1955,19 +1955,19 @@ void test_dividedBy_doubleRoundingMode_one() { @Test void test_dividedBy_doubleRoundingMode_positive() { Money test = GBP_2_34.dividedBy(2.5d, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.93"); + assertThat(test).hasToString("GBP 0.93"); } @Test void test_dividedBy_doubleRoundingMode_positive_halfUp() { Money test = GBP_2_34.dividedBy(2.5d, RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("GBP 0.94"); + assertThat(test).hasToString("GBP 0.94"); } @Test void test_dividedBy_doubleRoundingMode_negative() { Money test = GBP_2_34.dividedBy(-2.5d, RoundingMode.FLOOR); - assertThat(test.toString()).isEqualTo("GBP -0.94"); + assertThat(test).hasToString("GBP -0.94"); } @Test @@ -1988,25 +1988,25 @@ void test_dividedBy_long_one() { @Test void test_dividedBy_long_positive() { Money test = GBP_2_34.dividedBy(3, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.78"); + assertThat(test).hasToString("GBP 0.78"); } @Test void test_dividedBy_long_positive_roundDown() { Money test = GBP_2_35.dividedBy(3, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 0.78"); + assertThat(test).hasToString("GBP 0.78"); } @Test void test_dividedBy_long_positive_roundUp() { Money test = GBP_2_35.dividedBy(3, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 0.79"); + assertThat(test).hasToString("GBP 0.79"); } @Test void test_dividedBy_long_negative() { Money test = GBP_2_34.dividedBy(-3, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP -0.78"); + assertThat(test).hasToString("GBP -0.78"); } //----------------------------------------------------------------------- @@ -2015,13 +2015,13 @@ void test_dividedBy_long_negative() { @Test void test_negated_positive() { Money test = GBP_2_34.negated(); - assertThat(test.toString()).isEqualTo("GBP -2.34"); + assertThat(test).hasToString("GBP -2.34"); } @Test void test_negated_negative() { Money test = Money.parse("GBP -2.34").negated(); - assertThat(test.toString()).isEqualTo("GBP 2.34"); + assertThat(test).hasToString("GBP 2.34"); } //----------------------------------------------------------------------- @@ -2036,7 +2036,7 @@ void test_abs_positive() { @Test void test_abs_negative() { Money test = Money.parse("GBP -2.34").abs(); - assertThat(test.toString()).isEqualTo("GBP 2.34"); + assertThat(test).hasToString("GBP 2.34"); } //----------------------------------------------------------------------- @@ -2057,37 +2057,37 @@ void test_round_2up() { @Test void test_round_1down() { Money test = GBP_2_34.rounded(1, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 2.30"); + assertThat(test).hasToString("GBP 2.30"); } @Test void test_round_1up() { Money test = GBP_2_34.rounded(1, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 2.40"); + assertThat(test).hasToString("GBP 2.40"); } @Test void test_round_0down() { Money test = GBP_2_34.rounded(0, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 2.00"); + assertThat(test).hasToString("GBP 2.00"); } @Test void test_round_0up() { Money test = GBP_2_34.rounded(0, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 3.00"); + assertThat(test).hasToString("GBP 3.00"); } @Test void test_round_M1down() { Money test = Money.parse("GBP 432.34").rounded(-1, RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("GBP 430.00"); + assertThat(test).hasToString("GBP 430.00"); } @Test void test_round_M1up() { Money test = Money.parse("GBP 432.34").rounded(-1, RoundingMode.UP); - assertThat(test.toString()).isEqualTo("GBP 440.00"); + assertThat(test).hasToString("GBP 440.00"); } @Test @@ -2102,13 +2102,13 @@ void test_round_3() { @Test void test_convertedTo_BigDecimalRoundingMode_positive() { Money test = GBP_2_33.convertedTo(EUR, new BigDecimal("2.5"), RoundingMode.DOWN); - assertThat(test.toString()).isEqualTo("EUR 5.82"); + assertThat(test).hasToString("EUR 5.82"); } @Test void test_convertedTo_BigDecimalRoundingMode_positive_halfUp() { Money test = GBP_2_33.convertedTo(EUR, new BigDecimal("2.5"), RoundingMode.HALF_UP); - assertThat(test.toString()).isEqualTo("EUR 5.83"); + assertThat(test).hasToString("EUR 5.83"); } @Test @@ -2413,13 +2413,13 @@ void test_equals_false() { @Test void test_toString_positive() { Money test = Money.of(GBP, BIGDEC_2_34); - assertThat(test.toString()).isEqualTo("GBP 2.34"); + assertThat(test).hasToString("GBP 2.34"); } @Test void test_toString_negative() { Money test = Money.of(EUR, BIGDEC_M5_78); - assertThat(test.toString()).isEqualTo("EUR -5.78"); + assertThat(test).hasToString("EUR -5.78"); } } diff --git a/src/test/java/org/joda/money/format/TestMoneyAmountStyle.java b/src/test/java/org/joda/money/format/TestMoneyAmountStyle.java index 7f3d235..0615738 100644 --- a/src/test/java/org/joda/money/format/TestMoneyAmountStyle.java +++ b/src/test/java/org/joda/money/format/TestMoneyAmountStyle.java @@ -821,7 +821,7 @@ void test_equals_notEqual_absValue() { @Test void test_toString() { MoneyAmountStyle test = MoneyAmountStyle.LOCALIZED_GROUPING; - assertThat(test.toString().startsWith("MoneyAmountStyle")).isTrue(); + assertThat(test.toString()).startsWith("MoneyAmountStyle"); } } diff --git a/src/test/java/org/joda/money/format/TestMoneyFormatter.java b/src/test/java/org/joda/money/format/TestMoneyFormatter.java index 680fe8e..81cda0f 100644 --- a/src/test/java/org/joda/money/format/TestMoneyFormatter.java +++ b/src/test/java/org/joda/money/format/TestMoneyFormatter.java @@ -150,7 +150,7 @@ void test_print_BigMoneyProvider_nullBigMoneyProvider() { void test_print_AppendableBigMoneyProvider() { StringBuilder buf = new StringBuilder(); iPrintTest.print(buf, MONEY_GBP_12_34); - assertThat(buf.toString()).isEqualTo("GBP hello"); + assertThat(buf).hasToString("GBP hello"); } @Test @@ -186,7 +186,7 @@ void test_print_AppendableBigMoneyProvider_nullBigMoneyProvider() { void test_printIO_AppendableBigMoneyProvider() throws IOException { StringBuilder buf = new StringBuilder(); iPrintTest.printIO(buf, MONEY_GBP_12_34); - assertThat(buf.toString()).isEqualTo("GBP hello"); + assertThat(buf).hasToString("GBP hello"); } @Test @@ -359,7 +359,7 @@ void test_parse_CharSequenceInt( assertThat(test.getCurrency()).isEqualTo(currency); assertThat(test.getIndex()).isEqualTo(index); assertThat(test.getErrorIndex()).isEqualTo(errorIndex); - assertThat(test.getText().toString()).isEqualTo(str); + assertThat(test.getText()).hasToString(str); assertThat(test.getTextLength()).isEqualTo(str.length()); assertThat(test.isError()).isEqualTo(error); assertThat(test.isFullyParsed()).isEqualTo(fullyParsed); @@ -377,7 +377,7 @@ void test_parse_CharSequenceInt_incomplete() { assertThat(test.getCurrency()).isNull(); assertThat(test.getIndex()).isEqualTo(0); assertThat(test.getErrorIndex()).isEqualTo(-1); - assertThat(test.getText().toString()).isEqualTo("12.34 GBP"); + assertThat(test.getText()).hasToString("12.34 GBP"); assertThat(test.getTextLength()).isEqualTo(9); assertThat(test.isError()).isFalse(); assertThat(test.isFullyParsed()).isFalse(); @@ -393,7 +393,7 @@ void test_parse_CharSequenceInt_continueAfterDoubleDecimal() { assertThat(test.getCurrency()).isEqualTo(CurrencyUnit.of("GBP")); assertThat(test.getIndex()).isEqualTo(7); assertThat(test.getErrorIndex()).isEqualTo(-1); - assertThat(test.getText().toString()).isEqualTo("12..GBP"); + assertThat(test.getText()).hasToString("12..GBP"); assertThat(test.getTextLength()).isEqualTo(7); assertThat(test.isError()).isFalse(); assertThat(test.isFullyParsed()).isTrue(); @@ -409,7 +409,7 @@ void test_parse_CharSequenceInt_continueAfterSingleComma() { assertThat(test.getCurrency()).isEqualTo(CurrencyUnit.of("GBP")); assertThat(test.getIndex()).isEqualTo(6); assertThat(test.getErrorIndex()).isEqualTo(-1); - assertThat(test.getText().toString()).isEqualTo("12,GBP"); + assertThat(test.getText()).hasToString("12,GBP"); assertThat(test.getTextLength()).isEqualTo(6); assertThat(test.isError()).isFalse(); assertThat(test.isFullyParsed()).isTrue(); @@ -425,7 +425,7 @@ void test_parse_CharSequenceInt_continueAfterDoubleComma() { assertThat(test.getCurrency()).isEqualTo(CurrencyUnit.of("GBP")); assertThat(test.getIndex()).isEqualTo(7); assertThat(test.getErrorIndex()).isEqualTo(-1); - assertThat(test.getText().toString()).isEqualTo("12,,GBP"); + assertThat(test.getText()).hasToString("12,,GBP"); assertThat(test.getTextLength()).isEqualTo(7); assertThat(test.isError()).isFalse(); assertThat(test.isFullyParsed()).isTrue(); @@ -527,7 +527,7 @@ public String toString() { } }; MoneyFormatter f = new MoneyFormatterBuilder().append(printer, parser).toFormatter(); - assertThat(f.toString()).isEqualTo("A:B"); + assertThat(f).hasToString("A:B"); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/joda/money/format/TestMoneyFormatterBuilder.java b/src/test/java/org/joda/money/format/TestMoneyFormatterBuilder.java index 78cdc35..a2ca64a 100644 --- a/src/test/java/org/joda/money/format/TestMoneyFormatterBuilder.java +++ b/src/test/java/org/joda/money/format/TestMoneyFormatterBuilder.java @@ -76,8 +76,8 @@ void afterMethod() { @Test void test_empty() { MoneyFormatter test = iBuilder.toFormatter(); - assertThat(test.print(GBP_2_34)).isEqualTo(""); - assertThat(test.toString()).isEqualTo(""); + assertThat(test.print(GBP_2_34)).isEmpty(); + assertThat(test).hasToString(""); } //----------------------------------------------------------------------- @@ -86,7 +86,7 @@ void test_appendCurrencyCode_print() { iBuilder.appendCurrencyCode(); MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.print(GBP_2_34)).isEqualTo("GBP"); - assertThat(test.toString()).isEqualTo("${code}"); + assertThat(test).hasToString("${code}"); } @Test @@ -131,7 +131,7 @@ void test_appendCurrencyNumeric3Code_print() { iBuilder.appendCurrencyNumeric3Code(); MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.print(GBP_2_34)).isEqualTo("826"); - assertThat(test.toString()).isEqualTo("${numeric3Code}"); + assertThat(test).hasToString("${numeric3Code}"); } @Test @@ -188,7 +188,7 @@ void test_appendCurrencyNumericCode_print() { iBuilder.appendCurrencyNumericCode(); MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.print(GBP_2_34)).isEqualTo("826"); - assertThat(test.toString()).isEqualTo("${numericCode}"); + assertThat(test).hasToString("${numericCode}"); } @Test @@ -281,7 +281,7 @@ void test_appendCurrencySymbolLocalized_print() { iBuilder.appendCurrencySymbolLocalized(); MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.print(GBP_2_34)).isEqualTo("\u00a3"); - assertThat(test.toString()).isEqualTo("${symbolLocalized}"); + assertThat(test).hasToString("${symbolLocalized}"); } @Test @@ -297,23 +297,23 @@ void test_appendLiteral_print() { iBuilder.appendLiteral("Hello"); MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.print(GBP_2_34)).isEqualTo("Hello"); - assertThat(test.toString()).isEqualTo("'Hello'"); + assertThat(test).hasToString("'Hello'"); } @Test void test_appendLiteral_print_empty() { iBuilder.appendLiteral(""); MoneyFormatter test = iBuilder.toFormatter(); - assertThat(test.print(GBP_2_34)).isEqualTo(""); - assertThat(test.toString()).isEqualTo(""); + assertThat(test.print(GBP_2_34)).isEmpty(); + assertThat(test).hasToString(""); } @Test void test_appendLiteral_print_null() { iBuilder.appendLiteral((CharSequence) null); MoneyFormatter test = iBuilder.toFormatter(); - assertThat(test.print(GBP_2_34)).isEqualTo(""); - assertThat(test.toString()).isEqualTo(""); + assertThat(test.print(GBP_2_34)).isEmpty(); + assertThat(test).hasToString(""); } @Test @@ -372,7 +372,7 @@ void test_appendAmount(BigMoneyProvider money, String expected) { iBuilder.appendAmount(); MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.print(money)).isEqualTo(expected); - assertThat(test.toString()).isEqualTo("${amount}"); + assertThat(test).hasToString("${amount}"); } @Test @@ -380,7 +380,7 @@ void test_appendAmount_GBP_1234_56789_France() { iBuilder.appendAmount(); MoneyFormatter test = iBuilder.toFormatter(Locale.FRANCE); assertThat(test.print(GBP_1234_56789)).isEqualTo("1,234.567,89"); - assertThat(test.toString()).isEqualTo("${amount}"); + assertThat(test).hasToString("${amount}"); } @Test @@ -388,7 +388,7 @@ void test_appendAmount_JPY_2345() { iBuilder.appendAmount(); MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.print(JPY_2345)).isEqualTo("2,345"); - assertThat(test.toString()).isEqualTo("${amount}"); + assertThat(test).hasToString("${amount}"); } @Test @@ -418,7 +418,7 @@ void test_appendAmountLocalized(BigMoneyProvider money, String expected) { iBuilder.appendAmountLocalized(); MoneyFormatter test = iBuilder.toFormatter(Locale.FRANCE); assertThat(test.print(money)).isEqualTo(expected); - assertThat(test.toString()).isEqualTo("${amount}"); + assertThat(test).hasToString("${amount}"); } @Test @@ -426,7 +426,7 @@ void test_appendAmountLocalized_GBP_1234_56789_US() { iBuilder.appendAmountLocalized(); MoneyFormatter test = iBuilder.toFormatter(Locale.US); assertThat(test.print(GBP_1234_56789)).isEqualTo("1,234.567,89"); - assertThat(test.toString()).isEqualTo("${amount}"); + assertThat(test).hasToString("${amount}"); } @Test @@ -434,7 +434,7 @@ void test_appendAmountLocalized_JPY_2345() { iBuilder.appendAmountLocalized(); MoneyFormatter test = iBuilder.toFormatter(Locale.FRANCE); assertThat(test.print(JPY_2345)).isEqualTo("2" + FR_GROUP + "345"); - assertThat(test.toString()).isEqualTo("${amount}"); + assertThat(test).hasToString("${amount}"); } //----------------------------------------------------------------------- @@ -699,7 +699,7 @@ void test_appendAmount_parseExtendedGroupingSize(BigMoneyProvider money, String .appendAmount(MoneyAmountStyle.ASCII_DECIMAL_POINT_GROUP3_COMMA.withExtendedGroupingSize(2)) .toFormatter(); assertThat(test.print(money)).isEqualTo(expected); - assertThat(test.toString()).isEqualTo("${amount}"); + assertThat(test).hasToString("${amount}"); } //----------------------------------------------------------------------- @@ -730,7 +730,7 @@ public void print(MoneyPrintContext context, Appendable appendable, BigMoney mon assertThat(test.isPrinter()).isTrue(); assertThat(test.isParser()).isFalse(); assertThat(test.print(JPY_2345)).isEqualTo("HELLO"); - assertThat(test.toString().startsWith("org.joda.money.format.TestMoneyFormatterBuilder$")).isTrue(); + assertThat(test.toString()).startsWith("org.joda.money.format.TestMoneyFormatterBuilder$"); } @Test @@ -748,7 +748,7 @@ public void parse(MoneyParseContext context) { assertThat(test.isPrinter()).isFalse(); assertThat(test.isParser()).isTrue(); assertThat(test.parseMoney("")).isEqualTo(JPY_2345); - assertThat(test.toString().startsWith("org.joda.money.format.TestMoneyFormatterBuilder$")).isTrue(); + assertThat(test.toString()).startsWith("org.joda.money.format.TestMoneyFormatterBuilder$"); } @Test @@ -757,7 +757,7 @@ void test_append_MoneyPrinter_nullMoneyPrinter_nullMoneyParser() { MoneyFormatter test = iBuilder.toFormatter(); assertThat(test.isPrinter()).isFalse(); assertThat(test.isParser()).isFalse(); - assertThat(test.toString()).isEqualTo(""); + assertThat(test).hasToString(""); } //----------------------------------------------------------------------- @@ -784,8 +784,8 @@ void test_appendSigned_PN() { .appendLiteral(")") .toFormatter(); MoneyFormatter f = new MoneyFormatterBuilder().appendSigned(pos, neg).toFormatter(); - assertThat(f.toString()) - .isEqualTo("PositiveZeroNegative(${code}' '${amount},${code}' '${amount},'('${code}' '${amount}')')"); + assertThat(f) + .hasToString("PositiveZeroNegative(${code}' '${amount},${code}' '${amount},'('${code}' '${amount}')')"); assertThat(f.print(GBP_234_56)).isEqualTo("GBP 234.56"); assertThat(f.print(Money.zero(GBP))).isEqualTo("GBP 0.00"); assertThat(f.print(GBP_MINUS_234_56)).isEqualTo("(GBP 234.56)"); diff --git a/src/test/java/org/joda/money/format/TestMoneyParseContext.java b/src/test/java/org/joda/money/format/TestMoneyParseContext.java index 0fafa14..0f2d271 100644 --- a/src/test/java/org/joda/money/format/TestMoneyParseContext.java +++ b/src/test/java/org/joda/money/format/TestMoneyParseContext.java @@ -37,7 +37,7 @@ void test_initialState() { assertThat(test.getCurrency()).isNull(); assertThat(test.getIndex()).isEqualTo(0); assertThat(test.getErrorIndex()).isEqualTo(-1); - assertThat(test.getText().toString()).isEqualTo("GBP 123"); + assertThat(test.getText()).hasToString("GBP 123"); assertThat(test.getTextLength()).isEqualTo(7); assertThat(test.isError()).isFalse(); assertThat(test.isFullyParsed()).isFalse();