From 183281472cb842ed1be98c1590fc7cdef4f088db Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Mon, 12 May 2008 09:29:18 +0000 Subject: [PATCH 1/1] Added SetterConfiguration class for configuring how setters correspond to required interfaces. --- .../wamblee/collections/CollectionFilter.java | 8 ++++++++ .../java/org/wamblee/test/AssertionUtils.java | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java index c52bf7b1..75cdcb1e 100644 --- a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java +++ b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java @@ -21,6 +21,14 @@ import org.wamblee.conditions.Condition; public class CollectionFilter { + /** + * Filters a collection by adding all elements in the from collection + * that satisfy a given condition to the to collection. + * @param Type of contained element. + * @param aFrom From container to which the condition is applied. + * @param aTo To container to which matching elements are added. + * @param aCondition Condition by which elements are matched. + */ public static void filter(Collection aFrom, Collection aTo, Condition aCondition) { for (T t: aFrom) { if ( aCondition.matches(t)) { diff --git a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java index 0a3e4171..82462041 100644 --- a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java +++ b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java @@ -15,6 +15,8 @@ */ package org.wamblee.test; +import java.util.Arrays; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -45,9 +47,10 @@ public final class AssertionUtils { * @param aActual * Actual object array. */ - public static void assertEquals(Object[] aExpected, Object[] aActual) { + public static void assertEquals(T[] aExpected, T[] aActual) { assertEquals("", aExpected, aActual); } + /** * Asserts that two object arrays are equal. @@ -59,8 +62,8 @@ public final class AssertionUtils { * @param aActual * Actual array. */ - public static void assertEquals(String aMsg, Object[] aExpected, - Object[] aActual) { + public static void assertEquals(String aMsg, T[] aExpected, + T[] aActual) { TestCase.assertEquals(aMsg + ": Array lengths ", aExpected.length, aActual.length); @@ -69,6 +72,7 @@ public final class AssertionUtils { aActual[i]); } } + /** * Asserts that two objects are equal, and in case the object is an Object[] @@ -81,8 +85,8 @@ public final class AssertionUtils { * @param aActual * Actual result. */ - public static void assertEquals(String aMsg, Object aExpected, - Object aActual) { + public static void assertEquals(String aMsg, T aExpected, + T aActual) { if (aExpected instanceof Object[]) { AssertionUtils.assertEquals(aMsg, (Object[]) aExpected, (Object[]) aActual); @@ -104,7 +108,8 @@ public final class AssertionUtils { * @param aActual * Actual result. */ - public static void assertEquals(String aMsg, Map aExpectedMap, Map aActual) { + public static void assertEquals(String aMsg, + Map aExpectedMap, Map aActual) { TestCase.assertEquals("Map sizes differ", aExpectedMap.size(), aActual .size()); @@ -132,6 +137,7 @@ public final class AssertionUtils { public static void assertException(ErroneousCode aObject, Class aType) { try { aObject.run(); + throw new RuntimeException("No exception occurred"); } catch (Throwable t) { if ( aType.isInstance(t)) { return; // ok -- 2.31.1