From a9b7c29bc70c3250f7aa3b70673c8cad75a755fd Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Sun, 29 Jul 2012 10:37:03 +0000 Subject: [PATCH] Fixed generics testcase. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1366807 13f79535-47bb-0310-9956-ffa450edef68 --- .../collections/bag/TransformedBagTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/apache/commons/collections/bag/TransformedBagTest.java b/src/test/java/org/apache/commons/collections/bag/TransformedBagTest.java index bcaf43845..ffc4e19f5 100644 --- a/src/test/java/org/apache/commons/collections/bag/TransformedBagTest.java +++ b/src/test/java/org/apache/commons/collections/bag/TransformedBagTest.java @@ -36,13 +36,15 @@ public class TransformedBagTest extends AbstractBagTest { @Override @SuppressWarnings("unchecked") public Bag makeObject() { - return TransformedBag.transformingBag(new HashBag(), (Transformer) TestTransformedCollection.NOOP_TRANSFORMER); + return TransformedBag.transformingBag(new HashBag(), + (Transformer) TestTransformedCollection.NOOP_TRANSFORMER); } @SuppressWarnings("unchecked") public void testTransformedBag() { //T had better be Object! - Bag bag = TransformedBag.transformingBag(new HashBag(), (Transformer) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); + Bag bag = TransformedBag.transformingBag(new HashBag(), + (Transformer) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, bag.size()); Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (int i = 0; i < els.length; i++) { @@ -56,14 +58,15 @@ public class TransformedBagTest extends AbstractBagTest { assertEquals(true, bag.remove(new Integer((String) els[0]))); } - // TODO: Generics + @SuppressWarnings("unchecked") public void testTransformedBag_decorateTransform() { - Bag originalBag = new HashBag(); + Bag originalBag = new HashBag(); Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (int i = 0; i < els.length; i++) { - originalBag.add(els[i]); + originalBag.add((T) els[i]); } - Bag bag = TransformedBag.transformedBag(originalBag, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); + Bag bag = TransformedBag.transformedBag(originalBag, + (Transformer) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); assertEquals(els.length, bag.size()); for (int i = 0; i < els.length; i++) { assertEquals(true, bag.contains(new Integer((String) els[i])));