diff options
author | Gary Gregory <ggregory@apache.org> | 2016-10-23 10:55:56 -0700 |
---|---|---|
committer | Gary Gregory <ggregory@apache.org> | 2016-10-23 10:55:56 -0700 |
commit | eb2b89efbe15ab0b70fd94f0ecd0aa03866fb4d2 (patch) | |
tree | 38e07f2997b0ee2d779dcbcb52198aa68a7cb738 /src/test/java/org/apache/commons/lang3/builder | |
parent | aadb9a31ed969fc72cc87d486ec02383faa5bd06 (diff) | |
download | apache-commons-lang-eb2b89efbe15ab0b70fd94f0ecd0aa03866fb4d2.tar.gz |
Add final modifier to local variables.
Diffstat (limited to 'src/test/java/org/apache/commons/lang3/builder')
4 files changed, 54 insertions, 54 deletions
diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java index aa53fd1b8..d04b70fbe 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java @@ -471,12 +471,12 @@ public class DiffBuilderTest { final Matcher<Integer> equalToOne = equalTo(1); // Constructor's arguments are not trivially equal, but not testing for that. - DiffBuilder explicitTestAndNotEqual1 = new DiffBuilder(1, 2, null, false); + final DiffBuilder explicitTestAndNotEqual1 = new DiffBuilder(1, 2, null, false); explicitTestAndNotEqual1.append("letter", "X", "Y"); assertThat(explicitTestAndNotEqual1.build().getNumberOfDiffs(), equalToOne); // Constructor's arguments are trivially equal, but not testing for that. - DiffBuilder explicitTestAndNotEqual2 = new DiffBuilder(1, 1, null, false); + final DiffBuilder explicitTestAndNotEqual2 = new DiffBuilder(1, 1, null, false); // This append(f, l, r) will not abort early. explicitTestAndNotEqual2.append("letter", "X", "Y"); assertThat(explicitTestAndNotEqual2.build().getNumberOfDiffs(), equalToOne); @@ -488,19 +488,19 @@ public class DiffBuilderTest { final Matcher<Integer> equalToOne = equalTo(1); // The option to test if trivially equal is enabled by default. - DiffBuilder implicitTestAndEqual = new DiffBuilder(1, 1, null); + final DiffBuilder implicitTestAndEqual = new DiffBuilder(1, 1, null); // This append(f, l, r) will abort without creating a Diff for letter. implicitTestAndEqual.append("letter", "X", "Y"); assertThat(implicitTestAndEqual.build().getNumberOfDiffs(), equalToZero); - DiffBuilder implicitTestAndNotEqual = new DiffBuilder(1, 2, null); + final DiffBuilder implicitTestAndNotEqual = new DiffBuilder(1, 2, null); // This append(f, l, r) will not abort early // because the constructor's arguments were not trivially equal. implicitTestAndNotEqual.append("letter", "X", "Y"); assertThat(implicitTestAndNotEqual.build().getNumberOfDiffs(), equalToOne); // This is explicitly enabling the trivially equal test. - DiffBuilder explicitTestAndEqual = new DiffBuilder(1, 1, null, true); + final DiffBuilder explicitTestAndEqual = new DiffBuilder(1, 1, null, true); explicitTestAndEqual.append("letter", "X", "Y"); assertThat(explicitTestAndEqual.build().getNumberOfDiffs(), equalToZero); } diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java index 8ce0a049d..b28b89c3f 100644 --- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java @@ -604,8 +604,8 @@ public class HashCodeBuilderTest { @Test public void testToHashCodeExclude() { - TestObjectHashCodeExclude one = new TestObjectHashCodeExclude(1, 2); - TestObjectHashCodeExclude2 two = new TestObjectHashCodeExclude2(1, 2); + final TestObjectHashCodeExclude one = new TestObjectHashCodeExclude(1, 2); + final TestObjectHashCodeExclude2 two = new TestObjectHashCodeExclude2(1, 2); assertEquals(17 * 37 + 2, HashCodeBuilder.reflectionHashCode(one)); assertEquals(17, HashCodeBuilder.reflectionHashCode(two)); } diff --git a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java index 404c9c561..682a6d26f 100644 --- a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java @@ -95,7 +95,7 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append('A').toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } assertEquals("{\"a\":\"A\"}", new ToStringBuilder(base).append("a", 'A') @@ -112,7 +112,7 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append(now).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } assertEquals("{\"now\":\"" + now.toString() +"\"}", new ToStringBuilder(base).append("now", now) @@ -130,13 +130,13 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append((Object) null).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append(i3).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } assertEquals("{\"a\":null}", @@ -150,13 +150,13 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append("a", i3, false).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } assertEquals( @@ -167,7 +167,7 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append("a", new HashMap<>(), false).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } assertEquals( @@ -178,7 +178,7 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append("a", (Object) new String[0], false).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } assertEquals( @@ -189,7 +189,7 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append("a", (Object) new int[]{1, 2, 3}, false).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } @@ -201,7 +201,7 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append("a", (Object) new String[]{"v", "x", "y", "z"}, false).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } @@ -256,7 +256,7 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append(3L).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } assertEquals("{\"a\":3}", new ToStringBuilder(base).append("a", 3L) @@ -273,26 +273,26 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append(array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append((Object) array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } array = null; try { new ToStringBuilder(base).append(array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append((Object) array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } } @@ -303,13 +303,13 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append(array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append((Object) array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } array = null; @@ -317,13 +317,13 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append(array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append((Object) array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } } @@ -334,13 +334,13 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append(array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append((Object) array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } array = null; @@ -348,13 +348,13 @@ public class JsonToStringStyleTest { try { new ToStringBuilder(base).append(array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } try { new ToStringBuilder(base).append((Object) array).toString(); fail("Should have generated UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } } diff --git a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java index 4b9ebeea1..51dfff40f 100644 --- a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java @@ -33,8 +33,8 @@ public class MultilineRecursiveToStringStyleTest { @Test public void simpleObject() { - Transaction tx = new Transaction("2014.10.15", 100); - String expected = getClassPrefix(tx) + "[" + BR + final Transaction tx = new Transaction("2014.10.15", 100); + final String expected = getClassPrefix(tx) + "[" + BR + " amount=100.0," + BR + " date=2014.10.15" + BR + "]"; @@ -43,10 +43,10 @@ public class MultilineRecursiveToStringStyleTest { @Test public void nestedElements() { - Customer customer = new Customer("Douglas Adams"); - Bank bank = new Bank("ASF Bank"); + final Customer customer = new Customer("Douglas Adams"); + final Bank bank = new Bank("ASF Bank"); customer.bank = bank; - String exp = getClassPrefix(customer) + "[" + BR + final String exp = getClassPrefix(customer) + "[" + BR + " name=Douglas Adams," + BR + " bank=" + getClassPrefix(bank) + "[" + BR + " name=ASF Bank" + BR @@ -58,12 +58,12 @@ public class MultilineRecursiveToStringStyleTest { @Test public void nestedAndArray() { - Account acc = new Account(); - Transaction tx1 = new Transaction("2014.10.14", 100); - Transaction tx2 = new Transaction("2014.10.15", 50); + final Account acc = new Account(); + final Transaction tx1 = new Transaction("2014.10.14", 100); + final Transaction tx2 = new Transaction("2014.10.15", 50); acc.transactions.add(tx1); acc.transactions.add(tx2); - String expected = getClassPrefix(acc) + "[" + BR + final String expected = getClassPrefix(acc) + "[" + BR + " owner=<null>," + BR + " transactions=" + getClassPrefix(acc.transactions) + "{" + BR + " " + getClassPrefix(tx1) + "[" + BR @@ -81,8 +81,8 @@ public class MultilineRecursiveToStringStyleTest { @Test public void noArray() { - WithArrays wa = new WithArrays(); - String exp = getClassPrefix(wa) + "[" + BR + final WithArrays wa = new WithArrays(); + final String exp = getClassPrefix(wa) + "[" + BR + " boolArray=<null>," + BR + " charArray=<null>," + BR + " intArray=<null>," + BR @@ -95,9 +95,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void boolArray() { - WithArrays wa = new WithArrays(); + final WithArrays wa = new WithArrays(); wa.boolArray = new boolean[] { true, false, true }; - String exp = getClassPrefix(wa) + "[" + BR + final String exp = getClassPrefix(wa) + "[" + BR + " boolArray={" + BR + " true," + BR + " false," + BR @@ -114,9 +114,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void charArray() { - WithArrays wa = new WithArrays(); + final WithArrays wa = new WithArrays(); wa.charArray = new char[] { 'a', 'A' }; - String exp = getClassPrefix(wa) + "[" + BR + final String exp = getClassPrefix(wa) + "[" + BR + " boolArray=<null>," + BR + " charArray={" + BR + " a," + BR @@ -132,9 +132,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void intArray() { - WithArrays wa = new WithArrays(); + final WithArrays wa = new WithArrays(); wa.intArray = new int[] { 1, 2 }; - String exp = getClassPrefix(wa) + "[" + BR + final String exp = getClassPrefix(wa) + "[" + BR + " boolArray=<null>," + BR + " charArray=<null>," + BR + " intArray={" + BR @@ -150,9 +150,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void doubleArray() { - WithArrays wa = new WithArrays(); + final WithArrays wa = new WithArrays(); wa.doubleArray = new double[] { 1, 2 }; - String exp = getClassPrefix(wa) + "[" + BR + final String exp = getClassPrefix(wa) + "[" + BR + " boolArray=<null>," + BR + " charArray=<null>," + BR + " intArray=<null>," + BR @@ -168,9 +168,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void longArray() { - WithArrays wa = new WithArrays(); + final WithArrays wa = new WithArrays(); wa.longArray = new long[] { 1L, 2L }; - String exp = getClassPrefix(wa) + "[" + BR + final String exp = getClassPrefix(wa) + "[" + BR + " boolArray=<null>," + BR + " charArray=<null>," + BR + " intArray=<null>," + BR @@ -186,9 +186,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void stringArray() { - WithArrays wa = new WithArrays(); + final WithArrays wa = new WithArrays(); wa.stringArray = new String[] { "a", "A" }; - String exp = getClassPrefix(wa) + "[" + BR + final String exp = getClassPrefix(wa) + "[" + BR + " boolArray=<null>," + BR + " charArray=<null>," + BR + " intArray=<null>," + BR @@ -243,7 +243,7 @@ public class MultilineRecursiveToStringStyleTest { public double getBalance() { double balance = 0; - for (Transaction tx : transactions) { + for (final Transaction tx : transactions) { balance += tx.amount; } return balance; |