Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2013-12-02 20:04:11 +0000
committerRoberto E. Escobar2013-12-04 00:05:37 +0000
commit5c05723b76b315d0710403a649da6afdd84ed3f9 (patch)
tree45eb0eab5ddc0015ad539b64fa34c7e7bf4b950f /plugins/org.eclipse.osee.framework.jdk.core.test
parent94a1a53681dcdfddf07d11e37fcb161642cc6da6 (diff)
downloadorg.eclipse.osee-5c05723b76b315d0710403a649da6afdd84ed3f9.tar.gz
org.eclipse.osee-5c05723b76b315d0710403a649da6afdd84ed3f9.tar.xz
org.eclipse.osee-5c05723b76b315d0710403a649da6afdd84ed3f9.zip
refactor: Move ResultSet to jdk core
Diffstat (limited to 'plugins/org.eclipse.osee.framework.jdk.core.test')
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/JdkCoreTypeTestSuite.java1
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/ResultSetIterableTest.java129
3 files changed, 134 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.jdk.core.test/META-INF/MANIFEST.MF
index f3f462321a1..c53891443f8 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/META-INF/MANIFEST.MF
@@ -6,4 +6,7 @@ Bundle-Version: 0.16.0.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Fragment-Host: org.eclipse.osee.framework.jdk.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.junit
+Require-Bundle: org.junit,
+ org.mockito;bundle-version="1.9.0",
+ org.hamcrest.core,
+ org.objenesis
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/JdkCoreTypeTestSuite.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/JdkCoreTypeTestSuite.java
index b702b42f773..0e954f631af 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/JdkCoreTypeTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/JdkCoreTypeTestSuite.java
@@ -24,6 +24,7 @@ import org.junit.runners.Suite;
PropertyStoreTest.class,
PropertyStoreWriterTest.class,
QuadTest.class,
+ ResultSetIterableTest.class,
TripletTest.class})
public class JdkCoreTypeTestSuite {
// Test Suite
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/ResultSetIterableTest.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/ResultSetIterableTest.java
new file mode 100644
index 00000000000..bc8639b1587
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/type/ResultSetIterableTest.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.jdk.core.type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link ResultSetIterable}
+ *
+ * @author Roberto E. Escobar
+ */
+public class ResultSetIterableTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private ResultSet<String> result;
+ private Set<String> data;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+
+ data = new LinkedHashSet<String>();
+ result = new ResultSetIterable<String>(data);
+ }
+
+ @Test
+ public void testSizeAndEmpty() {
+ data.add("a");
+ data.add("b");
+ data.add("c");
+
+ assertFalse(result.isEmpty());
+ assertEquals(3, result.size());
+
+ data.clear();
+ assertTrue(result.isEmpty());
+ assertEquals(0, result.size());
+
+ result.iterator();
+ }
+
+ @Test
+ public void testGetExactlyOneMultipleException() throws OseeCoreException {
+ data.add("a");
+ data.add("b");
+
+ thrown.expect(MultipleItemsExist.class);
+ thrown.expectMessage("Multiple items found - total [2]");
+ result.getExactlyOne();
+ }
+
+ @Test
+ public void testGetExactlyOneNoneExistException() throws OseeCoreException {
+ thrown.expect(ItemDoesNotExist.class);
+ thrown.expectMessage("No item found");
+ result.getExactlyOne();
+ }
+
+ @Test
+ public void testGetExactlyOne() throws OseeCoreException {
+ data.add("c");
+ assertEquals("c", result.getExactlyOne());
+ }
+
+ @Test
+ public void testGetOneOrNull() throws OseeCoreException {
+ Assert.assertNull(result.getOneOrNull());
+
+ data.add("a");
+ data.add("b");
+ data.add("c");
+ assertEquals("a", result.getOneOrNull());
+ }
+
+ @Test
+ public void testGetAtMostOneOrNullExceptionMoreThanOne() throws OseeCoreException {
+ assertNull(result.getAtMostOneOrNull());
+
+ data.add("a");
+ data.add("b");
+ data.add("c");
+ thrown.expect(MultipleItemsExist.class);
+ thrown.expectMessage("Multiple items found - total [3]");
+ assertEquals("a", result.getAtMostOneOrNull());
+ }
+
+ @Test
+ public void testGetAtMostOneOrNull() throws OseeCoreException {
+ assertNull(result.getAtMostOneOrNull());
+
+ data.add("a");
+ assertEquals("a", result.getAtMostOneOrNull());
+ }
+
+ @Test
+ public void testIterator() {
+ data.add("a");
+ data.add("b");
+ data.add("c");
+
+ Iterator<String> iterator = result.iterator();
+ assertEquals("a", iterator.next());
+ assertEquals("b", iterator.next());
+ assertEquals("c", iterator.next());
+ }
+
+}

Back to the top