You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2013/11/13 19:54:06 UTC
svn commit: r1541658 [3/3] - in
/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor:
./ adapter/ aggregator/ core/ core/algorithm/ core/collection/
core/comparator/ core/composite/ example/ example/kata/four/
example/kata/one/ e...
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java Wed Nov 13 18:54:05 2013
@@ -140,7 +140,7 @@ public class QuicksortExample {
public void testSortSorted() {
List<Object> list = new ArrayList<Object>();
for (int i = 0; i < 10; i++) {
- list.add(new Integer(i));
+ list.add(Integer.valueOf(i));
}
List<?> sorted = quicksort(list);
@@ -167,11 +167,11 @@ public class QuicksortExample {
/*
* The "expected" list contains the integers in order.
*/
- expected.add(new Integer(i));
+ expected.add(Integer.valueOf(i));
/*
* The "tosort" list contains the integers in reverse order.
*/
- tosort.add(new Integer(9 - i));
+ tosort.add(Integer.valueOf(9 - i));
}
assertEquals(expected, quicksort(tosort));
@@ -184,7 +184,7 @@ public class QuicksortExample {
public void testSortShuffled() {
List<Object> expected = new ArrayList<Object>();
for (int i = 0; i < 10; i++) {
- expected.add(new Integer(i));
+ expected.add(Integer.valueOf(i));
}
List<Object> tosort = new ArrayList<Object>(expected);
Collections.shuffle(tosort);
@@ -203,7 +203,7 @@ public class QuicksortExample {
*/
List<Integer> tosort = new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
- tosort.add(new Integer(random.nextInt(10)));
+ tosort.add(Integer.valueOf(random.nextInt(10)));
}
/*
* and use java.util.Collections.sort to
@@ -248,7 +248,7 @@ public class QuicksortExample {
*/
List<Object> tosort = new ArrayList<Object>(SIZE);
for (int j = 0; j < SIZE; j++) {
- tosort.add(new Integer(random.nextInt(SIZE)));
+ tosort.add(Integer.valueOf(random.nextInt(SIZE)));
}
/*
@@ -535,14 +535,14 @@ public class QuicksortExample {
public void testLesserTail() {
List<Integer> list = new ArrayList<Integer>();
for (int i=0;i<10;i++) {
- list.add(new Integer(i));
+ list.add(Integer.valueOf(i));
}
for (int i=0;i<10;i++) {
- Integer val = new Integer(i);
+ Integer val = Integer.valueOf(i);
List<Integer> lesser = (List<Integer>) lesserTail.evaluate(val,list);
assertEquals(i,lesser.size());
for (int j=0;j<i;j++) {
- assertEquals(new Integer(j),lesser.get(j));
+ assertEquals(Integer.valueOf(j),lesser.get(j));
}
}
}
@@ -550,14 +550,14 @@ public class QuicksortExample {
public void testGreaterTail() {
List<Integer> list = new ArrayList<Integer>();
for (int i=0;i<10;i++) {
- list.add(new Integer(i));
+ list.add(Integer.valueOf(i));
}
for (int i=0;i<10;i++) {
- Integer val = new Integer(i);
+ Integer val = Integer.valueOf(i);
List<Integer> greater = (List<Integer>) greaterTail.evaluate(val,list);
assertEquals(10-i,greater.size());
for (int j=i;j<10;j++) {
- assertEquals(new Integer(j),greater.get(j-i));
+ assertEquals(Integer.valueOf(j),greater.get(j-i));
}
}
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java Wed Nov 13 18:54:05 2013
@@ -27,7 +27,7 @@ import org.apache.commons.functor.Functi
public final class Abs implements Function<Number, Integer> {
public Integer evaluate(Number num) {
- return new Integer(Math.abs(num.intValue()));
+ return Integer.valueOf(Math.abs(num.intValue()));
}
public static final Abs instance() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java Wed Nov 13 18:54:05 2013
@@ -19,19 +19,17 @@ package org.apache.commons.functor.examp
import org.apache.commons.functor.Function;
/**
- * Converts a String value to an Integer, throwing
- * an exception if no such conversion can be made.
- *
- * Trailing, non-{@link Character#isDigit digit} characters
- * are ignored.
- *
+ * Converts a String value to an Integer, throwing an exception if no such conversion can be made.
+ *
+ * Trailing, non-{@link Character#isDigit digit} characters are ignored.
+ *
* @version $Revision$ $Date$
*/
public final class ToInteger implements Function<String, Integer> {
public Integer evaluate(String str) {
- StringBuffer buf = new StringBuffer();
- for (int i=0;i<str.length();i++) {
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < str.length(); i++) {
if (Character.isDigit(str.charAt(i))) {
buf.append(str.charAt(i));
} else {
@@ -39,8 +37,8 @@ public final class ToInteger implements
}
}
try {
- return new Integer(buf.toString());
- } catch(NumberFormatException e) {
+ return Integer.valueOf(buf.toString());
+ } catch (NumberFormatException e) {
throw new NumberFormatException(str);
}
}
@@ -50,4 +48,4 @@ public final class ToInteger implements
}
private static final ToInteger INSTANCE = new ToInteger();
-}
\ No newline at end of file
+}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java Wed Nov 13 18:54:05 2013
@@ -24,7 +24,7 @@ import org.apache.commons.functor.adapte
*/
public class Add extends ArithmeticOperation {
public Number evaluate(Number left, Number right) {
- return new Integer(left.intValue() + right.intValue());
+ return Integer.valueOf(left.intValue() + right.intValue());
}
public static Add instance() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java Wed Nov 13 18:54:05 2013
@@ -25,7 +25,7 @@ import org.apache.commons.functor.adapte
public class Divide extends ArithmeticOperation {
public Number evaluate(Number left, Number right) {
- return new Integer(left.intValue() / right.intValue());
+ return Integer.valueOf(left.intValue() / right.intValue());
}
public static Divide instance() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java Wed Nov 13 18:54:05 2013
@@ -24,7 +24,7 @@ import org.apache.commons.functor.adapte
*/
public class Mod extends ArithmeticOperation {
public Number evaluate(Number left, Number right) {
- return new Integer(left.intValue() % right.intValue());
+ return Integer.valueOf(left.intValue() % right.intValue());
}
public static Mod instance() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java Wed Nov 13 18:54:05 2013
@@ -25,7 +25,7 @@ import org.apache.commons.functor.adapte
public class Multiply extends ArithmeticOperation {
public Number evaluate(Number left, Number right) {
- return new Integer(left.intValue() * right.intValue());
+ return Integer.valueOf(left.intValue() * right.intValue());
}
public static Multiply instance() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java Wed Nov 13 18:54:05 2013
@@ -24,7 +24,7 @@ import org.apache.commons.functor.adapte
*/
public class Subtract extends ArithmeticOperation {
public Number evaluate(Number left, Number right) {
- return new Integer(left.intValue() - right.intValue());
+ return Integer.valueOf(left.intValue() - right.intValue());
}
public static Subtract instance() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java Wed Nov 13 18:54:05 2013
@@ -28,276 +28,223 @@ import org.apache.commons.functor.core.c
import org.junit.Test;
/**
- * Dave Thomas's Kata One asks us to think about how one might
- * implement pricing rules:
- *
- * "Some things in supermarkets have simple prices: this can of
- * beans costs $0.65. Other things have more complex prices.
- * For example:
- *
+ * Dave Thomas's Kata One asks us to think about how one might implement pricing rules:
+ *
+ * "Some things in supermarkets have simple prices: this can of beans costs $0.65. Other things have more complex
+ * prices. For example:
+ *
* o three for a dollar (so what?s the price if I buy 4, or 5?)
- *
+ *
* o $1.99/pound (so what does 4 ounces cost?)
- *
+ *
* o buy two, get one free (so does the third item have a price?)"
- *
- * Functors provide one approach to this sort of problem, and in
- * this example we'll demonstrate some simple cases.
- *
- * See http://pragprog.com/pragdave/Practices/Kata/KataOne.rdoc,v
- * for more information on this Kata.
- *
+ *
+ * Functors provide one approach to this sort of problem, and in this example we'll demonstrate some simple cases.
+ *
+ * See http://pragprog.com/pragdave/Practices/Kata/KataOne.rdoc,v for more information on this Kata.
+ *
* @version $Revision$ $Date$
*/
public class SupermarketPricingExample {
// tests
- //----------------------------------------------------------
+ // ----------------------------------------------------------
/*
- * The simplest form of pricing is simply a constant
- * rate. In Dave's example, a can of beans costs $0.65,
- * and n cans of beans cost n*0.65.
- *
- * This pricing rule simply multiplies the quantity by
- * a constant, e.g.:
- * ToMoney.from(Multiply.by(65))
- *
- * This case is so common, we may want to introduce a
- * special Product constructor to wrap up create the
- * functors for us.
+ * The simplest form of pricing is simply a constant rate. In Dave's example, a can of beans costs $0.65, and n cans
+ * of beans cost n*0.65.
+ *
+ * This pricing rule simply multiplies the quantity by a constant, e.g.: ToMoney.from(Multiply.by(65))
+ *
+ * This case is so common, we may want to introduce a special Product constructor to wrap up create the functors for
+ * us.
*/
@Test
public void testConstantPricePerUnit() throws Exception {
{
- Product beans = new Product(
- "Can of Beans",
- "SKU-0001",
- ToMoney.from(Multiply.by(65)));
-
- assertEquals(new Money(0*65),beans.getPrice(0));
- assertEquals(new Money(1*65),beans.getPrice(1));
- assertEquals(new Money(2*65),beans.getPrice(2));
- assertEquals(new Money(3*65),beans.getPrice(3));
+ Product beans = new Product("Can of Beans", "SKU-0001", ToMoney.from(Multiply.by(65)));
+
+ assertEquals(new Money(0 * 65), beans.getPrice(0));
+ assertEquals(new Money(1 * 65), beans.getPrice(1));
+ assertEquals(new Money(2 * 65), beans.getPrice(2));
+ assertEquals(new Money(3 * 65), beans.getPrice(3));
}
// or, using the speical constructor:
{
- Product beans = new Product(
- "Can of Beans",
- "SKU-0001",
- 65);
-
- assertEquals(new Money(0*65),beans.getPrice(0));
- assertEquals(new Money(1*65),beans.getPrice(1));
- assertEquals(new Money(2*65),beans.getPrice(2));
- assertEquals(new Money(3*65),beans.getPrice(3));
+ Product beans = new Product("Can of Beans", "SKU-0001", 65);
+
+ assertEquals(new Money(0 * 65), beans.getPrice(0));
+ assertEquals(new Money(1 * 65), beans.getPrice(1));
+ assertEquals(new Money(2 * 65), beans.getPrice(2));
+ assertEquals(new Money(3 * 65), beans.getPrice(3));
}
}
/*
- * A slighly more complicated example is a bulk
- * discount. For example, bananas may be
- * $0.33 cents each, or 4 for a dollar ($1.00).
- *
- * This rule is underspecified by itself, there are
- * at least two ways to interpret this pricing rule:
- *
- * a) the cost is $0.33 cents for 3 or fewer, $0.25
- * for 4 or more
- *
+ * A slighly more complicated example is a bulk discount. For example, bananas may be $0.33 cents each, or 4 for a
+ * dollar ($1.00).
+ *
+ * This rule is underspecified by itself, there are at least two ways to interpret this pricing rule:
+ *
+ * a) the cost is $0.33 cents for 3 or fewer, $0.25 for 4 or more
+ *
* or
- *
- * b) the cost is $1.00 for every group of 4, $0.33
- * each for anything left over
- *
- * although I think in practice, "4 for a dollar"
- * usually means the former and not the latter.
- *
+ *
+ * b) the cost is $1.00 for every group of 4, $0.33 each for anything left over
+ *
+ * although I think in practice, "4 for a dollar" usually means the former and not the latter.
+ *
* We can implement either:
*/
@Test
public void testFourForADollar_A() throws Exception {
- Product banana = new Product(
- "Banana",
- "SKU-0002",
- ToMoney.from(
- new ConditionalFunction<Integer, Number>(
- IsGreaterThan.instance(new Integer(3)),
- Multiply.by(25),
- Multiply.by(33))));
-
- assertEquals(new Money(0*33),banana.getPrice(0));
- assertEquals(new Money(1*33),banana.getPrice(1));
- assertEquals(new Money(2*33),banana.getPrice(2));
- assertEquals(new Money(3*33),banana.getPrice(3));
- assertEquals(new Money(4*25),banana.getPrice(4));
- assertEquals(new Money(5*25),banana.getPrice(5));
- assertEquals(new Money(6*25),banana.getPrice(6));
- assertEquals(new Money(7*25),banana.getPrice(7));
- assertEquals(new Money(8*25),banana.getPrice(8));
+ Product banana =
+ new Product("Banana", "SKU-0002", ToMoney.from(new ConditionalFunction<Integer, Number>(IsGreaterThan
+ .instance(Integer.valueOf(3)), Multiply.by(25), Multiply.by(33))));
+
+ assertEquals(new Money(0 * 33), banana.getPrice(0));
+ assertEquals(new Money(1 * 33), banana.getPrice(1));
+ assertEquals(new Money(2 * 33), banana.getPrice(2));
+ assertEquals(new Money(3 * 33), banana.getPrice(3));
+ assertEquals(new Money(4 * 25), banana.getPrice(4));
+ assertEquals(new Money(5 * 25), banana.getPrice(5));
+ assertEquals(new Money(6 * 25), banana.getPrice(6));
+ assertEquals(new Money(7 * 25), banana.getPrice(7));
+ assertEquals(new Money(8 * 25), banana.getPrice(8));
}
-
@Test
public void testFourForADollar_B() throws Exception {
- Product banana = new Product(
- "Banana",
- "SKU-0002",
- ToMoney.from(
- new BinaryFunctionFunction<Integer, Number>(
- new CompositeBinaryFunction<Integer, Integer, Number>(
- Add.instance(),
- Composite.function(
- Multiply.by(100),
- Divide.by(4)),
- Composite.function(
- Multiply.by(33),
- Mod.by(4))))));
- assertEquals(new Money(0*33+0*25),banana.getPrice(0));
- assertEquals(new Money(1*33+0*25),banana.getPrice(1));
- assertEquals(new Money(2*33+0*25),banana.getPrice(2));
- assertEquals(new Money(3*33+0*25),banana.getPrice(3));
- assertEquals(new Money(0*33+4*25),banana.getPrice(4));
- assertEquals(new Money(1*33+4*25),banana.getPrice(5));
- assertEquals(new Money(2*33+4*25),banana.getPrice(6));
- assertEquals(new Money(3*33+4*25),banana.getPrice(7));
- assertEquals(new Money(0*33+8*25),banana.getPrice(8));
+ Product banana =
+ new Product("Banana", "SKU-0002", ToMoney.from(new BinaryFunctionFunction<Integer, Number>(
+ new CompositeBinaryFunction<Integer, Integer, Number>(Add.instance(), Composite.function(
+ Multiply.by(100), Divide.by(4)), Composite.function(Multiply.by(33), Mod.by(4))))));
+ assertEquals(new Money(0 * 33 + 0 * 25), banana.getPrice(0));
+ assertEquals(new Money(1 * 33 + 0 * 25), banana.getPrice(1));
+ assertEquals(new Money(2 * 33 + 0 * 25), banana.getPrice(2));
+ assertEquals(new Money(3 * 33 + 0 * 25), banana.getPrice(3));
+ assertEquals(new Money(0 * 33 + 4 * 25), banana.getPrice(4));
+ assertEquals(new Money(1 * 33 + 4 * 25), banana.getPrice(5));
+ assertEquals(new Money(2 * 33 + 4 * 25), banana.getPrice(6));
+ assertEquals(new Money(3 * 33 + 4 * 25), banana.getPrice(7));
+ assertEquals(new Money(0 * 33 + 8 * 25), banana.getPrice(8));
}
-
/*
- * Another interesting pricing rule is
- * something like "buy 2, get 1 free".
- *
- * This may be implemented using a formula
- * like:
- * costPerUnit * (quantity - quantity / 2)
- *
+ * Another interesting pricing rule is something like "buy 2, get 1 free".
+ *
+ * This may be implemented using a formula like: costPerUnit * (quantity - quantity / 2)
+ *
* For example...
*/
@Test
public void testBuyTwoGetOneFree_1() throws Exception {
- Product apple = new Product(
- "Apple",
- "SKU-0003",
- ToMoney.from(
- Composite.function(Multiply.by(40),
- BinaryFunctionFunction.adapt(new CompositeBinaryFunction<Number, Number, Number>(Subtract.instance(),
- new Identity<Number>(),
- Divide.by(3))))));
-
- assertEquals(new Money(0*40),apple.getPrice(0));
- assertEquals(new Money(1*40),apple.getPrice(1));
- assertEquals(new Money(2*40),apple.getPrice(2));
- assertEquals(new Money(2*40),apple.getPrice(3));
- assertEquals(new Money(3*40),apple.getPrice(4));
- assertEquals(new Money(4*40),apple.getPrice(5));
- assertEquals(new Money(4*40),apple.getPrice(6));
- assertEquals(new Money(5*40),apple.getPrice(7));
- assertEquals(new Money(6*40),apple.getPrice(8));
- assertEquals(new Money(6*40),apple.getPrice(9));
- assertEquals(new Money(7*40),apple.getPrice(10));
+ Product apple =
+ new Product("Apple", "SKU-0003", ToMoney.from(Composite.function(Multiply.by(40), BinaryFunctionFunction
+ .adapt(new CompositeBinaryFunction<Number, Number, Number>(Subtract.instance(), new Identity<Number>(),
+ Divide.by(3))))));
+
+ assertEquals(new Money(0 * 40), apple.getPrice(0));
+ assertEquals(new Money(1 * 40), apple.getPrice(1));
+ assertEquals(new Money(2 * 40), apple.getPrice(2));
+ assertEquals(new Money(2 * 40), apple.getPrice(3));
+ assertEquals(new Money(3 * 40), apple.getPrice(4));
+ assertEquals(new Money(4 * 40), apple.getPrice(5));
+ assertEquals(new Money(4 * 40), apple.getPrice(6));
+ assertEquals(new Money(5 * 40), apple.getPrice(7));
+ assertEquals(new Money(6 * 40), apple.getPrice(8));
+ assertEquals(new Money(6 * 40), apple.getPrice(9));
+ assertEquals(new Money(7 * 40), apple.getPrice(10));
}
/*
- * ...but our pricing rule is starting to get ugly,
- * and we haven't even considered things
- * something like "buy 3, get 2 free", etc.
- *
- * Perhaps a special Function instance is in
- * order:
+ * ...but our pricing rule is starting to get ugly, and we haven't even considered things something like
+ * "buy 3, get 2 free", etc.
+ *
+ * Perhaps a special Function instance is in order:
*/
class BuyNGetMFree implements Function<Number, Number> {
- public BuyNGetMFree(int n, int m, int costPerUnit) {
- this.n = n;
- this.m = m;
- this.costPerUnit = costPerUnit;
- }
-
- public Number evaluate(Number num) {
- int quantity = num.intValue();
- int cost = 0;
-
- while(quantity >= n) {
- // buy n
- cost += n * costPerUnit;
- quantity -= n;
- // get m (or fewer) free
- quantity -= Math.min(quantity,m);
- }
- // buy less than n
- cost += quantity * costPerUnit;
+ public BuyNGetMFree(int n, int m, int costPerUnit) {
+ this.n = n;
+ this.m = m;
+ this.costPerUnit = costPerUnit;
+ }
+
+ public Number evaluate(Number num) {
+ int quantity = num.intValue();
+ int cost = 0;
+
+ while (quantity >= n) {
+ // buy n
+ cost += n * costPerUnit;
+ quantity -= n;
+ // get m (or fewer) free
+ quantity -= Math.min(quantity, m);
+ }
+ // buy less than n
+ cost += quantity * costPerUnit;
- return new Integer(cost);
- }
+ return Integer.valueOf(cost);
+ }
- private int n, m, costPerUnit;
- }
+ private int n, m, costPerUnit;
+ }
@Test
public void testBuyTwoGetOneFree_2() throws Exception {
- Product apple = new Product(
- "Apple",
- "SKU-0003",
- ToMoney.from(new BuyNGetMFree(2,1,40)));
-
- assertEquals(new Money(0*40),apple.getPrice(0));
- assertEquals(new Money(1*40),apple.getPrice(1));
- assertEquals(new Money(2*40),apple.getPrice(2));
- assertEquals(new Money(2*40),apple.getPrice(3));
- assertEquals(new Money(3*40),apple.getPrice(4));
- assertEquals(new Money(4*40),apple.getPrice(5));
- assertEquals(new Money(4*40),apple.getPrice(6));
- assertEquals(new Money(5*40),apple.getPrice(7));
- assertEquals(new Money(6*40),apple.getPrice(8));
- assertEquals(new Money(6*40),apple.getPrice(9));
- assertEquals(new Money(7*40),apple.getPrice(10));
+ Product apple = new Product("Apple", "SKU-0003", ToMoney.from(new BuyNGetMFree(2, 1, 40)));
+
+ assertEquals(new Money(0 * 40), apple.getPrice(0));
+ assertEquals(new Money(1 * 40), apple.getPrice(1));
+ assertEquals(new Money(2 * 40), apple.getPrice(2));
+ assertEquals(new Money(2 * 40), apple.getPrice(3));
+ assertEquals(new Money(3 * 40), apple.getPrice(4));
+ assertEquals(new Money(4 * 40), apple.getPrice(5));
+ assertEquals(new Money(4 * 40), apple.getPrice(6));
+ assertEquals(new Money(5 * 40), apple.getPrice(7));
+ assertEquals(new Money(6 * 40), apple.getPrice(8));
+ assertEquals(new Money(6 * 40), apple.getPrice(9));
+ assertEquals(new Money(7 * 40), apple.getPrice(10));
}
@Test
public void testBuyThreeGetTwoFree() throws Exception {
- Product apple = new Product(
- "Apple",
- "SKU-0003",
- ToMoney.from(new BuyNGetMFree(3,2,40)));
-
- assertEquals(new Money(0*40),apple.getPrice(0));
- assertEquals(new Money(1*40),apple.getPrice(1));
- assertEquals(new Money(2*40),apple.getPrice(2));
- assertEquals(new Money(3*40),apple.getPrice(3));
- assertEquals(new Money(3*40),apple.getPrice(4));
- assertEquals(new Money(3*40),apple.getPrice(5));
- assertEquals(new Money(4*40),apple.getPrice(6));
- assertEquals(new Money(5*40),apple.getPrice(7));
- assertEquals(new Money(6*40),apple.getPrice(8));
- assertEquals(new Money(6*40),apple.getPrice(9));
- assertEquals(new Money(6*40),apple.getPrice(10));
- assertEquals(new Money(7*40),apple.getPrice(11));
+ Product apple = new Product("Apple", "SKU-0003", ToMoney.from(new BuyNGetMFree(3, 2, 40)));
+
+ assertEquals(new Money(0 * 40), apple.getPrice(0));
+ assertEquals(new Money(1 * 40), apple.getPrice(1));
+ assertEquals(new Money(2 * 40), apple.getPrice(2));
+ assertEquals(new Money(3 * 40), apple.getPrice(3));
+ assertEquals(new Money(3 * 40), apple.getPrice(4));
+ assertEquals(new Money(3 * 40), apple.getPrice(5));
+ assertEquals(new Money(4 * 40), apple.getPrice(6));
+ assertEquals(new Money(5 * 40), apple.getPrice(7));
+ assertEquals(new Money(6 * 40), apple.getPrice(8));
+ assertEquals(new Money(6 * 40), apple.getPrice(9));
+ assertEquals(new Money(6 * 40), apple.getPrice(10));
+ assertEquals(new Money(7 * 40), apple.getPrice(11));
}
@Test
public void testBuyTwoGetFiveFree() throws Exception {
- Product apple = new Product(
- "Apple",
- "SKU-0003",
- ToMoney.from(new BuyNGetMFree(2,5,40)));
-
- assertEquals(new Money(0*40),apple.getPrice(0));
- assertEquals(new Money(1*40),apple.getPrice(1));
- assertEquals(new Money(2*40),apple.getPrice(2));
- assertEquals(new Money(2*40),apple.getPrice(3));
- assertEquals(new Money(2*40),apple.getPrice(4));
- assertEquals(new Money(2*40),apple.getPrice(5));
- assertEquals(new Money(2*40),apple.getPrice(6));
- assertEquals(new Money(2*40),apple.getPrice(7));
- assertEquals(new Money(3*40),apple.getPrice(8));
- assertEquals(new Money(4*40),apple.getPrice(9));
- assertEquals(new Money(4*40),apple.getPrice(10));
- assertEquals(new Money(4*40),apple.getPrice(11));
- assertEquals(new Money(4*40),apple.getPrice(12));
- assertEquals(new Money(4*40),apple.getPrice(13));
- assertEquals(new Money(4*40),apple.getPrice(14));
- assertEquals(new Money(5*40),apple.getPrice(15));
- }
+ Product apple = new Product("Apple", "SKU-0003", ToMoney.from(new BuyNGetMFree(2, 5, 40)));
+
+ assertEquals(new Money(0 * 40), apple.getPrice(0));
+ assertEquals(new Money(1 * 40), apple.getPrice(1));
+ assertEquals(new Money(2 * 40), apple.getPrice(2));
+ assertEquals(new Money(2 * 40), apple.getPrice(3));
+ assertEquals(new Money(2 * 40), apple.getPrice(4));
+ assertEquals(new Money(2 * 40), apple.getPrice(5));
+ assertEquals(new Money(2 * 40), apple.getPrice(6));
+ assertEquals(new Money(2 * 40), apple.getPrice(7));
+ assertEquals(new Money(3 * 40), apple.getPrice(8));
+ assertEquals(new Money(4 * 40), apple.getPrice(9));
+ assertEquals(new Money(4 * 40), apple.getPrice(10));
+ assertEquals(new Money(4 * 40), apple.getPrice(11));
+ assertEquals(new Money(4 * 40), apple.getPrice(12));
+ assertEquals(new Money(4 * 40), apple.getPrice(13));
+ assertEquals(new Money(4 * 40), apple.getPrice(14));
+ assertEquals(new Money(5 * 40), apple.getPrice(15));
+ }
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/BaseBinaryChop.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/BaseBinaryChop.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/BaseBinaryChop.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/BaseBinaryChop.java Wed Nov 13 18:54:05 2013
@@ -20,18 +20,17 @@ import java.util.Arrays;
import java.util.List;
/**
- * See http://pragprog.com/pragdave/Practices/Kata/KataTwo.rdoc,v
- * for more information on this Kata.
- *
+ * See http://pragprog.com/pragdave/Practices/Kata/KataTwo.rdoc,v for more information on this Kata.
+ *
* @version $Revision$ $Date$
*/
public abstract class BaseBinaryChop implements BinaryChop {
public int find(int seeking, int[] in) {
Integer[] In = new Integer[in.length];
- for (int i=0;i<in.length;i++) {
- In[i] = new Integer(in[i]);
+ for (int i = 0; i < in.length; i++) {
+ In[i] = Integer.valueOf(in[i]);
}
- return find(new Integer(seeking), In);
+ return find(Integer.valueOf(seeking), In);
}
public int find(Integer seeking, Integer[] in) {
@@ -43,13 +42,13 @@ public abstract class BaseBinaryChop imp
}
protected static boolean greaterThan(List<Integer> list, int index, Integer obj) {
- return compare(list,index,obj) > 0;
+ return compare(list, index, obj) > 0;
}
protected static boolean equals(List<Integer> list, int index, Integer obj) {
- return compare(list,index,obj) == 0;
+ return compare(list, index, obj) == 0;
}
- protected static final Integer NEGATIVE_ONE = new Integer(-1);
+ protected static final Integer NEGATIVE_ONE = Integer.valueOf(-1);
-}
\ No newline at end of file
+}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java Wed Nov 13 18:54:05 2013
@@ -107,10 +107,10 @@ public class TestBinaryChop {
final List<Integer> largeList =
IteratorToGeneratorAdapter.adapt(new IntegerRange(0, 100001)).to(new ArrayList<Integer>());
- assertEquals(-1, chopper.find(new Integer(-5), largeList));
- assertEquals(100000, chopper.find(new Integer(100000), largeList));
- assertEquals(0, chopper.find(new Integer(0), largeList));
- assertEquals(50000, chopper.find(new Integer(50000), largeList));
+ assertEquals(-1, chopper.find(Integer.valueOf(-5), largeList));
+ assertEquals(100000, chopper.find(Integer.valueOf(100000), largeList));
+ assertEquals(0, chopper.find(Integer.valueOf(0), largeList));
+ assertEquals(50000, chopper.find(Integer.valueOf(50000), largeList));
}
@@ -303,7 +303,7 @@ public class TestBinaryChop {
* at the end of the loop.
*/
public Object evaluate() {
- return new Integer(
+ return Integer.valueOf(
list.isEmpty() ?
-1 :
(BaseBinaryChop.equals(list,low,seeking) ? low : -1));
@@ -360,7 +360,7 @@ public class TestBinaryChop {
variant(new NullaryFunction<Object>() {
public Object evaluate() {
- return new Integer(high - low);
+ return Integer.valueOf(high - low);
}
});
@@ -459,7 +459,7 @@ public class TestBinaryChop {
return list.isEmpty() ?
BaseBinaryChop.NEGATIVE_ONE :
(BaseBinaryChop.equals(list,low,seeking) ?
- new Integer(low) :
+ Integer.valueOf(low) :
BaseBinaryChop.NEGATIVE_ONE);
}
}
@@ -527,7 +527,7 @@ public class TestBinaryChop {
return BaseBinaryChop.NEGATIVE_ONE;
} if (sublist.size() == 1) {
return (BaseBinaryChop.equals(sublist,0,seeking) ?
- new Integer(offset) :
+ Integer.valueOf(offset) :
BaseBinaryChop.NEGATIVE_ONE);
} else {
int mid = sublist.size() / 2;
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java Wed Nov 13 18:54:05 2013
@@ -64,14 +64,14 @@ public class TestLines extends TestCase
Object result = new FoldLeft<Integer>(Sum.instance()).evaluate(
new TransformedGenerator<String, Integer>(Lines.from(reader), new Size<String>()));
- assertEquals("Expected 990 characters",new Integer(990),result);
+ assertEquals("Expected 990 characters",Integer.valueOf(990),result);
}
public void testCountWords() throws Exception {
Object result = new FoldLeft<Integer>(Sum.instance()).evaluate(
new TransformedGenerator<String, Integer>(Lines.from(reader),WordCount.instance()));
- assertEquals("Expected 157 words",new Integer(157),result);
+ assertEquals("Expected 157 words",Integer.valueOf(157),result);
}
public void testCountLines() throws Exception {
@@ -88,7 +88,7 @@ public class TestLines extends TestCase
new FilteredGenerator<String>(Lines.from(reader), Not.not(new StartsWith<String>("#"))), WordCount
.instance()));
- assertEquals("Expected 90 words",new Integer(90),result);
+ assertEquals("Expected 90 words",Integer.valueOf(90),result);
}
public void testCountCommentLines() throws Exception {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestFixedSizeMap.java Wed Nov 13 18:54:05 2013
@@ -23,7 +23,6 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-
/**
* @version $Revision$ $Date$
*/
@@ -44,11 +43,11 @@ public class TestFixedSizeMap extends Te
public void setUp() throws Exception {
super.setUp();
baseMap = new HashMap<Object, Object>();
- baseMap.put(new Integer(1),"one");
- baseMap.put(new Integer(2),"two");
- baseMap.put(new Integer(3),"three");
- baseMap.put(new Integer(4),"four");
- baseMap.put(new Integer(5),"five");
+ baseMap.put(Integer.valueOf(1), "one");
+ baseMap.put(Integer.valueOf(2), "two");
+ baseMap.put(Integer.valueOf(3), "three");
+ baseMap.put(Integer.valueOf(4), "four");
+ baseMap.put(Integer.valueOf(5), "five");
fixedMap = new FixedSizeMap<Object, Object>(baseMap);
}
@@ -64,66 +63,65 @@ public class TestFixedSizeMap extends Te
public void testCantPutNewPair() {
try {
- fixedMap.put("xyzzy","xyzzy");
+ fixedMap.put("xyzzy", "xyzzy");
fail("Expected IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// expected
}
}
public void testCantPutNewPairViaPutAll() {
Map<Object, Object> map = new HashMap<Object, Object>();
- map.put(new Integer(1),"uno");
- map.put("xyzzy","xyzzy");
- map.put(new Integer(2),"dos");
+ map.put(Integer.valueOf(1), "uno");
+ map.put("xyzzy", "xyzzy");
+ map.put(Integer.valueOf(2), "dos");
try {
fixedMap.putAll(map);
fail("Expected IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// expected
}
- assertEquals("one",fixedMap.get(new Integer(1)));
- assertEquals("two",fixedMap.get(new Integer(2)));
+ assertEquals("one", fixedMap.get(Integer.valueOf(1)));
+ assertEquals("two", fixedMap.get(Integer.valueOf(2)));
}
public void testCantClear() {
try {
fixedMap.clear();
fail("Expected UnsupportedOperationException");
- } catch(UnsupportedOperationException e) {
+ } catch (UnsupportedOperationException e) {
// expected
}
}
public void testCantRemove() {
try {
- fixedMap.remove(new Integer(1));
+ fixedMap.remove(Integer.valueOf(1));
fail("Expected UnsupportedOperationException");
- } catch(UnsupportedOperationException e) {
+ } catch (UnsupportedOperationException e) {
// expected
}
}
public void testCanAssociateNewValueWithOldKey() {
- fixedMap.put(new Integer(1),"uno");
- assertEquals("uno",fixedMap.get(new Integer(1)));
- assertEquals("two",fixedMap.get(new Integer(2)));
- assertEquals("three",fixedMap.get(new Integer(3)));
+ fixedMap.put(Integer.valueOf(1), "uno");
+ assertEquals("uno", fixedMap.get(Integer.valueOf(1)));
+ assertEquals("two", fixedMap.get(Integer.valueOf(2)));
+ assertEquals("three", fixedMap.get(Integer.valueOf(3)));
}
public void testCanAssociateNewValueWithOldKeyViaPutAll() {
Map<Object, Object> map = new HashMap<Object, Object>();
- map.put(new Integer(1),"uno");
- map.put(new Integer(2),"dos");
+ map.put(Integer.valueOf(1), "uno");
+ map.put(Integer.valueOf(2), "dos");
fixedMap.putAll(map);
- assertEquals("uno",fixedMap.get(new Integer(1)));
- assertEquals("dos",fixedMap.get(new Integer(2)));
- assertEquals("three",fixedMap.get(new Integer(3)));
+ assertEquals("uno", fixedMap.get(Integer.valueOf(1)));
+ assertEquals("dos", fixedMap.get(Integer.valueOf(2)));
+ assertEquals("three", fixedMap.get(Integer.valueOf(3)));
}
-
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestLazyMap.java Wed Nov 13 18:54:05 2013
@@ -26,7 +26,6 @@ import junit.framework.TestSuite;
import org.apache.commons.functor.core.collection.Size;
-
/**
* @version $Revision$ $Date$
*/
@@ -48,14 +47,14 @@ public class TestLazyMap extends TestCas
public void setUp() throws Exception {
super.setUp();
expectedMap = new HashMap<Object, Integer>();
- expectedMap.put("one",new Integer(3));
- expectedMap.put("two",new Integer(3));
- expectedMap.put("three", new Integer(5));
- expectedMap.put("four", new Integer(4));
- expectedMap.put("five", new Integer(4));
+ expectedMap.put("one", Integer.valueOf(3));
+ expectedMap.put("two", Integer.valueOf(3));
+ expectedMap.put("three", Integer.valueOf(5));
+ expectedMap.put("four", Integer.valueOf(4));
+ expectedMap.put("five", Integer.valueOf(4));
baseMap = new HashMap<Object, Integer>();
- lazyMap = new LazyMap<Object, Integer>(baseMap,Size.instance());
+ lazyMap = new LazyMap<Object, Integer>(baseMap, Size.instance());
}
@Override
@@ -73,32 +72,31 @@ public class TestLazyMap extends TestCas
Object key = iter.next();
assertFalse(baseMap.containsKey(key));
assertFalse(lazyMap.containsKey(key));
- assertEquals(expectedMap.get(key),lazyMap.get(key));
- assertEquals(expectedMap.get(key),baseMap.get(key));
+ assertEquals(expectedMap.get(key), lazyMap.get(key));
+ assertEquals(expectedMap.get(key), baseMap.get(key));
assertTrue(lazyMap.containsKey(key));
assertTrue(baseMap.containsKey(key));
}
- assertEquals(expectedMap,lazyMap);
- assertEquals(expectedMap,baseMap);
+ assertEquals(expectedMap, lazyMap);
+ assertEquals(expectedMap, baseMap);
baseMap.clear();
for (Iterator<Object> iter = expectedMap.keySet().iterator(); iter.hasNext();) {
Object key = iter.next();
assertFalse(baseMap.containsKey(key));
assertFalse(lazyMap.containsKey(key));
- assertEquals(expectedMap.get(key),lazyMap.get(key));
- assertEquals(expectedMap.get(key),baseMap.get(key));
+ assertEquals(expectedMap.get(key), lazyMap.get(key));
+ assertEquals(expectedMap.get(key), baseMap.get(key));
assertTrue(lazyMap.containsKey(key));
assertTrue(baseMap.containsKey(key));
}
- assertEquals(expectedMap,lazyMap);
- assertEquals(expectedMap,baseMap);
+ assertEquals(expectedMap, lazyMap);
+ assertEquals(expectedMap, baseMap);
}
-
public void testBaseMapOverrides() {
- assertEquals(new Integer(5),lazyMap.get("xyzzy"));
- baseMap.put("xyzzy",new Integer(3));
- assertEquals(Integer.valueOf(3),lazyMap.get("xyzzy"));
+ assertEquals(Integer.valueOf(5), lazyMap.get("xyzzy"));
+ baseMap.put("xyzzy", Integer.valueOf(3));
+ assertEquals(Integer.valueOf(3), lazyMap.get("xyzzy"));
}
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java Wed Nov 13 18:54:05 2013
@@ -58,7 +58,7 @@ public class TestPredicatedMap extends T
// tests
public void testCanPutMatchingPair() {
- predicatedMap.put("xyzzy", new Integer(17));
+ predicatedMap.put("xyzzy", Integer.valueOf(17));
}
public void testCantPutInvalidValue() {
try {
@@ -71,7 +71,7 @@ public class TestPredicatedMap extends T
public void testCantPutInvalidKey() {
try {
- predicatedMap.put(new Long(1), new Integer(3));
+ predicatedMap.put(Long.valueOf(1), Integer.valueOf(3));
fail("Expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// expected
@@ -80,17 +80,13 @@ public class TestPredicatedMap extends T
public void testOnlyValidPairsAreAddedInPutAll() {
HashMap<Object, Object> map = new HashMap<Object, Object>();
- map.put("one", new Integer(17));
+ map.put("one", Integer.valueOf(17));
map.put("two", "rejected");
- map.put(new Integer(17), "xyzzy");
- map.put(new Integer(7), new Integer(3));
+ map.put(Integer.valueOf(17), "xyzzy");
+ map.put(Integer.valueOf(7), Integer.valueOf(3));
predicatedMap.putAll(map);
- assertEquals(new Integer(17), predicatedMap.get("one"));
+ assertEquals(Integer.valueOf(17), predicatedMap.get("one"));
assertFalse(predicatedMap.containsKey("two"));
-/*
- assertFalse(predicatedMap.containsKey(new Integer(17)));
- assertFalse(predicatedMap.containsKey(new Integer(7)));
-*/
}
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java Wed Nov 13 18:54:05 2013
@@ -45,8 +45,8 @@ public class TestBaseGenerator {
public void setUp() throws Exception {
simpleGenerator = new BaseGenerator<Integer>() {
public void run(Procedure<? super Integer> proc) {
- for (int i=0;i<5;i++) {
- proc.run(new Integer(i));
+ for (int i = 0; i < 5; i++) {
+ proc.run(Integer.valueOf(i));
}
}
};
@@ -56,14 +56,14 @@ public class TestBaseGenerator {
doubled = new ArrayList<Integer>();
listWithDuplicates = new ArrayList<Integer>();
sum = 0;
- for (int i=0;i<10;i++) {
- list.add(new Integer(i));
- doubled.add(new Integer(i*2));
- listWithDuplicates.add(new Integer(i));
- listWithDuplicates.add(new Integer(i));
+ for (int i = 0; i < 10; i++) {
+ list.add(Integer.valueOf(i));
+ doubled.add(Integer.valueOf(i * 2));
+ listWithDuplicates.add(Integer.valueOf(i));
+ listWithDuplicates.add(Integer.valueOf(i));
sum += i;
- if (i%2 == 0) {
- evens.add(new Integer(i));
+ if (i % 2 == 0) {
+ evens.add(Integer.valueOf(i));
}
}
}
@@ -82,7 +82,7 @@ public class TestBaseGenerator {
@Test
public void testSimpleGenerator() {
- final StringBuffer result = new StringBuffer();
+ final StringBuilder result = new StringBuilder();
simpleGenerator.run(new Procedure<Integer>() {
public void run(Integer obj) {
result.append(obj);
@@ -105,12 +105,12 @@ public class TestBaseGenerator {
assertSame(fillThis, col);
assertEquals("[0, 1, 2, 3, 4]", col.toString());
- col = (Collection<Integer>)simpleGenerator.toCollection();
+ col = (Collection<Integer>) simpleGenerator.toCollection();
assertEquals("[0, 1, 2, 3, 4]", col.toString());
assertEquals("[0, 1, 2, 3, 4]", col.toString());
fillThis = new LinkedList<Integer>();
- col = (Collection<Integer>)simpleGenerator.to(fillThis);
+ col = (Collection<Integer>) simpleGenerator.to(fillThis);
assertSame(fillThis, col);
assertEquals("[0, 1, 2, 3, 4]", col.toString());
}
@@ -123,18 +123,6 @@ public class TestBaseGenerator {
private List<Integer> listWithDuplicates = null;
@SuppressWarnings("unused")
private int sum = 0;
-// private Predicate equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
-// private Predicate equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
-// private Predicate isEven = new Predicate() {
-// public boolean test(Object obj) {
-// return ((Number) obj).intValue() % 2 == 0;
-// }
-// };
-// private Predicate isOdd = new Predicate() {
-// public boolean test(Object obj) {
-// return ((Number) obj).intValue() % 2 != 0;
-// }
-// };
// Classes
// ------------------------------------------------------------------------
@@ -143,6 +131,7 @@ public class TestBaseGenerator {
public void run(Number that) {
sum += (that).intValue();
}
+
public int sum = 0;
}
-}
\ No newline at end of file
+}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java Wed Nov 13 18:54:05 2013
@@ -95,7 +95,7 @@ public class TestGenerateUntil
// Attributes
// ------------------------------------------------------------------------
- private static final Integer FIVE = new Integer(5);
+ private static final Integer FIVE = Integer.valueOf(5);
private Generator<Integer> wrappedGenerator = null;
private Predicate<Integer> isMoreThanFive = new Predicate<Integer>() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java Wed Nov 13 18:54:05 2013
@@ -95,7 +95,7 @@ public class TestGenerateWhile
// Attributes
// ------------------------------------------------------------------------
- private static final Integer FIVE = new Integer(5);
+ private static final Integer FIVE = Integer.valueOf(5);
private Generator<Integer> wrappedGenerator = null;
private Predicate<Integer> isLessThanFive = new Predicate<Integer>()
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java Wed Nov 13 18:54:05 2013
@@ -45,8 +45,8 @@ public class TestLoopGenerator {
public void setUp() throws Exception {
simpleGenerator = new LoopGenerator<Integer>() {
public void run(Procedure<? super Integer> proc) {
- for (int i=0;i<5;i++) {
- proc.run(new Integer(i));
+ for (int i = 0; i < 5; i++) {
+ proc.run(Integer.valueOf(i));
if (isStopped()) {
break;
}
@@ -59,14 +59,14 @@ public class TestLoopGenerator {
doubled = new ArrayList<Integer>();
listWithDuplicates = new ArrayList<Integer>();
sum = 0;
- for (int i=0;i<10;i++) {
- list.add(new Integer(i));
- doubled.add(new Integer(i*2));
- listWithDuplicates.add(new Integer(i));
- listWithDuplicates.add(new Integer(i));
+ for (int i = 0; i < 10; i++) {
+ list.add(Integer.valueOf(i));
+ doubled.add(Integer.valueOf(i * 2));
+ listWithDuplicates.add(Integer.valueOf(i));
+ listWithDuplicates.add(Integer.valueOf(i));
sum += i;
- if (i%2 == 0) {
- evens.add(new Integer(i));
+ if (i % 2 == 0) {
+ evens.add(Integer.valueOf(i));
}
}
}
@@ -85,7 +85,7 @@ public class TestLoopGenerator {
@Test
public void testSimpleGenerator() {
- final StringBuffer result = new StringBuffer();
+ final StringBuilder result = new StringBuilder();
simpleGenerator.run(new Procedure<Integer>() {
public void run(Integer obj) {
result.append(obj);
@@ -97,9 +97,10 @@ public class TestLoopGenerator {
@Test
public void testStop() {
- final StringBuffer result = new StringBuffer();
+ final StringBuilder result = new StringBuilder();
simpleGenerator.run(new Procedure<Integer>() {
- int i=0;
+ int i = 0;
+
public void run(Integer obj) {
result.append(obj);
if (i++ > 1) {
@@ -113,14 +114,14 @@ public class TestLoopGenerator {
@Test
public void testWrappingGenerator() {
- final StringBuffer result = new StringBuffer();
+ final StringBuilder result = new StringBuilder();
final LoopGenerator<Integer> gen = new LoopGenerator<Integer>(simpleGenerator) {
public void run(final Procedure<? super Integer> proc) {
- LoopGenerator<Integer> wrapped = (LoopGenerator<Integer>)getWrappedGenerator();
+ LoopGenerator<Integer> wrapped = (LoopGenerator<Integer>) getWrappedGenerator();
assertSame(simpleGenerator, wrapped);
wrapped.run(new Procedure<Integer>() {
public void run(Integer obj) {
- proc.run(new Integer(obj.intValue() + 1));
+ proc.run(Integer.valueOf(obj.intValue() + 1));
}
});
}
@@ -135,9 +136,10 @@ public class TestLoopGenerator {
assertEquals("12345", result.toString());
// try to stop the wrapped generator
- final StringBuffer result2 = new StringBuffer();
+ final StringBuilder result2 = new StringBuilder();
gen.run(new Procedure<Integer>() {
- int i=0;
+ int i = 0;
+
public void run(Integer obj) {
result2.append(obj);
if (i++ > 1) {
@@ -162,12 +164,12 @@ public class TestLoopGenerator {
assertSame(fillThis, col);
assertEquals("[0, 1, 2, 3, 4]", col.toString());
- col = (Collection<Integer>)simpleGenerator.toCollection();
+ col = (Collection<Integer>) simpleGenerator.toCollection();
assertEquals("[0, 1, 2, 3, 4]", col.toString());
assertEquals("[0, 1, 2, 3, 4]", col.toString());
fillThis = new LinkedList<Integer>();
- col = (Collection<Integer>)simpleGenerator.to(fillThis);
+ col = (Collection<Integer>) simpleGenerator.to(fillThis);
assertSame(fillThis, col);
assertEquals("[0, 1, 2, 3, 4]", col.toString());
}
@@ -180,18 +182,6 @@ public class TestLoopGenerator {
private List<Integer> listWithDuplicates = null;
@SuppressWarnings("unused")
private int sum = 0;
-// private UnaryPredicate equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
-// private UnaryPredicate equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
-// private UnaryPredicate isEven = new UnaryPredicate() {
-// public boolean test(Object obj) {
-// return ((Number) obj).intValue() % 2 == 0;
-// }
-// };
-// private UnaryPredicate isOdd = new UnaryPredicate() {
-// public boolean test(Object obj) {
-// return ((Number) obj).intValue() % 2 != 0;
-// }
-// };
// Classes
// ------------------------------------------------------------------------
@@ -200,6 +190,7 @@ public class TestLoopGenerator {
public void run(Number that) {
sum += (that).intValue();
}
+
public int sum = 0;
}
-}
\ No newline at end of file
+}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java Wed Nov 13 18:54:05 2013
@@ -112,7 +112,7 @@ public class TestTransformedGenerator
// Attributes
// ------------------------------------------------------------------------
- private static final Integer TWO = new Integer(2);
+ private static final Integer TWO = Integer.valueOf(2);
private Generator<Integer> wrappedGenerator = null;
private Function<Integer, Integer> sumsTwo = new Function<Integer, Integer>() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java Wed Nov 13 18:54:05 2013
@@ -113,7 +113,7 @@ public class TestUntilGenerate
// Attributes
// ------------------------------------------------------------------------
- private static final Integer FIVE = new Integer(5);
+ private static final Integer FIVE = Integer.valueOf(5);
private Generator<Integer> wrappedGenerator = null;
private Predicate<Integer> isGreaterThanFive = new Predicate<Integer>() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java Wed Nov 13 18:54:05 2013
@@ -112,7 +112,7 @@ public class TestWhileGenerate {
// Attributes
// ------------------------------------------------------------------------
- private static final Integer FIVE = new Integer(5);
+ private static final Integer FIVE = Integer.valueOf(5);
private Generator<Integer> wrappedGenerator = null;
private Predicate<Integer> isLessThanFive = new Predicate<Integer>() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java Wed Nov 13 18:54:05 2013
@@ -55,11 +55,11 @@ public class TestEachElement extends Bas
@Before
public void setUp() throws Exception {
list = new ArrayList<Integer>();
- list.add(new Integer(0));
- list.add(new Integer(1));
- list.add(new Integer(2));
- list.add(new Integer(3));
- list.add(new Integer(4));
+ list.add(Integer.valueOf(0));
+ list.add(Integer.valueOf(1));
+ list.add(Integer.valueOf(2));
+ list.add(Integer.valueOf(3));
+ list.add(Integer.valueOf(4));
map = new HashMap<String, String>();
map.put("1", "1-1");
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestCharacterRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestCharacterRange.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestCharacterRange.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestCharacterRange.java Wed Nov 13 18:54:05 2013
@@ -117,11 +117,11 @@ public class TestCharacterRange extends
@Test
public void testObjectConstructor() {
- CharacterRange range = Ranges.characterRange(new Character('a'),
- new Character('e'));
+ CharacterRange range = Ranges.characterRange(Character.valueOf('a'),
+ Character.valueOf('e'));
assertEquals("[a, b, c, d, e]", IteratorToGeneratorAdapter.adapt(range).toCollection().toString());
- range = Ranges.characterRange(new Character('a'), new Character('e'),
- new Integer(1));
+ range = Ranges.characterRange(Character.valueOf('a'), Character.valueOf('e'),
+ Integer.valueOf(1));
assertEquals("[a, b, c, d, e]", IteratorToGeneratorAdapter.adapt(range).toCollection().toString());
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestDoubleRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestDoubleRange.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestDoubleRange.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestDoubleRange.java Wed Nov 13 18:54:05 2013
@@ -92,7 +92,7 @@ public class TestDoubleRange extends Bas
IteratorToGeneratorAdapter.adapt(Ranges.doubleRange(0, 10))
.to(new ArrayList<Double>()));
for (int i = 0; i < 10; i++) {
- assertEquals(new Double(i), list.get(i));
+ assertEquals(Double.valueOf(i), list.get(i));
}
}
@@ -103,7 +103,7 @@ public class TestDoubleRange extends Bas
IteratorToGeneratorAdapter.adapt(Ranges.doubleRange(10, 0))
.to(new ArrayList<Double>()));
for (int i = 10; i > 0; i--) {
- assertEquals(new Double(i), list.get(10 - i));
+ assertEquals(Double.valueOf(i), list.get(10 - i));
}
}
}
@@ -149,11 +149,11 @@ public class TestDoubleRange extends Bas
@Test
public void testObjectConstructor() {
- DoubleRange range = Ranges.doubleRange(new Double(0),
- new Double(5));
+ DoubleRange range = Ranges.doubleRange(Double.valueOf(0),
+ Double.valueOf(5));
assertEquals("[0.0, 1.0, 2.0, 3.0, 4.0]", IteratorToGeneratorAdapter.adapt(range).toCollection()
.toString());
- range = Ranges.doubleRange(new Double(0), new Double(5), new Double(1));
+ range = Ranges.doubleRange(Double.valueOf(0), Double.valueOf(5), Double.valueOf(1));
}
@Test
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestFloatRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestFloatRange.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestFloatRange.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestFloatRange.java Wed Nov 13 18:54:05 2013
@@ -91,7 +91,7 @@ public class TestFloatRange extends Base
IteratorToGeneratorAdapter.adapt(Ranges.floatRange(0, 10))
.to(new ArrayList<Float>()));
for (int i = 0; i < 10; i++) {
- assertEquals(new Float(i), list.get(i));
+ assertEquals(Float.valueOf(i), list.get(i));
}
}
@@ -101,7 +101,7 @@ public class TestFloatRange extends Base
IteratorToGeneratorAdapter.adapt(Ranges.floatRange(10, 0))
.to(new ArrayList<Float>()));
for (int i = 10; i > 0; i--) {
- assertEquals(new Float(i), list.get(10 - i));
+ assertEquals(Float.valueOf(i), list.get(10 - i));
}
}
}
@@ -147,10 +147,10 @@ public class TestFloatRange extends Base
@Test
public void testObjectConstructor() {
- FloatRange range = Ranges.floatRange(new Float(0), new Float(5));
+ FloatRange range = Ranges.floatRange(Float.valueOf(0), Float.valueOf(5));
assertEquals("[0.0, 1.0, 2.0, 3.0, 4.0]", IteratorToGeneratorAdapter.adapt(range).toCollection()
.toString());
- range = Ranges.floatRange(new Float(0), new Float(5), new Float(1));
+ range = Ranges.floatRange(Float.valueOf(0), Float.valueOf(5), Float.valueOf(1));
assertEquals("[0.0, 1.0, 2.0, 3.0, 4.0]", IteratorToGeneratorAdapter.adapt(range).toCollection()
.toString());
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestIntegerRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestIntegerRange.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestIntegerRange.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestIntegerRange.java Wed Nov 13 18:54:05 2013
@@ -78,7 +78,7 @@ public class TestIntegerRange extends Ba
List<? super Integer> list = (List<? super Integer>) (
IteratorToGeneratorAdapter.adapt(Ranges.integerRange(0,10)).to(new ArrayList<Integer>()));
for (int i=0;i<10;i++) {
- assertEquals(new Integer(i),list.get(i));
+ assertEquals(Integer.valueOf(i),list.get(i));
}
}
@@ -87,7 +87,7 @@ public class TestIntegerRange extends Ba
List<? super Integer> list = (List<? super Integer>) (
IteratorToGeneratorAdapter.adapt(Ranges.integerRange(10,0)).to(new ArrayList<Integer>()));
for (int i=10;i>0;i--) {
- assertEquals(new Integer(i),list.get(10-i));
+ assertEquals(Integer.valueOf(i),list.get(10-i));
}
}
}
@@ -131,9 +131,9 @@ public class TestIntegerRange extends Ba
@Test
public void testObjectConstructor() {
- IntegerRange range = Ranges.integerRange(new Integer(0), new Integer(5));
+ IntegerRange range = Ranges.integerRange(Integer.valueOf(0), Integer.valueOf(5));
assertEquals("[0, 1, 2, 3, 4]", IteratorToGeneratorAdapter.adapt(range).toCollection().toString());
- range = Ranges.integerRange(new Integer(0), new Integer(5), new Integer(1));
+ range = Ranges.integerRange(Integer.valueOf(0), Integer.valueOf(5), Integer.valueOf(1));
assertEquals("[0, 1, 2, 3, 4]", IteratorToGeneratorAdapter.adapt(range).toCollection().toString());
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestLongRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestLongRange.java?rev=1541658&r1=1541657&r2=1541658&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestLongRange.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/range/TestLongRange.java Wed Nov 13 18:54:05 2013
@@ -84,7 +84,7 @@ public class TestLongRange extends BaseF
LongRange range = Ranges.longRange(0, 10);
Iterator<Long> iter = range.iterator();
for (int i=0;i<10;i++) {
- assertEquals(new Long(i), iter.next());
+ assertEquals(Long.valueOf(i), iter.next());
}
}
@@ -93,7 +93,7 @@ public class TestLongRange extends BaseF
LongRange range = Ranges.longRange(10, 0);
Iterator<Long> iter = range.iterator();
for (int i=10;i>0;i--) {
- assertEquals(new Long(i), iter.next());
+ assertEquals(Long.valueOf(i), iter.next());
}
}
}
@@ -137,9 +137,9 @@ public class TestLongRange extends BaseF
@Test
public void testObjectConstructor() {
- LongRange range = Ranges.longRange(new Long(0), new Long(5));
+ LongRange range = Ranges.longRange(Long.valueOf(0), Long.valueOf(5));
assertEquals("[0, 1, 2, 3, 4]", IteratorToGeneratorAdapter.adapt(range).toCollection().toString());
- range = Ranges.longRange(new Integer(0), new Long(5), new Long(1));
+ range = Ranges.longRange(Integer.valueOf(0), Long.valueOf(5), Long.valueOf(1));
assertEquals("[0, 1, 2, 3, 4]", IteratorToGeneratorAdapter.adapt(range).toCollection().toString());
}