Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-06-08 16:52:22 +0000
committerBrian Vosburgh2017-05-18 22:36:53 +0000
commite827a4f8b802b3dfd3c9511ea273d495d545ba18 (patch)
treeec173d39a523be57f3bb123bf8e6cadaf2eaaaae /common/tests
parent80f0a4cc227f32c288d1bc3a8ecaf3574ef15b4d (diff)
downloadwebtools.dali-e827a4f8b802b3dfd3c9511ea273d495d545ba18.tar.gz
webtools.dali-e827a4f8b802b3dfd3c9511ea273d495d545ba18.tar.xz
webtools.dali-e827a4f8b802b3dfd3c9511ea273d495d545ba18.zip
add CollectionIsEmptyPredicate
Diffstat (limited to 'common/tests')
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/CollectionIsEmptyPredicateTests.java46
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/JptCommonUtilityPredicateTests.java3
2 files changed, 48 insertions, 1 deletions
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/CollectionIsEmptyPredicateTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/CollectionIsEmptyPredicateTests.java
new file mode 100644
index 0000000000..f162e801f8
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/CollectionIsEmptyPredicateTests.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.tests.internal.predicate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.eclipse.jpt.common.utility.internal.predicate.PredicateTools;
+import org.eclipse.jpt.common.utility.predicate.Predicate;
+import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
+public class CollectionIsEmptyPredicateTests
+ extends TestCase
+{
+ public CollectionIsEmptyPredicateTests(String name) {
+ super(name);
+ }
+
+ public void testEvaluate() {
+ Collection<String> list = new ArrayList<>();
+ Predicate<Collection<String>> predicate = PredicateTools.<String>collectionIsEmptyPredicate();
+ assertTrue(predicate.evaluate(list));
+ list.add("foo");
+ assertFalse(predicate.evaluate(list));
+ list.remove("foo");
+ assertTrue(predicate.evaluate(list));
+ }
+
+ public void testToString() {
+ Predicate<Collection<String>> predicate = PredicateTools.<String>collectionIsEmptyPredicate();
+ assertEquals("CollectionIsEmptyPredicate", predicate.toString());
+ }
+
+ public void testSerialization() throws Exception {
+ Predicate<Collection<String>> predicate = PredicateTools.<String>collectionIsEmptyPredicate();
+ assertSame(predicate, TestTools.serialize(predicate));
+ }
+}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/JptCommonUtilityPredicateTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/JptCommonUtilityPredicateTests.java
index 5cab63aed7..561e5210a6 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/JptCommonUtilityPredicateTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/JptCommonUtilityPredicateTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2016 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -18,6 +18,7 @@ public class JptCommonUtilityPredicateTests {
TestSuite suite = new TestSuite(JptCommonUtilityPredicateTests.class.getPackage().getName());
suite.addTestSuite(ANDTests.class);
+ suite.addTestSuite(CollectionIsEmptyPredicateTests.class);
suite.addTestSuite(EqualsTests.class);
suite.addTestSuite(FieldPredicateTests.class);
suite.addTestSuite(IsIdenticalTests.class);

Back to the top