Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-06-17 16:12:27 +0000
committerBrian Vosburgh2017-05-18 22:37:14 +0000
commita36a53cc6c994695a43c789491f31a4381b926dc (patch)
tree8e3cfadf2858b5f36ec7aa54524eec08144ebfb2 /common/tests
parent6ac3335fb9ba983b1c15cafa71209848456d91b1 (diff)
downloadwebtools.dali-a36a53cc6c994695a43c789491f31a4381b926dc.tar.gz
webtools.dali-a36a53cc6c994695a43c789491f31a4381b926dc.tar.xz
webtools.dali-a36a53cc6c994695a43c789491f31a4381b926dc.zip
add List/CollectionLastElementTransformer
Diffstat (limited to 'common/tests')
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformerTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformer_Tests.java64
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformerTests.java50
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformer_Tests.java64
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionSingleElementTransformerTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java5
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java50
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java63
8 files changed, 302 insertions, 6 deletions
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformerTests.java
index 298dd4b2ca..f6d1227d7f 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformerTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformerTests.java
@@ -26,7 +26,7 @@ public class CollectionFirstElementTransformerTests
public void testEvaluate() {
Collection<String> list = new ArrayList<>();
- Transformer<Collection<String>, String> transformer = TransformerTools.collectionFirstElementTransformer();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionFirstElementTransformer();
assertNull(transformer.transform(list));
list.add("foo");
assertEquals("foo", transformer.transform(list));
@@ -39,12 +39,12 @@ public class CollectionFirstElementTransformerTests
}
public void testToString() {
- Transformer<Collection<String>, String> transformer = TransformerTools.collectionFirstElementTransformer();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionFirstElementTransformer();
assertEquals("CollectionFirstElementTransformer", transformer.toString());
}
public void testSerialization() throws Exception {
- Transformer<Collection<String>, String> transformer = TransformerTools.collectionFirstElementTransformer();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionFirstElementTransformer();
assertSame(transformer, TestTools.serialize(transformer));
}
}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformer_Tests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformer_Tests.java
new file mode 100644
index 0000000000..22d105e3af
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionFirstElementTransformer_Tests.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.transformer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.NoSuchElementException;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
+import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
+public class CollectionFirstElementTransformer_Tests
+ extends TestCase
+{
+ public CollectionFirstElementTransformer_Tests(String name) {
+ super(name);
+ }
+
+ public void testEvaluate() {
+ Collection<String> list = new ArrayList<>();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionFirstElementTransformer_();
+ boolean exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (NoSuchElementException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ list.add("foo");
+ assertEquals("foo", transformer.transform(list));
+ list.add("bar");
+ assertEquals("foo", transformer.transform(list));
+ list.remove("foo");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("bar");
+ exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (NoSuchElementException ex) {
+ exCaught = true;
+ }
+ }
+
+ public void testToString() {
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionFirstElementTransformer_();
+ assertEquals("CollectionFirstElementTransformer_", transformer.toString());
+ }
+
+ public void testSerialization() throws Exception {
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionFirstElementTransformer_();
+ assertSame(transformer, TestTools.serialize(transformer));
+ }
+}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformerTests.java
new file mode 100644
index 0000000000..4db7c09526
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformerTests.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.transformer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
+import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
+public class CollectionLastElementTransformerTests
+ extends TestCase
+{
+ public CollectionLastElementTransformerTests(String name) {
+ super(name);
+ }
+
+ public void testEvaluate() {
+ Collection<String> list = new ArrayList<>();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionLastElementTransformer();
+ assertNull(transformer.transform(list));
+ list.add("foo");
+ assertEquals("foo", transformer.transform(list));
+ list.add("bar");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("foo");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("bar");
+ assertNull(transformer.transform(list));
+ }
+
+ public void testToString() {
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionLastElementTransformer();
+ assertEquals("CollectionLastElementTransformer", transformer.toString());
+ }
+
+ public void testSerialization() throws Exception {
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionLastElementTransformer();
+ assertSame(transformer, TestTools.serialize(transformer));
+ }
+}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformer_Tests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformer_Tests.java
new file mode 100644
index 0000000000..a57a806c64
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionLastElementTransformer_Tests.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.transformer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.NoSuchElementException;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
+import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
+public class CollectionLastElementTransformer_Tests
+ extends TestCase
+{
+ public CollectionLastElementTransformer_Tests(String name) {
+ super(name);
+ }
+
+ public void testEvaluate() {
+ Collection<String> list = new ArrayList<>();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionLastElementTransformer_();
+ boolean exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (NoSuchElementException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ list.add("foo");
+ assertEquals("foo", transformer.transform(list));
+ list.add("bar");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("foo");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("bar");
+ exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (NoSuchElementException ex) {
+ exCaught = true;
+ }
+ }
+
+ public void testToString() {
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionLastElementTransformer_();
+ assertEquals("CollectionLastElementTransformer_", transformer.toString());
+ }
+
+ public void testSerialization() throws Exception {
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionLastElementTransformer_();
+ assertSame(transformer, TestTools.serialize(transformer));
+ }
+}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionSingleElementTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionSingleElementTransformerTests.java
index 845cb635d3..fa116241e4 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionSingleElementTransformerTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/CollectionSingleElementTransformerTests.java
@@ -26,7 +26,7 @@ public class CollectionSingleElementTransformerTests
public void testEvaluate() {
Collection<String> list = new ArrayList<>();
- Transformer<Collection<String>, String> transformer = TransformerTools.collectionSingleElementTransformer();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionSingleElementTransformer();
assertNull(transformer.transform(list));
list.add("foo");
assertEquals("foo", transformer.transform(list));
@@ -39,12 +39,12 @@ public class CollectionSingleElementTransformerTests
}
public void testToString() {
- Transformer<Collection<String>, String> transformer = TransformerTools.collectionSingleElementTransformer();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionSingleElementTransformer();
assertEquals("CollectionSingleElementTransformer", transformer.toString());
}
public void testSerialization() throws Exception {
- Transformer<Collection<String>, String> transformer = TransformerTools.collectionSingleElementTransformer();
+ Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionSingleElementTransformer();
assertSame(transformer, TestTools.serialize(transformer));
}
}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java
index a087f1d57e..bf3b780746 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java
@@ -21,7 +21,12 @@ public class JptCommonUtilityTransformerTests {
TestSuite suite = new TestSuite(JptCommonUtilityTransformerTests.class.getPackage().getName());
suite.addTestSuite(CollectionFirstElementTransformerTests.class);
+ suite.addTestSuite(CollectionFirstElementTransformer_Tests.class);
+ suite.addTestSuite(CollectionLastElementTransformerTests.class);
+ suite.addTestSuite(CollectionLastElementTransformer_Tests.class);
suite.addTestSuite(CollectionSingleElementTransformerTests.class);
+ suite.addTestSuite(ListLastElementTransformerTests.class);
+ suite.addTestSuite(ListLastElementTransformer_Tests.class);
suite.addTestSuite(XMLStringDecoderTests.class);
suite.addTestSuite(XMLStringEncoderTests.class);
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java
new file mode 100644
index 0000000000..af971881a2
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.transformer;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
+import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
+public class ListLastElementTransformerTests
+ extends TestCase
+{
+ public ListLastElementTransformerTests(String name) {
+ super(name);
+ }
+
+ public void testEvaluate() {
+ List<String> list = new ArrayList<>();
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer();
+ assertNull(transformer.transform(list));
+ list.add("foo");
+ assertEquals("foo", transformer.transform(list));
+ list.add("bar");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("foo");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("bar");
+ assertNull(transformer.transform(list));
+ }
+
+ public void testToString() {
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer();
+ assertEquals("ListLastElementTransformer", transformer.toString());
+ }
+
+ public void testSerialization() throws Exception {
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer();
+ assertSame(transformer, TestTools.serialize(transformer));
+ }
+}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java
new file mode 100644
index 0000000000..d68eb01a52
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.transformer;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
+import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
+public class ListLastElementTransformer_Tests
+ extends TestCase
+{
+ public ListLastElementTransformer_Tests(String name) {
+ super(name);
+ }
+
+ public void testEvaluate() {
+ List<String> list = new ArrayList<>();
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer_();
+ boolean exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (IndexOutOfBoundsException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ list.add("foo");
+ assertEquals("foo", transformer.transform(list));
+ list.add("bar");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("foo");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("bar");
+ exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (IndexOutOfBoundsException ex) {
+ exCaught = true;
+ }
+ }
+
+ public void testToString() {
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer_();
+ assertEquals("ListLastElementTransformer_", transformer.toString());
+ }
+
+ public void testSerialization() throws Exception {
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer_();
+ assertSame(transformer, TestTools.serialize(transformer));
+ }
+}

Back to the top