Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-06-18 21:12:30 -0400
committerrescobar2010-06-18 21:12:30 -0400
commit43b01ceb6d945a880d248b7d118bcdcbe9311e20 (patch)
tree39dab74c1d658a11a9a9f19b8ba3699eb722d6d6
parent9c11caaa40976f710dc3b7111104b0c04344993e (diff)
downloadorg.eclipse.osee-43b01ceb6d945a880d248b7d118bcdcbe9311e20.tar.gz
org.eclipse.osee-43b01ceb6d945a880d248b7d118bcdcbe9311e20.tar.xz
org.eclipse.osee-43b01ceb6d945a880d248b7d118bcdcbe9311e20.zip
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/.project28
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.pde.core.prefs5
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/META-INF/MANIFEST.MF11
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/build.properties4
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/AllCoreModelTestSuite.java30
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AbstractOseeCacheTest.java271
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/ArtifactTypeCacheTest.java70
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AttributeTypeCacheTest.java70
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/BranchCacheTest.java71
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/CacheTestSuite.java30
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/OseeEnumTypeCacheTest.java83
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/RelationTypeCacheTest.java70
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactSuperTypeFieldTest.java99
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactTypeAttributesFieldTest.java106
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/AssociatedArtifactFieldTest.java50
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BaseOseeFieldTest.java119
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BranchAliasesFieldTest.java56
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/CollectionFieldTest.java77
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/EnumEntryFieldTest.java150
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldGetSetTestData.java58
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestSuite.java32
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestUtil.java37
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldMainTest.java118
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldTestData.java58
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/UniqueIdFieldTest.java51
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockAbstractOseeType.java23
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockDataFactory.java141
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeCachingServiceProvider.java31
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeDataAccessor.java56
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeTransactionDataAccessor.java75
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/ModelAsserts.java302
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AbstractOseeTypeTest.java124
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ArtifactTypeTest.java308
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AttributeTypeTest.java51
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BaseOseeTypeTest.java43
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BranchTest.java331
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ModelTestSuite.java30
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/OseeEnumTypeTest.java47
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/RelationTypeTest.java124
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/TransactionRecordTest.java161
42 files changed, 3616 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/.classpath b/plugins/org.eclipse.osee.framework.core.model.test/.classpath
new file mode 100644
index 0000000000..8a8f1668cd
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/.project b/plugins/org.eclipse.osee.framework.core.model.test/.project
new file mode 100644
index 0000000000..6535ad2cbe
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.core.model.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..253ebb427b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Fri Jun 18 14:11:27 MST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.pde.core.prefs b/plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 0000000000..539565a99d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,5 @@
+#Fri Jun 18 14:11:27 MST 2010
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.model.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..6af9e88eb6
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Core Model Test
+Bundle-SymbolicName: org.eclipse.osee.framework.core.model.test;singleton:=true
+Bundle-Version: 0.9.5.qualifier
+Bundle-Vendor: Eclipse.org
+Fragment-Host: org.eclipse.osee.framework.core.model;bundle-version="0.9.5"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.junit4;bundle-version="4.5.0"
+Export-Package: org.eclipse.osee.framework.core.model.test,
+ org.eclipse.osee.framework.core.model.test.mocks
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/build.properties b/plugins/org.eclipse.osee.framework.core.model.test/build.properties
new file mode 100644
index 0000000000..41eb6ade2b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/AllCoreModelTestSuite.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/AllCoreModelTestSuite.java
new file mode 100644
index 0000000000..c01fd69cd4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/AllCoreModelTestSuite.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test;
+
+import org.eclipse.osee.framework.core.model.test.cache.CacheTestSuite;
+import org.eclipse.osee.framework.core.model.test.fields.FieldTestSuite;
+import org.eclipse.osee.framework.core.model.test.type.ModelTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {//
+CacheTestSuite.class, //
+ FieldTestSuite.class, //
+ ModelTestSuite.class, //
+})
+/**
+ * @author Roberto E. Escobar
+ */
+public class AllCoreModelTestSuite {
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AbstractOseeCacheTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AbstractOseeCacheTest.java
new file mode 100644
index 0000000000..e03a9e2459
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AbstractOseeCacheTest.java
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.exception.OseeTypeDoesNotExist;
+import org.eclipse.osee.framework.core.model.AbstractOseeType;
+import org.eclipse.osee.framework.core.model.cache.AbstractOseeCache;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AbstractOseeCache}
+ *
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractOseeCacheTest<T extends AbstractOseeType> {
+ private final List<T> data;
+ private final AbstractOseeCache<T> cache;
+ private final TypeComparator comparator;
+
+ public AbstractOseeCacheTest(List<T> artifactTypes, AbstractOseeCache<T> typeCache) {
+ this.comparator = new TypeComparator();
+ this.data = artifactTypes;
+ this.cache = typeCache;
+ }
+
+ @org.junit.Test
+ public void testAllItems() throws OseeCoreException {
+ List<T> actualTypes = new ArrayList<T>(cache.getAll());
+ java.util.Collections.sort(actualTypes, comparator);
+
+ java.util.Collections.sort(data, comparator);
+ Assert.assertEquals(data.size(), actualTypes.size());
+ for (int index = 0; index < data.size(); index++) {
+ Assert.assertNotNull(actualTypes.get(index));
+ checkEquals(data.get(index), actualTypes.get(index));
+ }
+ }
+
+ @org.junit.Test
+ public void testExistByGuid() throws OseeCoreException {
+ for (T expected : data) {
+ Assert.assertTrue(cache.existsByGuid(expected.getGuid()));
+ }
+ Assert.assertFalse(cache.existsByGuid("notExist"));
+ }
+
+ @org.junit.Test
+ public void testCacheByGuid() throws OseeCoreException {
+ for (T expected : data) {
+ T actual = cache.getByGuid(expected.getGuid());
+ Assert.assertNotNull(actual);
+ checkEquals(expected, actual);
+ }
+ }
+
+ @org.junit.Test
+ public void testCacheById() throws OseeCoreException {
+ for (T expected : data) {
+ T actual = cache.getById(expected.getId());
+ Assert.assertNotNull(actual);
+ checkEquals(expected, actual);
+ }
+ }
+
+ @org.junit.Test
+ public void testCacheByName() throws OseeCoreException {
+ for (T expected : data) {
+ T actual = cache.getUniqueByName(expected.getName());
+ Assert.assertNotNull(actual);
+ checkEquals(expected, actual);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @org.junit.Test
+ public void testDecache() throws OseeCoreException {
+ T item1 = data.get(0);
+ checkCached(item1, true);
+
+ cache.decache(item1);
+ checkCached(item1, false);
+
+ cache.cache(item1);
+ checkCached(item1, true);
+
+ T item2 = data.get(1);
+ checkCached(item2, true);
+
+ cache.decache(item1, item2);
+ checkCached(item1, false);
+ checkCached(item2, false);
+
+ cache.cache(item1, item2);
+ checkCached(item1, true);
+ checkCached(item2, true);
+ }
+
+ private void checkCached(T item, boolean isInCacheExpected) throws OseeCoreException {
+ if (isInCacheExpected) {
+ Assert.assertEquals(item, cache.getByGuid(item.getGuid()));
+ Assert.assertEquals(item, cache.getById(item.getId()));
+ Assert.assertEquals(item, cache.getUniqueByName(item.getName()));
+ Assert.assertTrue(cache.getAll().contains(item));
+ } else {
+ Assert.assertNull(cache.getByGuid(item.getGuid()));
+ Assert.assertNull(cache.getById(item.getId()));
+ Assert.assertNull(cache.getUniqueByName(item.getName()));
+ Assert.assertFalse(cache.getAll().contains(item));
+ }
+ }
+
+ @org.junit.Test
+ public void testGetByName() throws OseeCoreException {
+ for (T expected : data) {
+ Collection<T> actual = cache.getByName(expected.getName());
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(1, actual.size());
+ checkEquals(expected, actual.iterator().next());
+ }
+ }
+
+ @org.junit.Test
+ public void testMultipleGetByName() throws OseeCoreException {
+ T item1 = data.get(0);
+ T item2 = data.get(1);
+ Assert.assertNotNull(item1);
+ Assert.assertNotNull(item2);
+
+ Collection<T> actual = cache.getByName(item1.getName());
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(1, actual.size());
+ checkEquals(item1, actual.iterator().next());
+
+ actual = cache.getByName(item2.getName());
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(1, actual.size());
+ checkEquals(item2, actual.iterator().next());
+
+ String originalName = item1.getName();
+ if (item1 instanceof AbstractOseeType) {
+ cache.decache(item1);
+
+ ((AbstractOseeType) item1).setName(item2.getName());
+
+ if (cache.isNameUniquenessEnforced()) {
+ try {
+ cache.cache(item1);
+ Assert.fail("This line should not be executed");
+ } catch (OseeCoreException ex) {
+ Assert.assertTrue(ex instanceof OseeStateException);
+ }
+
+ actual = cache.getByName(originalName);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(0, actual.size());
+
+ } else {
+ cache.cache(item1);
+
+ actual = cache.getByName(originalName);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(0, actual.size());
+
+ actual = cache.getByName(item2.getName());
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(2, actual.size());
+
+ checkEquals(item2, actual.iterator().next());
+ }
+ ((AbstractOseeType) item1).setName(originalName);
+ }
+ }
+
+ @Test
+ public void testReload() throws OseeCoreException {
+ int fullCacheSize = cache.size();
+ Assert.assertTrue(fullCacheSize > 0);
+ for (T type : cache.getAll()) {
+ cache.decache(type);
+ }
+
+ Assert.assertEquals(0, cache.size());
+ Assert.assertTrue(cache.reloadCache());
+ Assert.assertEquals(fullCacheSize, cache.size());
+ }
+
+ @Test(expected = OseeTypeDoesNotExist.class)
+ public void testNonExistingPersist() throws OseeCoreException {
+ cache.storeByGuid(Collections.singleton(GUID.create()));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test(expected = OseeArgumentException.class)
+ public void testStoreNull2() throws OseeCoreException {
+ cache.storeItems((T) null);
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testStoreNull3() throws OseeCoreException {
+ cache.storeItems((Collection<T>) null);
+ }
+
+ @Ignore
+ @Test
+ public void testPersist() throws OseeCoreException {
+ // T item1 = data.get(0);
+ // T item2 = data.get(1);
+ //
+ // String name1 = item1.getName();
+ // String name2 = item2.getName();
+ //
+ // AbstractOseeType t1 = (AbstractOseeType) item1;
+ // AbstractOseeType t2 = (AbstractOseeType) item2;
+ //
+ // t1.setName("changed_1");
+ // t2.setName("changed_2");
+ //
+ // cache.storeByGuid(guids);
+
+ // T item2 = data.get(1);
+ //
+ //
+ // cache.storeItem(item);
+ // cache.storeItems(toStore);
+ // cache.storeItems(items);
+ // public void storeItem(AbstractOseeType item) throws OseeCoreException {
+
+ // public void storeItems(T... items) throws OseeCoreException {
+
+ // public void storeItems(Collection<T> toStore) throws OseeCoreException {
+ }
+
+ protected void checkEquals(T expected, T actual) throws OseeCoreException {
+ Assert.assertEquals(expected, actual);
+ }
+
+ private final class TypeComparator implements Comparator<T> {
+
+ @Override
+ public int compare(T o1, T o2) {
+ int result = -1;
+ if (o1 == null && o2 == null) {
+ result = 0;
+ } else if (o1 != null && o2 != null) {
+ result = o1.getName().compareTo(o2.getName());
+ } else if (o2 == null) {
+ result = 1;
+ }
+ return result;
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/ArtifactTypeCacheTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/ArtifactTypeCacheTest.java
new file mode 100644
index 0000000000..ecad91c4e0
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/ArtifactTypeCacheTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.core.model.test.mocks.MockOseeDataAccessor;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+/**
+ * Test Case for {@link ArtifactTypeCache}
+ *
+ * @author Roberto E. Escobar
+ */
+public class ArtifactTypeCacheTest extends AbstractOseeCacheTest<ArtifactType> {
+
+ private static List<ArtifactType> artifactTypes;
+ private static ArtifactTypeCache artCache;
+
+ @BeforeClass
+ public static void prepareTestData() throws OseeCoreException {
+ artifactTypes = new ArrayList<ArtifactType>();
+
+ ArtifactDataAccessor artData = new ArtifactDataAccessor(artifactTypes);
+ artCache = new ArtifactTypeCache(artData);
+
+ artCache.ensurePopulated();
+ Assert.assertTrue(artData.wasLoaded());
+ }
+
+ public ArtifactTypeCacheTest() {
+ super(artifactTypes, artCache);
+ }
+
+ private final static class ArtifactDataAccessor extends MockOseeDataAccessor<ArtifactType> {
+ private final List<ArtifactType> artifactTypes;
+
+ public ArtifactDataAccessor(List<ArtifactType> artifactTypes) {
+ super();
+ this.artifactTypes = artifactTypes;
+ }
+
+ @Override
+ public void load(IOseeCache<ArtifactType> cache) throws OseeCoreException {
+ super.load(cache);
+
+ int typeId = 100;
+ for (int index = 0; index < 10; index++) {
+ ArtifactType item = MockDataFactory.createArtifactType(index);
+ artifactTypes.add(item);
+ item.setId(typeId++);
+ cache.cache(item);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AttributeTypeCacheTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AttributeTypeCacheTest.java
new file mode 100644
index 0000000000..0ec3f58d92
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/AttributeTypeCacheTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.core.model.test.mocks.MockOseeDataAccessor;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+/**
+ * Test Case for {@link AttributeTypeCache}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AttributeTypeCacheTest extends AbstractOseeCacheTest<AttributeType> {
+
+ private static List<AttributeType> attributeTypes;
+ private static AttributeTypeCache attrCache;
+
+ @BeforeClass
+ public static void prepareTestData() throws OseeCoreException {
+ attributeTypes = new ArrayList<AttributeType>();
+
+ AttributeDataAccessor attrData = new AttributeDataAccessor(attributeTypes);
+ attrCache = new AttributeTypeCache(attrData);
+
+ attrCache.ensurePopulated();
+ Assert.assertTrue(attrData.wasLoaded());
+ }
+
+ public AttributeTypeCacheTest() {
+ super(attributeTypes, attrCache);
+ }
+
+ private final static class AttributeDataAccessor extends MockOseeDataAccessor<AttributeType> {
+
+ private final List<AttributeType> attributeTypes;
+
+ public AttributeDataAccessor(List<AttributeType> attributeTypes) {
+ super();
+ this.attributeTypes = attributeTypes;
+ }
+
+ @Override
+ public void load(IOseeCache<AttributeType> cache) throws OseeCoreException {
+ super.load(cache);
+ int typeId = 100;
+ for (int index = 0; index < 10; index++) {
+ AttributeType item = MockDataFactory.createAttributeType(index, null);
+ attributeTypes.add(item);
+ item.setId(typeId++);
+ cache.cache(item);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/BranchCacheTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/BranchCacheTest.java
new file mode 100644
index 0000000000..5d39782ce7
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/BranchCacheTest.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.core.model.test.mocks.MockOseeDataAccessor;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+/**
+ * Test Case for {@link BranchCache}
+ *
+ * @author Roberto E. Escobar
+ */
+public class BranchCacheTest extends AbstractOseeCacheTest<Branch> {
+
+ private static List<Branch> branchData;
+ private static BranchCache cache;
+
+ @BeforeClass
+ public static void prepareTestData() throws OseeCoreException {
+ branchData = new ArrayList<Branch>();
+
+ BranchDataAccessor branchAccessor = new BranchDataAccessor(branchData);
+ cache = new BranchCache(branchAccessor);
+ cache.ensurePopulated();
+
+ Assert.assertTrue(branchAccessor.wasLoaded());
+
+ }
+
+ public BranchCacheTest() {
+ super(branchData, cache);
+ }
+
+ private final static class BranchDataAccessor extends MockOseeDataAccessor<Branch> {
+
+ private final List<Branch> data;
+
+ public BranchDataAccessor(List<Branch> data) {
+ super();
+ this.data = data;
+ }
+
+ @Override
+ public void load(IOseeCache<Branch> cache) throws OseeCoreException {
+ super.load(cache);
+ int typeId = 100;
+ for (int index = 0; index < 10; index++) {
+ Branch item = MockDataFactory.createBranch(index);
+ data.add(item);
+ item.setId(typeId++);
+ cache.cache(item);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/CacheTestSuite.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/CacheTestSuite.java
new file mode 100644
index 0000000000..3cc200f670
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/CacheTestSuite.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.cache;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {//
+
+ArtifactTypeCacheTest.class, //
+ AttributeTypeCacheTest.class, //
+ RelationTypeCacheTest.class, //
+ OseeEnumTypeCacheTest.class, //
+ BranchCacheTest.class //
+})
+/**
+ * @author Roberto E. Escobar
+ */
+public class CacheTestSuite {
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/OseeEnumTypeCacheTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/OseeEnumTypeCacheTest.java
new file mode 100644
index 0000000000..4421591c1f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/OseeEnumTypeCacheTest.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.OseeEnumEntry;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.core.model.test.mocks.MockOseeDataAccessor;
+import org.eclipse.osee.framework.core.model.test.mocks.ModelAsserts;
+import org.eclipse.osee.framework.core.model.type.OseeEnumType;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+/**
+ * Test Case for {@link OseeEnumTypeCache}
+ *
+ * @author Roberto E. Escobar
+ */
+public class OseeEnumTypeCacheTest extends AbstractOseeCacheTest<OseeEnumType> {
+
+ private static List<OseeEnumType> data;
+ private static OseeEnumTypeCache cache;
+
+ @BeforeClass
+ public static void prepareTestData() throws OseeCoreException {
+ data = new ArrayList<OseeEnumType>();
+
+ EnumDataAccessor enumAccessor = new EnumDataAccessor(data);
+ cache = new OseeEnumTypeCache(enumAccessor);
+
+ cache.ensurePopulated();
+ Assert.assertTrue(enumAccessor.wasLoaded());
+ }
+
+ public OseeEnumTypeCacheTest() {
+ super(data, cache);
+ }
+
+ @Override
+ protected void checkEquals(OseeEnumType expected, OseeEnumType actual) throws OseeCoreException {
+ ModelAsserts.checkEnumType(expected, actual);
+ }
+
+ private final static class EnumDataAccessor extends MockOseeDataAccessor<OseeEnumType> {
+ private final List<OseeEnumType> oseeEnumTypes;
+
+ public EnumDataAccessor(List<OseeEnumType> oseeEnumTypes) {
+ super();
+ this.oseeEnumTypes = oseeEnumTypes;
+ }
+
+ @Override
+ public void load(IOseeCache<OseeEnumType> cache) throws OseeCoreException {
+ super.load(cache);
+ int typeId = 100;
+ for (int index = 0; index < 10; index++) {
+ OseeEnumType item = MockDataFactory.createEnumType(index);
+ List<OseeEnumEntry> entries = new ArrayList<OseeEnumEntry>();
+ for (int j = 1; j <= 5; j++) {
+ OseeEnumEntry enumEntry = MockDataFactory.createEnumEntry(index + j);
+ entries.add(enumEntry);
+ }
+ item.setEntries(entries);
+
+ oseeEnumTypes.add(item);
+ item.setId(typeId++);
+ cache.cache(item);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/RelationTypeCacheTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/RelationTypeCacheTest.java
new file mode 100644
index 0000000000..aae7258ac3
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/cache/RelationTypeCacheTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.core.model.test.mocks.MockOseeDataAccessor;
+import org.eclipse.osee.framework.core.model.type.RelationType;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+/**
+ * Test Case for {@link RelationTypeCache}
+ *
+ * @author Roberto E. Escobar
+ */
+public class RelationTypeCacheTest extends AbstractOseeCacheTest<RelationType> {
+
+ private static List<RelationType> data;
+ private static RelationTypeCache cache;
+
+ @BeforeClass
+ public static void prepareTestData() throws OseeCoreException {
+ data = new ArrayList<RelationType>();
+
+ RelationDataAccessor relationAccessor = new RelationDataAccessor(data);
+ cache = new RelationTypeCache(relationAccessor);
+
+ cache.ensurePopulated();
+ Assert.assertTrue(relationAccessor.wasLoaded());
+ }
+
+ public RelationTypeCacheTest() {
+ super(data, cache);
+ }
+
+ private final static class RelationDataAccessor extends MockOseeDataAccessor<RelationType> {
+ private final List<RelationType> relationTypes;
+
+ public RelationDataAccessor(List<RelationType> relationTypes) {
+ super();
+ this.relationTypes = relationTypes;
+ }
+
+ @Override
+ public void load(IOseeCache<RelationType> cache) throws OseeCoreException {
+ super.load(cache);
+ int typeId = 100;
+ for (int index = 0; index < 10; index++) {
+ RelationType item = MockDataFactory.createRelationType(index, null, null);
+ relationTypes.add(item);
+ item.setId(typeId++);
+ cache.cache(item);
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactSuperTypeFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactSuperTypeFieldTest.java
new file mode 100644
index 0000000000..e10aa1ad37
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactSuperTypeFieldTest.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeInvalidInheritanceException;
+import org.eclipse.osee.framework.core.model.internal.fields.ArtifactSuperTypeField;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case For {@link ArtifactSuperTypeField}
+ *
+ * @author Roberto E. Escobar
+ */
+public class ArtifactSuperTypeFieldTest {
+
+ private static ArtifactType art1;
+ private static ArtifactType art2;
+ private static ArtifactType art3;
+ private static ArtifactType base;
+ private static ArtifactType containingArt;
+
+ @BeforeClass
+ public static void prepareTest() {
+ containingArt = MockDataFactory.createArtifactType(999);
+ art1 = MockDataFactory.createArtifactType(1);
+ art2 = MockDataFactory.createArtifactType(2);
+ art3 = MockDataFactory.createArtifactType(3);
+ base = new ArtifactType(CoreArtifactTypes.Artifact.getGuid(), CoreArtifactTypes.Artifact.getName(), false);
+ }
+
+ @Test
+ public void testSetGet() throws OseeCoreException {
+ List<ArtifactType> input = new ArrayList<ArtifactType>();
+ ArtifactSuperTypeField field = new ArtifactSuperTypeField(containingArt, input);
+ Assert.assertEquals(false, field.isDirty());
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList(art1, art2, art3), Arrays.asList(art1, art2, art3), true);
+ field.clearDirty();
+ Assert.assertEquals(false, field.isDirty());
+
+ // Add again in a different order
+ FieldTestUtil.assertSetGet(field, Arrays.asList(art3, art1, art2), Arrays.asList(art1, art2, art3), false);
+
+ // Remove
+ FieldTestUtil.assertSetGet(field, Arrays.asList(art3), Arrays.asList(art3), true);
+ field.clearDirty();
+ Assert.assertEquals(false, field.isDirty());
+
+ // Add
+ FieldTestUtil.assertSetGet(field, Arrays.asList(art3, art2), Arrays.asList(art3, art2), true);
+ field.clearDirty();
+ Assert.assertEquals(false, field.isDirty());
+ }
+
+ @Test(expected = OseeInvalidInheritanceException.class)
+ public void testBaseCircularity() throws OseeCoreException {
+ List<ArtifactType> input = new ArrayList<ArtifactType>();
+ ArtifactSuperTypeField field = new ArtifactSuperTypeField(containingArt, input);
+ Assert.assertEquals(false, field.isDirty());
+
+ field.set(Collections.singletonList(containingArt));
+ }
+
+ @Test(expected = OseeInvalidInheritanceException.class)
+ public void testBaseArtifact() throws OseeCoreException {
+ List<ArtifactType> input = new ArrayList<ArtifactType>();
+ ArtifactSuperTypeField field = new ArtifactSuperTypeField(containingArt, input);
+ Assert.assertEquals(false, field.isDirty());
+
+ field.set(Collections.<ArtifactType> emptyList());
+ }
+
+ @Test
+ public void testBaseArtifactNoSuperTypeRequired() throws OseeCoreException {
+ List<ArtifactType> input = new ArrayList<ArtifactType>();
+ ArtifactSuperTypeField field = new ArtifactSuperTypeField(base, input);
+ Assert.assertEquals(false, field.isDirty());
+
+ field.set(Collections.<ArtifactType> emptyList());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactTypeAttributesFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactTypeAttributesFieldTest.java
new file mode 100644
index 0000000000..2ae3e03010
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/ArtifactTypeAttributesFieldTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.internal.fields.ArtifactTypeAttributesField;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.jdk.core.util.Compare;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case For {@link ArtifactTypeAttributesField}
+ *
+ * @author Roberto E. Escobar
+ */
+public class ArtifactTypeAttributesFieldTest {
+
+ private static AttributeType attr1;
+ private static AttributeType attr2;
+ private static AttributeType attr3;
+ private static AttributeType attr4;
+ private static Branch br1;
+ private static Branch br2;
+
+ @BeforeClass
+ public static void prepareTest() throws OseeCoreException {
+ attr1 = MockDataFactory.createAttributeType(1, null);
+ attr2 = MockDataFactory.createAttributeType(2, null);
+ attr3 = MockDataFactory.createAttributeType(3, null);
+ attr4 = MockDataFactory.createAttributeType(4, null);
+
+ br1 = MockDataFactory.createBranch(1);
+ br2 = MockDataFactory.createBranch(2);
+ }
+
+ @Test
+ public void testGetSet() throws OseeCoreException {
+ Map<Branch, Collection<AttributeType>> input = new LinkedHashMap<Branch, Collection<AttributeType>>();
+ ArtifactTypeAttributesField field = new ArtifactTypeAttributesField(input);
+
+ Assert.assertEquals(false, field.isDirty());
+
+ assertSetGet(field, map(br1, attr1, attr2, attr3), map(br1, attr1, attr2, attr3), true);
+ field.clearDirty();
+
+ // Add again in different order
+ assertSetGet(field, map(br1, attr2, attr3, attr1), map(br1, attr1, attr2, attr3), false);
+
+ // Remove from list
+ assertSetGet(field, map(br1, attr2), map(br1, attr2), true);
+ field.clearDirty();
+
+ // Add to list
+ assertSetGet(field, map(br1, attr2, attr4), map(br1, attr2, attr4), true);
+ field.clearDirty();
+
+ // Add to entry
+ Map<Branch, Collection<AttributeType>> values = map(br1, attr2, attr4);
+ map(values, br2, attr3, attr1);
+ assertSetGet(field, values, values, true);
+ field.clearDirty();
+
+ // Add to emptylist
+ assertSetGet(field, Collections.<Branch, Collection<AttributeType>> emptyMap(),
+ Collections.<Branch, Collection<AttributeType>> emptyMap(), true);
+ field.clearDirty();
+ }
+
+ private static Map<Branch, Collection<AttributeType>> map(Branch branch, AttributeType... attrs) {
+ Map<Branch, Collection<AttributeType>> map = new LinkedHashMap<Branch, Collection<AttributeType>>();
+ map.put(branch, Arrays.asList(attrs));
+ return map;
+ }
+
+ private static Map<Branch, Collection<AttributeType>> map(Map<Branch, Collection<AttributeType>> map, Branch branch, AttributeType... attrs) {
+ map.put(branch, Arrays.asList(attrs));
+ return map;
+ }
+
+ private static void assertSetGet(ArtifactTypeAttributesField field, Map<Branch, Collection<AttributeType>> setValues, Map<Branch, Collection<AttributeType>> expected, boolean expectedDirty) throws OseeCoreException {
+ field.set(setValues);
+ Assert.assertEquals(expectedDirty, field.isDirty());
+
+ Map<Branch, Collection<AttributeType>> actual = field.get();
+ Assert.assertEquals(expected.size(), actual.size());
+
+ Assert.assertFalse(Compare.isDifferent(actual, expected));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/AssociatedArtifactFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/AssociatedArtifactFieldTest.java
new file mode 100644
index 0000000000..d412bcbfb9
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/AssociatedArtifactFieldTest.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.internal.fields.AssociatedArtifactField;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case For {@link AssociatedArtifactField}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AssociatedArtifactFieldTest {
+
+ private static IBasicArtifact<?> art1;
+ private static IBasicArtifact<?> art2;
+
+ // private static IBasicArtifact<?> art3;
+
+ @BeforeClass
+ public static void prepareTest() {
+ art1 = MockDataFactory.createArtifact(1);
+ art2 = MockDataFactory.createArtifact(2);
+ // art3 = MockDataFactory.createArtifact(3);
+ }
+
+ @Test
+ public void test() throws OseeCoreException {
+ AssociatedArtifactField field = new AssociatedArtifactField(art1);
+ Assert.assertEquals(false, field.isDirty());
+
+ field.set(art2);
+ Assert.assertEquals(true, field.isDirty());
+ field.clearDirty();
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BaseOseeFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BaseOseeFieldTest.java
new file mode 100644
index 0000000000..2127864a0d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BaseOseeFieldTest.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.internal.fields.OseeField;
+import org.eclipse.osee.framework.jdk.core.util.Compare;
+import org.junit.Test;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class BaseOseeFieldTest {
+ private final OseeFieldTestData<?> test;
+
+ protected BaseOseeFieldTest(OseeFieldTestData<?> test) {
+ this.test = test;
+ }
+
+ @Test
+ public void testInitialValues() throws OseeCoreException {
+ String message = "InitTest";
+ checkObjects(message, test.getInitExpectedValue(), test.getField().get());
+ Assert.assertEquals(message, test.isInitExpectedDirty(), test.getField().isDirty());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testSettterGetter() throws OseeCoreException {
+ int index = 0;
+ for (FieldGetSetTestData testData : test.getTestDatas()) {
+ String message = String.format("Test Data [%s]", ++index);
+ if (testData.isClearBeforeRun()) {
+ test.getField().clearDirty();
+ Assert.assertFalse(message, test.getField().isDirty());
+ }
+
+ if (testData.throwsError()) {
+ try {
+ test.doSetValue(testData);
+ Assert.assertNull(message, "This line should never be executed");
+ } catch (Exception ex) {
+ Class<?> clazz = testData.getError();
+ Assert.assertTrue(message, ex.getClass().isAssignableFrom(clazz));
+ }
+ } else {
+ test.doSetValue(testData);
+ }
+
+ checkObjects(message, testData.getExpectedValue(), test.getField().get());
+ Assert.assertEquals(message, testData.isExpectedDirty(), test.getField().isDirty());
+ }
+ }
+
+ private void checkObjects(String message, Object expected, Object actual) {
+ Assert.assertFalse(String.format("%s expected[%s] actual[%s]", message, expected, actual),
+ Compare.isDifferent(expected, actual));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Parameters
+ public static Collection<Object[]> data() throws OseeCoreException {
+ Collection<Object[]> data = new ArrayList<Object[]>();
+
+ data.add(new Object[] {//
+ new OseeFieldTestData<Object>(new OseeField<Object>(), //
+ null, false, //
+ new FieldGetSetTestData<Object>(true, "one test", "one test", true), //
+ new FieldGetSetTestData<Object>(false, "two test", "two test", true), //
+ new FieldGetSetTestData<Object>(true, "three test", "three test", true)//
+ )});//
+
+ data.add(new Object[] { //
+ new OseeFieldTestData<Integer>(new OseeField<Integer>(), //
+ null, false, //
+ new FieldGetSetTestData<Integer>(true, 1, 1, true), //
+ new FieldGetSetTestData<Integer>(false, 5, 5, true), //
+ new FieldGetSetTestData<Integer>(true, Integer.MIN_VALUE, Integer.MIN_VALUE, true)//
+ )});
+
+ data.add(new Object[] { //
+ new OseeFieldTestData<Boolean>(new OseeField<Boolean>(), //
+ null, false, //
+ new FieldGetSetTestData<Boolean>(true, true, true, true), //
+ new FieldGetSetTestData<Boolean>(false, true, true, true), //
+ new FieldGetSetTestData<Boolean>(true, false, false, true),//
+ new FieldGetSetTestData<Boolean>(false, false, false, true)//
+ )});
+
+ data.add(new Object[] {new OseeFieldTestData<Object>(new OseeField<Object>("string1"), "string1", true)});
+ data.add(new Object[] {new OseeFieldTestData<Integer>(new OseeField<Integer>(Integer.MIN_VALUE),
+ Integer.MIN_VALUE, true)});
+ data.add(new Object[] {new OseeFieldTestData<Boolean>(new OseeField<Boolean>(true), true, true)});
+ data.add(new Object[] {new OseeFieldTestData<Boolean>(new OseeField<Boolean>(false), false, true)});
+
+ data.add(new Object[] {//
+ new OseeFieldTestData<String>(new OseeField<String>("string2"), "string2", true, //
+ new FieldGetSetTestData<String>(false, "another", "another", true), //
+ new FieldGetSetTestData<String>(true, "something", "something", true)//
+ )});
+
+ // IOseeTypeFactory factory = new OseeTypeFactory();
+ // data.add(createAssociatedArtifactTest(factory));
+ return data;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BranchAliasesFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BranchAliasesFieldTest.java
new file mode 100644
index 0000000000..0fba8e7f3a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/BranchAliasesFieldTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.internal.fields.BranchAliasesField;
+import org.junit.Test;
+
+/**
+ * Test Case For {@link BranchAliasesField}
+ *
+ * @author Roberto E. Escobar
+ */
+public class BranchAliasesFieldTest {
+
+ @Test
+ public void testSetGet() throws OseeCoreException {
+ Collection<String> aliases = new ArrayList<String>();
+ BranchAliasesField field = new BranchAliasesField(aliases);
+ Assert.assertEquals(false, field.isDirty());
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList("A", "B", "C"), Arrays.asList("a", "b", "c"), true);
+ field.clearDirty();
+ Assert.assertEquals(false, field.isDirty());
+
+ // Same but with changed order and case
+ FieldTestUtil.assertSetGet(field, Arrays.asList("C", "a", "b"), Arrays.asList("a", "b", "c"), false);
+ Assert.assertEquals(false, field.isDirty());
+
+ // Remove two
+ FieldTestUtil.assertSetGet(field, Arrays.asList("C"), Arrays.asList("c"), true);
+ field.clearDirty();
+
+ // Add
+ FieldTestUtil.assertSetGet(field, Arrays.asList("C", "WhaT!21", "AgAin"), Arrays.asList("c", "what!21", "again"),
+ true);
+ field.clearDirty();
+
+ // Add Empty
+ FieldTestUtil.assertSetGet(field, Collections.<String> emptyList(), Collections.<String> emptyList(), true);
+ field.clearDirty();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/CollectionFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/CollectionFieldTest.java
new file mode 100644
index 0000000000..f4ced1efe6
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/CollectionFieldTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.internal.fields.CollectionField;
+import org.junit.Test;
+
+/**
+ * author Roberto E. Escobar
+ */
+public class CollectionFieldTest {
+
+ @Test
+ public void testSetGetString() throws OseeCoreException {
+ List<String> values = new ArrayList<String>();
+ CollectionField<String> field = new CollectionField<String>(values);
+ Assert.assertFalse(field.isDirty());
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList("a", "b", "c"), Arrays.asList("a", "b", "c"), true);
+ field.clearDirty();
+
+ // Test order doesn't matter
+ FieldTestUtil.assertSetGet(field, Arrays.asList("b", "c", "a"), Arrays.asList("a", "b", "c"), false);
+
+ // Test remove one
+ FieldTestUtil.assertSetGet(field, Arrays.asList("a", "b"), Arrays.asList("a", "b"), true);
+ field.clearDirty();
+
+ // Test add one
+ FieldTestUtil.assertSetGet(field, Arrays.asList("a", "b", "d"), Arrays.asList("a", "b", "d"), true);
+ field.clearDirty();
+
+ // Add Empty
+ FieldTestUtil.assertSetGet(field, Collections.<String> emptyList(), Collections.<String> emptyList(), true);
+ field.clearDirty();
+ }
+
+ @Test
+ public void testSetGetInteger() throws OseeCoreException {
+ List<Integer> values = new ArrayList<Integer>();
+ CollectionField<Integer> field = new CollectionField<Integer>(values);
+ Assert.assertFalse(field.isDirty());
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList(1, 2, 3), Arrays.asList(1, 2, 3), true);
+ field.clearDirty();
+
+ // Test order doesn't matter
+ FieldTestUtil.assertSetGet(field, Arrays.asList(2, 3, 1), Arrays.asList(1, 2, 3), false);
+
+ // Test remove one
+ FieldTestUtil.assertSetGet(field, Arrays.asList(1, 2), Arrays.asList(1, 2), true);
+ field.clearDirty();
+
+ // Test add
+ FieldTestUtil.assertSetGet(field, Arrays.asList(1, 2, 4, 5), Arrays.asList(1, 2, 4, 5), true);
+ field.clearDirty();
+
+ // Add Empty
+ FieldTestUtil.assertSetGet(field, Collections.<Integer> emptyList(), Collections.<Integer> emptyList(), true);
+ field.clearDirty();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/EnumEntryFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/EnumEntryFieldTest.java
new file mode 100644
index 0000000000..45d78b702d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/EnumEntryFieldTest.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.OseeEnumEntry;
+import org.eclipse.osee.framework.core.model.internal.fields.EnumEntryField;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case For {@link EnumEntryField}
+ *
+ * @author Roberto E. Escobar
+ */
+public class EnumEntryFieldTest {
+
+ private static OseeEnumEntry e1;
+ private static OseeEnumEntry e2;
+ private static OseeEnumEntry e3;
+ private static OseeEnumEntry e4;
+
+ @BeforeClass
+ public static void prepareTest() {
+ e1 = MockDataFactory.createEnumEntry(1);
+ e2 = MockDataFactory.createEnumEntry(2);
+ e3 = MockDataFactory.createEnumEntry(3);
+ e4 = MockDataFactory.createEnumEntry(4);
+ }
+
+ @Test
+ public void testSetGet() throws OseeCoreException {
+ Collection<OseeEnumEntry> enumEntries = new ArrayList<OseeEnumEntry>();
+ EnumEntryField field = new EnumEntryField(enumEntries);
+ Assert.assertEquals(false, field.isDirty());
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList(e1, e2, e3), Arrays.asList(e1, e2, e3), true);
+ field.clearDirty();
+ Assert.assertEquals(false, field.isDirty());
+
+ // Same but with changed order and case
+ FieldTestUtil.assertSetGet(field, Arrays.asList(e3, e1, e2), Arrays.asList(e1, e2, e3), false);
+ Assert.assertEquals(false, field.isDirty());
+
+ // Remove two
+ FieldTestUtil.assertSetGet(field, Arrays.asList(e3), Arrays.asList(e3), true);
+ field.clearDirty();
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList(e3, e4, e2), Arrays.asList(e3, e4, e2), true);
+ field.clearDirty();
+
+ // Add Empty
+ FieldTestUtil.assertSetGet(field, Collections.<OseeEnumEntry> emptyList(),
+ Collections.<OseeEnumEntry> emptyList(), true);
+ field.clearDirty();
+ }
+
+ @Test
+ public void testEnumEntryDirtyOrdinal() throws OseeCoreException {
+ Collection<OseeEnumEntry> enumEntries = new ArrayList<OseeEnumEntry>();
+ EnumEntryField field = new EnumEntryField(enumEntries);
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList(e1, e2, e3), Arrays.asList(e1, e2, e3), true);
+ field.clearDirty();
+
+ e1.setOrdinal(4);
+ Assert.assertEquals(true, e1.isDirty());
+ Assert.assertEquals(true, field.isDirty());
+
+ field.clearDirty();
+ Assert.assertEquals(false, field.isDirty());
+ Assert.assertEquals(false, e1.isDirty());
+ }
+
+ @Test
+ public void testEnumEntryDirtyName() throws OseeCoreException {
+ Collection<OseeEnumEntry> enumEntries = new ArrayList<OseeEnumEntry>();
+ EnumEntryField field = new EnumEntryField(enumEntries);
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList(e1, e2, e3), Arrays.asList(e1, e2, e3), true);
+ field.clearDirty();
+
+ e3.setName(GUID.create());
+ Assert.assertEquals(true, e3.isDirty());
+ Assert.assertEquals(true, field.isDirty());
+
+ field.clearDirty();
+ Assert.assertEquals(false, field.isDirty());
+ Assert.assertEquals(false, e3.isDirty());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testEnumEntryNameUniqueness() throws OseeCoreException {
+ Collection<OseeEnumEntry> enumEntries = new ArrayList<OseeEnumEntry>();
+ EnumEntryField field = new EnumEntryField(enumEntries);
+
+ FieldTestUtil.assertSetGet(field, Arrays.asList(e1, e2, e3), Arrays.asList(e1, e2, e3), true);
+ field.clearDirty();
+
+ OseeEnumEntry eX = MockDataFactory.createEnumEntry(1);
+ field.set(Arrays.asList(e1, e2, e3, eX));
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testEnumEntryOrdinalUniqueness() throws OseeCoreException {
+ Collection<OseeEnumEntry> enumEntries = new ArrayList<OseeEnumEntry>();
+ enumEntries.add(e1);
+ enumEntries.add(e2);
+ EnumEntryField field = new EnumEntryField(enumEntries);
+
+ OseeEnumEntry eX = MockDataFactory.createEnumEntry(1);
+ eX.setName("hello");
+ eX.setOrdinal(e1.ordinal());
+ field.set(Arrays.asList(e1, e2, eX));
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testEnumEntryNullName() throws OseeCoreException {
+ EnumEntryField field = new EnumEntryField(Collections.<OseeEnumEntry> emptyList());
+ OseeEnumEntry eX = MockDataFactory.createEnumEntry(1);
+ eX.setName(null);
+ eX.setOrdinal(5);
+ field.set(Collections.singleton(eX));
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testEnumEntryNegativeOrdinal() throws OseeCoreException {
+ EnumEntryField field = new EnumEntryField(Collections.<OseeEnumEntry> emptyList());
+ OseeEnumEntry eX = MockDataFactory.createEnumEntry(1);
+ eX.setName("not empty");
+ eX.setOrdinal(-1);
+ field.set(Collections.singleton(eX));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldGetSetTestData.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldGetSetTestData.java
new file mode 100644
index 0000000000..0e08772472
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldGetSetTestData.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class FieldGetSetTestData<T> {
+ private final T setValue;
+ private final T expectedValue;
+ private final boolean expectedDirty;
+ private final boolean clearBeforeRun;
+ private final Class<? extends Throwable> error;
+
+ public FieldGetSetTestData(boolean clearBeforeRun, T setValue, T expectedValue, boolean expectedDirty, Class<? extends Throwable> error) {
+ this.clearBeforeRun = clearBeforeRun;
+ this.setValue = setValue;
+ this.expectedValue = expectedValue;
+ this.expectedDirty = expectedDirty;
+ this.error = error;
+ }
+
+ public FieldGetSetTestData(boolean clearBeforeRun, T setValue, T expectedValue, boolean expectedDirty) {
+ this(clearBeforeRun, setValue, expectedValue, expectedDirty, null);
+ }
+
+ public boolean isClearBeforeRun() {
+ return clearBeforeRun;
+ }
+
+ public T getSetValue() {
+ return setValue;
+ }
+
+ public T getExpectedValue() {
+ return expectedValue;
+ }
+
+ public boolean isExpectedDirty() {
+ return expectedDirty;
+ }
+
+ public boolean throwsError() {
+ return getError() != null;
+ }
+
+ public Class<? extends Throwable> getError() {
+ return error;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestSuite.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestSuite.java
new file mode 100644
index 0000000000..8f8e1a900f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestSuite.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {//
+ArtifactSuperTypeFieldTest.class, //
+ ArtifactTypeAttributesFieldTest.class, //
+ AssociatedArtifactFieldTest.class, //
+ BranchAliasesFieldTest.class, //
+ CollectionFieldTest.class, //
+ EnumEntryFieldTest.class, //
+ OseeFieldMainTest.class, //
+ UniqueIdFieldTest.class, //
+})
+/**
+ * @author Roberto E. Escobar
+ */
+public class FieldTestSuite {
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestUtil.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestUtil.java
new file mode 100644
index 0000000000..afb35de7ee
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/FieldTestUtil.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.internal.fields.CollectionField;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class FieldTestUtil {
+
+ private FieldTestUtil() {
+ }
+
+ public static <T> void assertSetGet(CollectionField<T> field, List<T> setValues, List<T> expected, boolean expectedDirty) throws OseeCoreException {
+ field.set(setValues);
+ Assert.assertEquals(expectedDirty, field.isDirty());
+
+ List<T> actual = new ArrayList<T>(field.get());
+ Assert.assertEquals(expected.size(), actual.size());
+ Assert.assertTrue(Collections.setComplement(actual, expected).isEmpty());
+ Assert.assertTrue(Collections.setComplement(expected, actual).isEmpty());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldMainTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldMainTest.java
new file mode 100644
index 0000000000..ba76446e1b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldMainTest.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.internal.fields.OseeField;
+import org.eclipse.osee.framework.jdk.core.util.Compare;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Parameterized.class)
+public class OseeFieldMainTest {
+ private final OseeFieldTestData<?> test;
+
+ public OseeFieldMainTest(OseeFieldTestData<?> test) {
+ this.test = test;
+ }
+
+ @Test
+ public void testInitialValues() throws OseeCoreException {
+ String message = "InitTest";
+ checkObjects(message, test.getInitExpectedValue(), test.getField().get());
+ Assert.assertEquals(message, test.isInitExpectedDirty(), test.getField().isDirty());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testSettterGetter() throws OseeCoreException {
+ int index = 0;
+ for (FieldGetSetTestData testData : test.getTestDatas()) {
+ String message = String.format("Test Data [%s]", ++index);
+ if (testData.isClearBeforeRun()) {
+ test.getField().clearDirty();
+ Assert.assertFalse(message, test.getField().isDirty());
+ }
+
+ if (testData.throwsError()) {
+ try {
+ test.doSetValue(testData);
+ Assert.assertNull(message, "This line should never be executed");
+ } catch (Exception ex) {
+ Class<?> clazz = testData.getError();
+ Assert.assertTrue(message, ex.getClass().isAssignableFrom(clazz));
+ }
+ } else {
+ test.doSetValue(testData);
+ }
+
+ checkObjects(message, testData.getExpectedValue(), test.getField().get());
+ Assert.assertEquals(message, testData.isExpectedDirty(), test.getField().isDirty());
+ }
+ }
+
+ private void checkObjects(String message, Object expected, Object actual) {
+ Assert.assertFalse(String.format("%s expected[%s] actual[%s]", message, expected, actual),
+ Compare.isDifferent(expected, actual));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Parameters
+ public static Collection<Object[]> data() throws OseeCoreException {
+ Collection<Object[]> data = new ArrayList<Object[]>();
+
+ data.add(new Object[] {//
+ new OseeFieldTestData<Object>(new OseeField<Object>(), //
+ null, false, //
+ new FieldGetSetTestData<Object>(true, "one test", "one test", true), //
+ new FieldGetSetTestData<Object>(false, "two test", "two test", true), //
+ new FieldGetSetTestData<Object>(true, "three test", "three test", true)//
+ )});//
+
+ data.add(new Object[] { //
+ new OseeFieldTestData<Integer>(new OseeField<Integer>(), //
+ null, false, //
+ new FieldGetSetTestData<Integer>(true, 1, 1, true), //
+ new FieldGetSetTestData<Integer>(false, 5, 5, true), //
+ new FieldGetSetTestData<Integer>(true, Integer.MIN_VALUE, Integer.MIN_VALUE, true)//
+ )});
+
+ data.add(new Object[] { //
+ new OseeFieldTestData<Boolean>(new OseeField<Boolean>(), //
+ null, false, //
+ new FieldGetSetTestData<Boolean>(true, true, true, true), //
+ new FieldGetSetTestData<Boolean>(false, true, true, true), //
+ new FieldGetSetTestData<Boolean>(true, false, false, true),//
+ new FieldGetSetTestData<Boolean>(false, false, false, true)//
+ )});
+
+ data.add(new Object[] {new OseeFieldTestData<Object>(new OseeField<Object>("string1"), "string1", true)});
+ data.add(new Object[] {new OseeFieldTestData<Integer>(new OseeField<Integer>(Integer.MIN_VALUE),
+ Integer.MIN_VALUE, true)});
+ data.add(new Object[] {new OseeFieldTestData<Boolean>(new OseeField<Boolean>(true), true, true)});
+ data.add(new Object[] {new OseeFieldTestData<Boolean>(new OseeField<Boolean>(false), false, true)});
+
+ data.add(new Object[] {//
+ new OseeFieldTestData<String>(new OseeField<String>("string2"), "string2", true, //
+ new FieldGetSetTestData<String>(false, "another", "another", true), //
+ new FieldGetSetTestData<String>(true, "something", "something", true)//
+ )});
+ return data;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldTestData.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldTestData.java
new file mode 100644
index 0000000000..1d0042ef7a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/OseeFieldTestData.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.internal.fields.IOseeField;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OseeFieldTestData<T> {
+ private final IOseeField<T> field;
+ private final Object initExpectedValue;
+ private final boolean initExpectedDirty;
+
+ private final Collection<FieldGetSetTestData<T>> testDatas;
+
+ public OseeFieldTestData(IOseeField<T> field, Object initExpectedValue, boolean initExpectedDirty, FieldGetSetTestData<T>... testDatas) {
+ this.field = field;
+ this.initExpectedValue = initExpectedValue;
+ this.initExpectedDirty = initExpectedDirty;
+ this.testDatas = new ArrayList<FieldGetSetTestData<T>>();
+ if (testDatas != null && testDatas.length > 0) {
+ this.testDatas.addAll(Arrays.asList(testDatas));
+ }
+ }
+
+ public IOseeField<T> getField() {
+ return field;
+ }
+
+ public Object getInitExpectedValue() {
+ return initExpectedValue;
+ }
+
+ public boolean isInitExpectedDirty() {
+ return initExpectedDirty;
+ }
+
+ public Collection<FieldGetSetTestData<T>> getTestDatas() {
+ return testDatas;
+ }
+
+ public void doSetValue(FieldGetSetTestData<T> testData) throws OseeCoreException {
+ getField().set(testData.getSetValue());
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/UniqueIdFieldTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/UniqueIdFieldTest.java
new file mode 100644
index 0000000000..9cf45c1987
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/fields/UniqueIdFieldTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.fields;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.model.IOseeStorable;
+import org.eclipse.osee.framework.core.model.internal.fields.UniqueIdField;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test Case For {@link UniqueIdField}
+ *
+ * @author Roberto E. Escobar
+ */
+@RunWith(Parameterized.class)
+public class UniqueIdFieldTest extends BaseOseeFieldTest {
+
+ public UniqueIdFieldTest(OseeFieldTestData<?> test) {
+ super(test);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Parameters
+ public static Collection<Object[]> data() throws OseeCoreException {
+ Collection<Object[]> data = new ArrayList<Object[]>();
+ data.add(new Object[] {new OseeFieldTestData<Integer>(new UniqueIdField(), //
+ IOseeStorable.UNPERSISTED_VALUE, true, //
+ new FieldGetSetTestData<Integer>(false, IOseeStorable.UNPERSISTED_VALUE,
+ IOseeStorable.UNPERSISTED_VALUE, true), //
+ new FieldGetSetTestData<Integer>(true, IOseeStorable.UNPERSISTED_VALUE,
+ IOseeStorable.UNPERSISTED_VALUE, false), //
+ new FieldGetSetTestData<Integer>(false, 100, 100, true), //
+ new FieldGetSetTestData<Integer>(false, 200, 100, true, OseeStateException.class),//
+ new FieldGetSetTestData<Integer>(true, 300, 100, false, OseeStateException.class)//
+ )});
+ return data;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockAbstractOseeType.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockAbstractOseeType.java
new file mode 100644
index 0000000000..a35bf9ed7d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockAbstractOseeType.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.mocks;
+
+import org.eclipse.osee.framework.core.model.AbstractOseeType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockAbstractOseeType extends AbstractOseeType {
+
+ public MockAbstractOseeType(String guid, String name) {
+ super(guid, name);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockDataFactory.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockDataFactory.java
new file mode 100644
index 0000000000..b07f807d5e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockDataFactory.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.mocks;
+
+import java.util.Date;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
+import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.BranchFactory;
+import org.eclipse.osee.framework.core.model.DefaultBasicArtifact;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.OseeCachingService;
+import org.eclipse.osee.framework.core.model.OseeEnumEntry;
+import org.eclipse.osee.framework.core.model.OseeModelFactoryService;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
+import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
+import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
+import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.core.model.type.ArtifactTypeFactory;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
+import org.eclipse.osee.framework.core.model.type.OseeEnumType;
+import org.eclipse.osee.framework.core.model.type.OseeEnumTypeFactory;
+import org.eclipse.osee.framework.core.model.type.RelationType;
+import org.eclipse.osee.framework.core.model.type.RelationTypeFactory;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.core.services.IOseeCachingServiceProvider;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class MockDataFactory {
+
+ private MockDataFactory() {
+ }
+
+ public static IBasicArtifact<?> createArtifact(int index) {
+ return new DefaultBasicArtifact(index * 37, GUID.create(), "user_" + index);
+ }
+
+ public static AttributeType createAttributeType() throws OseeCoreException {
+ OseeEnumTypeFactory oseeEnumTypeFactory = new OseeEnumTypeFactory();
+ AttributeType attributeType =
+ new AttributeType(GUID.create(), "name", "baseType", "providerName", ".xml", "", 1, 1, "description",
+ "tagger");
+ attributeType.setOseeEnumType(oseeEnumTypeFactory.createEnumType(GUID.create(), "enum type name"));
+ return attributeType;
+ }
+
+ public static Branch createBranch(int index) {
+ BranchState branchState = BranchState.values()[Math.abs(index % BranchState.values().length)];
+ BranchType branchType = BranchType.values()[Math.abs(index % BranchType.values().length)];
+ boolean isArchived = index % 2 == 0 ? true : false;
+ return new Branch(GUID.create(), "branch_" + index, branchType, branchState, isArchived);
+ }
+
+ public static TransactionRecord createTransaction(int index, int branchId) {
+ TransactionDetailsType type =
+ TransactionDetailsType.values()[Math.abs(index % TransactionDetailsType.values().length)];
+ int value = index;
+ if (value == 0) {
+ value++;
+ }
+ return new TransactionRecord(value * 47, branchId, "comment_" + value, new Date(), value * 37, value * 42, type);
+ }
+
+ public static OseeEnumEntry createEnumEntry(int index) {
+ return new OseeEnumEntry(GUID.create(), "entry_" + index, Math.abs(index * 37));
+ }
+
+ public static OseeEnumType createEnumType(int index) {
+ return new OseeEnumType(GUID.create(), "enum_" + index);
+ }
+
+ public static AttributeType createAttributeType(int index, OseeEnumType oseeEnumType) throws OseeCoreException {
+ AttributeType type =
+ new AttributeType(GUID.create(), "attrType_" + index, "baseClass_" + index, "providerId_" + index,
+ "ext_" + index, "default_" + index, index * 2, index * 7, "description_" + index, "tag_" + index);
+ type.setOseeEnumType(oseeEnumType);
+ return type;
+ }
+
+ public static ArtifactType createArtifactType(int index) {
+ return new ArtifactType(GUID.create(), "art_" + index, index % 2 == 0);
+ }
+
+ public static ArtifactType createBaseArtifactType() {
+ IArtifactType baseType = CoreArtifactTypes.Artifact;
+ return new ArtifactType(baseType.getGuid(), baseType.getName(), true);
+ }
+
+ public static RelationType createRelationType(int index, ArtifactType artTypeA, ArtifactType artTypeB) {
+ RelationTypeMultiplicity multiplicity =
+ RelationTypeMultiplicity.values()[Math.abs(index % RelationTypeMultiplicity.values().length)];
+ String order = RelationOrderBaseTypes.values[index % RelationTypeMultiplicity.values().length].getGuid();
+ return new RelationType(GUID.create(), "relType_" + index, "sideA_" + index, "sideB_" + index, artTypeA,
+ artTypeB, multiplicity, order);
+ }
+
+ public static IOseeModelFactoryService createFactoryService() {
+ return new OseeModelFactoryService(new BranchFactory(), new TransactionRecordFactory(),
+ new ArtifactTypeFactory(), new AttributeTypeFactory(), new RelationTypeFactory(), new OseeEnumTypeFactory());
+ }
+
+ public static IOseeCachingServiceProvider createCachingProvider() {
+ BranchCache brCache = new BranchCache(new MockOseeDataAccessor<Branch>());
+ TransactionCache txCache = new TransactionCache();
+ txCache.setAccessor(new MockOseeTransactionDataAccessor());
+ ArtifactTypeCache artCache = new ArtifactTypeCache(new MockOseeDataAccessor<ArtifactType>());
+ AttributeTypeCache attrCache = new AttributeTypeCache(new MockOseeDataAccessor<AttributeType>());
+ RelationTypeCache relCache = new RelationTypeCache(new MockOseeDataAccessor<RelationType>());
+ OseeEnumTypeCache enumCache = new OseeEnumTypeCache(new MockOseeDataAccessor<OseeEnumType>());
+
+ IOseeCachingService service = new OseeCachingService(brCache, txCache, artCache, attrCache, relCache, enumCache);
+ return new MockOseeCachingServiceProvider(service);
+ }
+
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeCachingServiceProvider.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeCachingServiceProvider.java
new file mode 100644
index 0000000000..29ab5a5712
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeCachingServiceProvider.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.mocks;
+
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.core.services.IOseeCachingServiceProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockOseeCachingServiceProvider implements IOseeCachingServiceProvider {
+
+ private final IOseeCachingService service;
+
+ public MockOseeCachingServiceProvider(IOseeCachingService service) {
+ this.service = service;
+ }
+
+ @Override
+ public IOseeCachingService getOseeCachingService() {
+ return service;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeDataAccessor.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeDataAccessor.java
new file mode 100644
index 0000000000..051eb37185
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeDataAccessor.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.mocks;
+
+import java.util.Collection;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IOseeStorable;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockOseeDataAccessor<T extends IOseeStorable> implements IOseeDataAccessor<T> {
+
+ private boolean wasLoadCalled = false;
+ private boolean wasStoreCalled = false;
+
+ public void setLoadCalled(boolean wasLoadCalled) {
+ this.wasLoadCalled = wasLoadCalled;
+ }
+
+ public void setStoreCalled(boolean wasStoreCalled) {
+ this.wasStoreCalled = wasStoreCalled;
+ }
+
+ public boolean wasLoaded() {
+ return wasLoadCalled;
+ }
+
+ public boolean wasStoreCalled() {
+ return wasStoreCalled;
+ }
+
+ @Override
+ public void load(IOseeCache<T> cache) throws OseeCoreException {
+ Assert.assertNotNull(cache);
+ setLoadCalled(true);
+ }
+
+ @Override
+ public void store(Collection<T> types) throws OseeCoreException {
+ Assert.assertNotNull(types);
+ setStoreCalled(true);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeTransactionDataAccessor.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeTransactionDataAccessor.java
new file mode 100644
index 0000000000..5341fcdf41
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockOseeTransactionDataAccessor.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.mocks;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.enums.TransactionVersion;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.core.model.cache.ITransactionDataAccessor;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockOseeTransactionDataAccessor implements ITransactionDataAccessor {
+
+ private boolean wasLoadCalled = false;
+ private boolean wasStoreCalled = false;
+
+ public void setLoadCalled(boolean wasLoadCalled) {
+ this.wasLoadCalled = wasLoadCalled;
+ }
+
+ public void setStoreCalled(boolean wasStoreCalled) {
+ this.wasStoreCalled = wasStoreCalled;
+ }
+
+ public boolean wasLoaded() {
+ return wasLoadCalled;
+ }
+
+ public boolean wasStoreCalled() {
+ return wasStoreCalled;
+ }
+
+ // @Override
+ // public void load(AbstractOseeCache<T> cache) throws OseeCoreException {
+ // Assert.assertNotNull(cache);
+ // setLoadCalled(true);
+ // }
+ //
+ // @Override
+ // public void store(Collection<T> types) throws OseeCoreException {
+ // Assert.assertNotNull(types);
+ // setStoreCalled(true);
+ // }
+
+ @Override
+ public void loadTransactionRecord(TransactionCache cache, Collection<Integer> transactionIds) throws OseeCoreException {
+ wasLoadCalled = true;
+ }
+
+ @Override
+ public void loadTransactionRecord(TransactionCache cache, Branch branch) throws OseeCoreException {
+ }
+
+ @Override
+ public TransactionRecord loadTransactionRecord(TransactionCache cache, Branch branch, TransactionVersion transactionType) throws OseeCoreException {
+ return null;
+ }
+
+ @Override
+ public void load(TransactionCache transactionCache) throws OseeCoreException {
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/ModelAsserts.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/ModelAsserts.java
new file mode 100644
index 0000000000..c441ebe9c7
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/ModelAsserts.java
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.mocks;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.enums.RelationSide;
+import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.MergeBranch;
+import org.eclipse.osee.framework.core.model.OseeEnumEntry;
+import org.eclipse.osee.framework.core.model.cache.AbstractOseeCache;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeTypeFactory;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.core.model.type.OseeEnumType;
+import org.eclipse.osee.framework.core.model.type.RelationType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ModelAsserts {
+
+ private ModelAsserts() {
+
+ }
+
+ public static void createAlias(BranchCache cache, String branchGuid, String... aliases) throws OseeCoreException {
+ Branch branch = cache.getByGuid(branchGuid);
+ Assert.assertNotNull(branch);
+ // cache.setAliases(branch, Arrays.asList(aliases));
+ }
+
+ public static void checkMergeBranch(BranchCache cache, String expectedMergeBranchGuid, String sourceBranchGuid, String destinationBranchGuid) throws OseeCoreException {
+ Branch sourceBranch = cache.getByGuid(sourceBranchGuid);
+ Assert.assertNotNull(sourceBranch);
+ Branch destionationBranch = cache.getByGuid(destinationBranchGuid);
+ Assert.assertNotNull(destionationBranch);
+
+ Branch actualMergeBranch = cache.findMergeBranch(sourceBranch, destionationBranch);
+ if (expectedMergeBranchGuid == null) {
+ Assert.assertNull(actualMergeBranch);
+ } else {
+ Branch mergeBranch = cache.getByGuid(expectedMergeBranchGuid);
+ Assert.assertNotNull(mergeBranch);
+ Assert.assertEquals(mergeBranch, actualMergeBranch);
+ }
+ }
+
+ public static void createMergeBranch(BranchCache cache, String mergeBranchGuid, String sourceBranchGuid, String destinationBranchGuid) throws OseeCoreException {
+ Branch mergeBranch = cache.getByGuid(mergeBranchGuid);
+ Assert.assertNotNull(mergeBranch);
+ Branch sourceBranch = cache.getByGuid(sourceBranchGuid);
+ Assert.assertNotNull(sourceBranch);
+ Branch destionationBranch = cache.getByGuid(destinationBranchGuid);
+ Assert.assertNotNull(destionationBranch);
+ Assert.assertTrue(mergeBranch instanceof MergeBranch);
+ MergeBranch mBranch = (MergeBranch) mergeBranch;
+ mBranch.setSourceBranch(sourceBranch);
+ mBranch.setDestinationBranch(destionationBranch);
+ }
+
+ public static void checkHierarchy(BranchCache cache, String parentGuid, String... expected) throws OseeCoreException {
+ Branch parentBranch = cache.getByGuid(parentGuid);
+ Assert.assertNotNull(parentBranch);
+ Collection<Branch> children = parentBranch.getChildren();
+ Assert.assertEquals(expected.length, children.size());
+ int index = 0;
+ for (Branch child : children) {
+ Branch expectedBranch = cache.getByGuid(expected[index]);
+ Assert.assertNotNull(expectedBranch);
+ Assert.assertEquals(expectedBranch, child);
+ Assert.assertEquals(parentBranch, child.getParentBranch());
+ index++;
+ }
+ }
+
+ public static void createBranchHierarchy(BranchCache cache, String parentGuid, String... childrenGuids) throws OseeCoreException {
+ Branch parentBranch = cache.getByGuid(parentGuid);
+ Assert.assertNotNull(parentBranch);
+ Assert.assertNotNull(childrenGuids);
+ Assert.assertTrue(childrenGuids.length > 0);
+ for (String childGuid : childrenGuids) {
+ Branch childBranch = cache.getByGuid(childGuid);
+ Assert.assertNotNull(childBranch);
+ childBranch.setParentBranch(parentBranch);
+ }
+ }
+
+ public static RelationType createRelationType(AbstractOseeCache<ArtifactType> artCache, String guid, String name, String aGUID, String bGUID, RelationTypeMultiplicity multiplicity) throws OseeCoreException {
+ ArtifactType type1 = artCache.getByGuid(aGUID);
+ ArtifactType type2 = artCache.getByGuid(bGUID);
+ RelationType relationType =
+ new RelationType(guid, name, name + "_A", name + "_B", type1, type2, multiplicity, "");
+ Assert.assertNotNull(relationType);
+ return relationType;
+ }
+
+ public static Branch createBranch(String guid, String name, BranchType branchType, BranchState branchState, boolean isArchived) throws OseeCoreException {
+ Branch branch;
+ if (branchType.isMergeBranch()) {
+ branch = new MergeBranch(guid, name, branchType, branchState, isArchived);
+ } else {
+ branch = new Branch(guid, name, branchType, branchState, isArchived);
+ }
+ Assert.assertNotNull(branch);
+ return branch;
+ }
+
+ public static AttributeType createAttributeType(String guid, String name) throws OseeCoreException {
+ AttributeType attributeType =
+ new AttributeType(guid, name, "DummyBase", "DummyProvider", "none", "none", 1, 1, "test data", null);
+ Assert.assertNotNull(attributeType);
+ return attributeType;
+ }
+
+ public static void checkOseeEnumEntries(OseeEnumEntry[] actual, Object... entries) {
+ Assert.assertEquals(entries.length / 2, actual.length);
+ int index2 = 0;
+ for (int index = 0; index < entries.length; index++, index2++) {
+ String itemName = (String) entries[index];
+ Integer ordinal = (Integer) entries[++index];
+
+ Assert.assertEquals(itemName, actual[index2].getName());
+ Assert.assertEquals((int) ordinal, actual[index2].ordinal());
+ }
+ }
+
+ public static OseeEnumType createEnumType(IOseeTypeFactory factory, String guid, String name, Object... entries) throws OseeCoreException {
+ OseeEnumType type = new OseeEnumType(guid, name);
+ if (entries != null && entries.length > 0) {
+ List<OseeEnumEntry> items = new ArrayList<OseeEnumEntry>();
+ for (int index = 0; index < entries.length; index++) {
+ String itemName = (String) entries[index];
+ Integer ordinal = (Integer) entries[++index];
+ items.add(new OseeEnumEntry(null, itemName, ordinal));
+ }
+ type.setEntries(items);
+ }
+ return type;
+ }
+
+ public static void checkEnumType(String expectedName, String[] expectedEntries, Integer[] expectedOrdinals, OseeEnumType actualEnumType) throws OseeCoreException {
+ assertEquals(expectedName, actualEnumType.getName());
+ OseeEnumEntry[] enumEntries = actualEnumType.values();
+ assertEquals(expectedEntries.length, enumEntries.length);
+ for (int index = 0; index < expectedEntries.length && index < expectedOrdinals.length; index++) {
+ checkEnumEntry(expectedEntries[index], expectedOrdinals[index], actualEnumType, enumEntries[index]);
+ }
+ }
+
+ public static void checkEnumEntry(String expectedName, int expectedOrdinal, OseeEnumType parent, OseeEnumEntry entry) throws OseeCoreException {
+ assertEquals(expectedName, entry.getName());
+ assertEquals(expectedOrdinal, entry.ordinal());
+ // assertEquals(parent, entry.getDeclaringClass());
+ assertEquals(parent.getId(), entry.getId());
+ assertEquals(parent.getName(), entry.getName());
+ // OseeEnumEntry[] expected = parent.values();
+ // // OseeEnumEntry[] actual = entry.getDeclaringClass().values();
+ // assertEquals(expected.length, actual.length);
+ // for (int index = 0; index < expected.length; index++) {
+ // assertEquals(expected[index], actual[index]);
+ // }
+ }
+
+ public static void checkEnumType(OseeEnumType expected, OseeEnumType actual) throws OseeCoreException {
+ OseeEnumEntry[] expectedValues = expected.values();
+ OseeEnumEntry[] actualValues = actual.values();
+ Assert.assertEquals(expectedValues.length, actualValues.length);
+
+ for (int index = 0; index < expectedValues.length; index++) {
+ checkEnumEntry(expectedValues[index], actualValues[index]);
+ }
+ }
+
+ public static void checkEnumEntry(OseeEnumEntry expected, OseeEnumEntry actual) throws OseeCoreException {
+ Assert.assertEquals(expected.getName(), actual.getName());
+ Assert.assertEquals(expected.ordinal(), actual.ordinal());
+ // Assert.assertEquals(expected.getDeclaringClass(), actual.getDeclaringClass());
+ Assert.assertEquals(expected.getGuid(), actual.getGuid());
+ }
+
+ public static void checkInheritance(AbstractOseeCache<ArtifactType> artCache, String artTypeGuid, String... superTypeGuids) throws OseeCoreException {
+ ArtifactType target = artCache.getByGuid(artTypeGuid);
+ Assert.assertNotNull(target);
+
+ List<ArtifactType> expectedSuperTypes = new ArrayList<ArtifactType>();
+ for (String superTyperGuid : superTypeGuids) {
+ ArtifactType superArtifactType = artCache.getByGuid(superTyperGuid);
+ Assert.assertNotNull(superArtifactType);
+ expectedSuperTypes.add(superArtifactType);
+ }
+
+ for (ArtifactType testAgainstType : artCache.getAll()) {
+ boolean result = target.inheritsFrom(testAgainstType);
+ if (expectedSuperTypes.contains(testAgainstType) || target.equals(testAgainstType)) {
+ Assert.assertTrue(String.format("[%s] does not inherit from [%s]", target.getName(),
+ testAgainstType.getName()), result);
+ } else {
+ Assert.assertFalse(String.format("[%s] should not inherit from [%s]", target.getName(),
+ testAgainstType.getName()), result);
+ }
+ }
+ }
+
+ public static void checkDescendants(AbstractOseeCache<ArtifactType> artCache, String artTypeGuid, boolean isAllLevels, String... descendantGuids) throws OseeCoreException {
+ ArtifactType target = artCache.getByGuid(artTypeGuid);
+ Assert.assertNotNull(target);
+
+ List<ArtifactType> expectedDescendants = new ArrayList<ArtifactType>();
+ for (String type : descendantGuids) {
+ ArtifactType childType = artCache.getByGuid(type);
+ Assert.assertNotNull(childType);
+ expectedDescendants.add(childType);
+ }
+
+ Collection<ArtifactType> descendants =
+ isAllLevels ? target.getAllDescendantTypes() : target.getFirstLevelDescendantTypes();
+
+ Assert.assertEquals(expectedDescendants.size(), descendants.size());
+ for (ArtifactType child : descendants) {
+ boolean result = expectedDescendants.contains(target);
+ if (result) {
+ Assert.assertTrue(String.format("[%s] inherits from [%s]", child.getName(), target.getName()), result);
+ } else {
+ Assert.assertFalse(String.format("[%s] does not inherit from [%s]", child.getName(), target.getName()),
+ result);
+ }
+ if (target.hasSuperArtifactTypes()) {
+ Assert.assertEquals(true, child.inheritsFrom(target));
+ }
+ }
+ }
+
+ public static void checkAttributes(AbstractOseeCache<ArtifactType> artCache, AbstractOseeCache<AttributeType> attrCache, String artTypeGuid, Branch branch, String... attributeGuids) throws OseeCoreException {
+ ArtifactType artifactType = artCache.getByGuid(artTypeGuid);
+ Assert.assertNotNull(artifactType);
+
+ List<AttributeType> expectedAttributes = new ArrayList<AttributeType>();
+ for (String attrGuid : attributeGuids) {
+ AttributeType attributeType = attrCache.getByGuid(attrGuid);
+ Assert.assertNotNull(attributeType);
+ expectedAttributes.add(attributeType);
+ }
+
+ Collection<AttributeType> actualTypes = artifactType.getAttributeTypes(branch);
+ Assert.assertEquals(String.format("ArtifactType [%s] - incorrect number of attributes actual - %s expected - %s",
+ artTypeGuid, actualTypes, expectedAttributes), expectedAttributes.size(), actualTypes.size());
+
+ Collection<AttributeType> typesNotFound =
+ org.eclipse.osee.framework.jdk.core.util.Collections.setComplement(expectedAttributes, actualTypes);
+ Assert.assertTrue(String.format("Artifact [%s] for branch [%s] did not have the following attributes [%s]",
+ artifactType.getName(), branch.getName(), typesNotFound), typesNotFound.isEmpty());
+
+ typesNotFound =
+ org.eclipse.osee.framework.jdk.core.util.Collections.setComplement(actualTypes, expectedAttributes);
+ Assert.assertTrue(String.format("Artifact [%s] for branch [%s] the following additional attributes [%s]",
+ artifactType.getName(), branch.getName(), typesNotFound), typesNotFound.isEmpty());
+ }
+
+ public static void checkRelationTypeInheritance(AbstractOseeCache<RelationType> cache, AbstractOseeCache<ArtifactType> artCache, String relGuid, RelationSide relationSide, int maxValue, String... artifactTypesAllowed) throws OseeCoreException {
+ RelationType relationType = cache.getByGuid(relGuid);
+ Assert.assertNotNull(relationType);
+
+ Assert.assertEquals(maxValue, relationType.getMultiplicity().getLimit(relationSide));
+ Assert.assertEquals(maxValue == Integer.MAX_VALUE ? "n" : "1", relationType.getMultiplicity().asLimitLabel(
+ relationSide));
+
+ List<ArtifactType> allowedTypes = new ArrayList<ArtifactType>();
+ for (String guid : artifactTypesAllowed) {
+ ArtifactType type = artCache.getByGuid(guid);
+ Assert.assertNotNull(type);
+ allowedTypes.add(type);
+ }
+
+ for (ArtifactType artifactType : artCache.getAll()) {
+ boolean result = relationType.isArtifactTypeAllowed(relationSide, artifactType);
+ if (allowedTypes.contains(artifactType)) {
+ Assert.assertTrue(String.format("ArtifactType [%s] was not allowed", artifactType), result);
+ } else {
+ Assert.assertFalse(String.format("ArtifactType [%s] was allowed even though it should not have been",
+ artifactType), result);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AbstractOseeTypeTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AbstractOseeTypeTest.java
new file mode 100644
index 0000000000..96e4427a1c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AbstractOseeTypeTest.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.model.AbstractOseeType;
+import org.eclipse.osee.framework.core.model.IOseeStorable;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Test;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AbstractOseeTypeTest<T extends AbstractOseeType> {
+
+ private final T type;
+ private final String name;
+ private final String guid;
+
+ protected AbstractOseeTypeTest(T type, String guid, String name) {
+ this.type = type;
+ this.name = name;
+ this.guid = guid;
+ }
+
+ protected T getType() {
+ return type;
+ }
+
+ protected String getExpectedName() {
+ return name;
+ }
+
+ protected String getExpectedGuid() {
+ return guid;
+ }
+
+ @Test
+ public void testSetGetGuid() {
+ Assert.assertEquals(getExpectedGuid(), type.getGuid());
+ }
+
+ @Test
+ public void testGetId() {
+ Assert.assertEquals(IOseeStorable.UNPERSISTED_VALUE, Integer.valueOf(type.getId()));
+ }
+
+ @Test(expected = OseeStateException.class)
+ public void testSetGetId() throws OseeCoreException {
+ type.setId(Integer.MAX_VALUE);
+ Assert.assertEquals(Integer.MAX_VALUE, type.getId());
+
+ type.setId(Integer.MAX_VALUE - 1);
+ }
+
+ @Test
+ public void testSetGetName() throws OseeCoreException {
+ Assert.assertEquals(getExpectedName(), type.getName());
+ String originalName = type.getName();
+
+ type.clearDirty();
+ Assert.assertFalse(type.isDirty());
+ Assert.assertFalse(type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY));
+
+ // Check reassign doesn't mark as dirty
+ type.setName(originalName);
+ Assert.assertFalse(type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY));
+
+ String newName = GUID.create();
+ type.setName(newName);
+ Assert.assertEquals(newName, type.getName());
+
+ Assert.assertTrue(type.isDirty());
+ Assert.assertTrue(type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY));
+
+ type.clearDirty();
+ Assert.assertFalse(type.isDirty());
+ Assert.assertFalse(type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY));
+
+ type.setName(originalName);
+ type.clearDirty();
+ }
+
+ @Test
+ public void testSetGetModificationType() {
+ Assert.assertEquals(StorageState.LOADED, type.getStorageState());
+ Assert.assertFalse(type.isDirty());
+
+ type.setStorageState(StorageState.MODIFIED);
+ Assert.assertFalse(type.isDirty());
+ type.clearDirty();
+ Assert.assertFalse(type.isDirty());
+ Assert.assertEquals(StorageState.LOADED, type.getStorageState());
+
+ type.setStorageState(StorageState.PURGED);
+ Assert.assertFalse(type.isDirty());
+ type.clearDirty();
+ Assert.assertFalse(type.isDirty());
+ Assert.assertEquals(StorageState.PURGED, type.getStorageState());
+
+ type.setStorageState(StorageState.CREATED);
+ Assert.assertFalse(type.isDirty());
+ type.clearDirty();
+ Assert.assertFalse(type.isDirty());
+ Assert.assertEquals(StorageState.LOADED, type.getStorageState());
+ }
+
+ @Test
+ public void testToString() {
+ Assert.assertEquals(String.format("%s - [%s]", name, guid), type.toString());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ArtifactTypeTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ArtifactTypeTest.java
new file mode 100644
index 0000000000..9e4f834543
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ArtifactTypeTest.java
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test Case for {@link ArtifactType}
+ *
+ * @author Roberto E. Escobar
+ */
+@RunWith(Parameterized.class)
+public class ArtifactTypeTest extends AbstractOseeTypeTest<ArtifactType> {
+
+ private final boolean isAbstract;
+
+ public ArtifactTypeTest(ArtifactType type, String guid, String name, boolean isAbstract) {
+ super(type, guid, name);
+ this.isAbstract = isAbstract;
+ }
+
+ @Test
+ public void testSetGetIsAbstract() throws OseeCoreException {
+ Assert.assertEquals(isAbstract, getType().isAbstract());
+ getType().clearDirty();
+ Assert.assertFalse(getType().isDirty());
+ Assert.assertFalse(getType().areFieldsDirty(ArtifactType.ARTIFACT_IS_ABSTRACT_FIELD_KEY));
+
+ // Check assigning the same value does not affect dirty
+ getType().setAbstract(isAbstract);
+ Assert.assertFalse(getType().isDirty());
+ Assert.assertFalse(getType().areFieldsDirty(ArtifactType.ARTIFACT_IS_ABSTRACT_FIELD_KEY));
+
+ getType().setAbstract(!isAbstract);
+ Assert.assertEquals(!isAbstract, getType().isAbstract());
+ Assert.assertTrue(getType().isDirty());
+ Assert.assertTrue(getType().areFieldsDirty(ArtifactType.ARTIFACT_IS_ABSTRACT_FIELD_KEY));
+
+ getType().setAbstract(isAbstract);
+ getType().clearDirty();
+ }
+
+ @Ignore
+ @Test
+ public void test() {
+
+ // getType().compareTo(other);
+
+ // getType().getAttributeTypes(branch);
+ // getType().setAttributeTypes(attributeTypes, branch);
+
+ // getType().getFieldNames();
+
+ // getType().getFirstLevelDescendantTypes();
+ // getType().getAllDescendantTypes();
+
+ // getType().getLocalAttributeTypes();
+ // getType().getSuperArtifactTypes();
+
+ // getType().setSuperType(superType);
+ }
+
+ @Override
+ public void testToString() {
+ Assert.assertEquals(getExpectedName(), getType().toString());
+ }
+
+ @Parameters
+ public static Collection<Object[]> getData() {
+ Collection<Object[]> data = new ArrayList<Object[]>();
+ boolean isAbstract = true;
+ for (int index = 1; index <= 3; index++) {
+ String guid = GUID.create();
+ String name = "index: " + index;
+ isAbstract ^= isAbstract;
+ data.add(new Object[] {new ArtifactType(guid, name, isAbstract), guid, name, isAbstract});
+ }
+ return data;
+ }
+
+ // @Override
+ // @Ignore
+ // @Test
+ // public void testPersist() throws OseeCoreException {
+ //
+ // // T item1 = data.get(0);
+ // // T item2 = data.get(1);
+ // //
+ // // cache.storeByGuid(guids);
+ // // cache.storeItem(item);
+ // // cache.storeItems(toStore);
+ // // cache.storeItems(items);
+ // // public void storeItem(AbstractOseeType item) throws OseeCoreException {
+ //
+ // // public void storeItems(T... items) throws OseeCoreException {
+ //
+ // // public void storeItems(Collection<T> toStore) throws OseeCoreException {
+ // }
+
+ // @org.junit.Test
+ // public void testArtifactInheritanceCycleDetect() throws OseeCoreException {
+ // ArtifactType baseType = artCache.getUniqueByName("BaseArtifactType");
+ // Assert.assertNotNull(baseType);
+ //
+ // Set<ArtifactType> baseSuperType = new HashSet<ArtifactType>();
+ // baseSuperType.add(baseType);
+ //
+ // try {
+ // artCache.cacheArtifactSuperType(baseType, baseSuperType);
+ // Assert.assertTrue(
+ // "This line should not be execute, an inheritance cycle should have been detected and an exception should have been thrown",
+ // false);
+ // } catch (OseeInvalidInheritanceException ex) {
+ // Assert.assertNotNull(ex);
+ // }
+ // }
+ //
+ // @org.junit.Test
+ // public void testArtifactInheritance() throws OseeCoreException {
+ // OseeTypesUtil.checkInheritance(artCache, "000", "000");// inherits from returns true if comparing against itself
+ // OseeTypesUtil.checkInheritance(artCache, "111", "000");
+ // OseeTypesUtil.checkInheritance(artCache, "222", "000");
+ // OseeTypesUtil.checkInheritance(artCache, "333", "000", "222");
+ // OseeTypesUtil.checkInheritance(artCache, "444", "000", "222", "333");
+ // OseeTypesUtil.checkInheritance(artCache, "555", "000", "444", "333", "222");
+ // OseeTypesUtil.checkInheritance(artCache, "666", "000", "333", "222");
+ // }
+ //
+ // @org.junit.Test
+ // public void testArtifactInheritanceDescendants() throws OseeCoreException {
+ // OseeTypesUtil.checkDescendants(artCache, "000", false, "111", "222");
+ // OseeTypesUtil.checkDescendants(artCache, "000", true, "111", "222", "333", "444", "555", "666");
+ //
+ // OseeTypesUtil.checkDescendants(artCache, "111", false);
+ // OseeTypesUtil.checkDescendants(artCache, "111", true);
+ //
+ // OseeTypesUtil.checkDescendants(artCache, "222", false, "333");
+ // OseeTypesUtil.checkDescendants(artCache, "222", true, "333", "444", "555", "666");
+ //
+ // OseeTypesUtil.checkDescendants(artCache, "333", false, "333", "444");
+ // OseeTypesUtil.checkDescendants(artCache, "333", true, "444", "555", "666");
+ //
+ // OseeTypesUtil.checkDescendants(artCache, "444", false, "555");
+ // OseeTypesUtil.checkDescendants(artCache, "444", true, "555");
+ // }
+ //
+ // @org.junit.Test
+ // public void testNullArtifactInheritanceCheck() throws OseeCoreException {
+ // ArtifactType baseType = artCache.getUniqueByName("BaseArtifactType");
+ // // Check for null inheritance
+ // Assert.assertFalse(baseType.inheritsFrom((ArtifactType) null));
+ // }
+ //
+ // @org.junit.Test
+ // public void testArtifactInheritanceByName() throws OseeCoreException {
+ // Assert.assertTrue(artCache.getByGuid("666").inheritsFrom("ArtifactType3")); // check inherits from using artifact name
+ // }
+ //
+ // @org.junit.Test
+ // public void testAddArtifactSuperTypeMethod() throws OseeCoreException {
+ // ArtifactType artifactType = factory.createArtifactType(artCache, "myGUID", false, "TestMethodCreated");
+ // artCache.cache(artifactType);
+ //
+ // ArtifactType baseType = artCache.getUniqueByName("BaseArtifactType");
+ // Assert.assertFalse(artifactType.inheritsFrom(baseType));
+ // Assert.assertEquals(0, artifactType.getSuperArtifactTypes().size());
+ //
+ // artifactType.setSuperType(new HashSet<ArtifactType>(Arrays.asList(baseType)));
+ // Assert.assertEquals(1, artifactType.getSuperArtifactTypes().size());
+ // Assert.assertTrue(artifactType.inheritsFrom(baseType));
+ // artCache.decache(artifactType);
+ // }
+ //
+ // @org.junit.Test
+ // public void testInheritedAttributeTypes() throws OseeCoreException {
+ // Branch branch1 = branchCache.getByGuid("ROOT");
+ // Branch branch2 = branchCache.getByGuid("TEST");
+ // Assert.assertNotNull(branch1);
+ // Assert.assertNotNull(branch2);
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "000", branch1, "AAA");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "111", branch1, "AAA", "BBB");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "222", branch1, "AAA", "CCC");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "333", branch1, "AAA", "DDD", "CCC");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "444", branch1, "AAA", "FFF", "CCC", "DDD");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "555", branch1, "AAA", "GGG", "FFF", "CCC", "DDD");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "666", branch1, "AAA", "HHH", "DDD", "CCC");
+ //
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "000", branch2, "AAA");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "111", branch2, "AAA", "BBB");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "222", branch2, "AAA", "CCC");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "333", branch2, "AAA", "DDD", "CCC", "EEE"); // EEE only visible on branch2
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "444", branch2, "AAA", "FFF", "CCC", "DDD", "EEE");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "555", branch2, "AAA", "GGG", "FFF", "CCC", "DDD", "EEE");
+ // OseeTypesUtil.checkAttributes(artCache, attrCache, "666", branch2, "AAA", "HHH", "DDD", "CCC", "EEE");
+ // }
+ //
+ // @Override
+ // public void testDirty() throws OseeCoreException {
+ // }
+ //
+ // private final static class BranchDataAccessor extends MockOseeDataAccessor<Branch> {
+ //
+ // @Override
+ // public void load(AbstractOseeCache<Branch> cache) throws OseeCoreException {
+ // super.load(cache);
+ // Branch branch1 =
+ // OseeTypesUtil.createBranch(cache, factory, "ROOT", "Root Branch", BranchType.SYSTEM_ROOT,
+ // BranchState.CREATED, false);
+ // branch1.setId(999);
+ // cache.cache(branch1);
+ //
+ // Branch branch2 =
+ // OseeTypesUtil.createBranch(cache, factory, "TEST", "Test Branch", BranchType.BASELINE,
+ // BranchState.CREATED, false);
+ // branch2.setId(998);
+ // cache.cache(branch2);
+ //
+ // ((BranchCache) cache).setBranchParent(branch1, branch2);
+ // }
+ //
+ // }
+ //
+ // private final static class AttributeDataAccessor extends MockOseeDataAccessor<AttributeType> {
+ //
+ // private final List<AttributeType> attributeTypes;
+ //
+ // public AttributeDataAccessor(List<AttributeType> attributeTypes) {
+ // super();
+ // this.attributeTypes = attributeTypes;
+ // }
+ //
+ // private AttributeType createAttributeTypeHelper(AbstractOseeCache<AttributeType> cache, IOseeTypeFactory factory, String guid, String name) throws OseeCoreException {
+ // return factory.createAttributeType(cache, guid, name, "DummyBase", "DummyProvider", "none", "none", null, 1,
+ // 1, "test data", null);
+ // }
+ //
+ // @Override
+ // public void load(AbstractOseeCache<AttributeType> cache) throws OseeCoreException {
+ // super.load(cache);
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "AAA", "Attribute1"));
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "BBB", "Attribute2"));
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "CCC", "Attribute3"));
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "DDD", "Attribute4"));
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "EEE", "Attribute5"));
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "FFF", "Attribute6"));
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "GGG", "Attribute7"));
+ // attributeTypes.add(createAttributeTypeHelper(cache, factory, "HHH", "Attribute8"));
+ // int typeId = 200;
+ // for (AttributeType type : attributeTypes) {
+ // type.setId(typeId++);
+ // cache.cache(type);
+ // }
+ // }
+ // }
+ //
+
+ // private void setUpArtifactTypeInheritance(ArtifactTypeCache cache) throws OseeCoreException {
+ // ArtifactType baseType = cache.getUniqueByName("BaseArtifactType");
+ //
+ // Set<ArtifactType> baseSuperType = new HashSet<ArtifactType>();
+ // baseSuperType.add(baseType);
+ // // 0<-1
+ // cache.cacheArtifactSuperType(cache.getByGuid("111"), baseSuperType);
+ // // 0<-2
+ // cache.cacheArtifactSuperType(cache.getByGuid("222"), baseSuperType);
+ // // 2<-3
+ // cache.cacheArtifactSuperType(cache.getByGuid("333"), Arrays.asList(cache.getByGuid("222")));
+ // // 3<-4
+ // cache.cacheArtifactSuperType(cache.getByGuid("444"), Arrays.asList(cache.getByGuid("333")));
+ // // 4<-5
+ // cache.cacheArtifactSuperType(cache.getByGuid("555"), Arrays.asList(cache.getByGuid("444")));
+ // // 3<-6
+ // cache.cacheArtifactSuperType(cache.getByGuid("666"), Arrays.asList(cache.getByGuid("333")));
+ // }
+ //
+ // private void setUpTypeValidity(ArtifactTypeCache cache) throws OseeCoreException {
+ // Branch branch1 = branchCache.getByGuid("ROOT");
+ // Branch branch2 = branchCache.getByGuid("TEST");
+ // Assert.assertNotNull(branch1);
+ // Assert.assertNotNull(branch2);
+ // cache.cacheTypeValidity(cache.getByGuid("000"), attributeCache.getByGuid("AAA"), branch1);
+ // cache.cacheTypeValidity(cache.getByGuid("111"), attributeCache.getByGuid("BBB"), branch1);
+ // cache.cacheTypeValidity(cache.getByGuid("222"), attributeCache.getByGuid("CCC"), branch1);
+ // cache.cacheTypeValidity(cache.getByGuid("333"), attributeCache.getByGuid("DDD"), branch1);
+ // cache.cacheTypeValidity(cache.getByGuid("333"), attributeCache.getByGuid("EEE"), branch2);
+ // cache.cacheTypeValidity(cache.getByGuid("444"), attributeCache.getByGuid("FFF"), branch1);
+ // cache.cacheTypeValidity(cache.getByGuid("555"), attributeCache.getByGuid("GGG"), branch1);
+ // cache.cacheTypeValidity(cache.getByGuid("666"), attributeCache.getByGuid("HHH"), branch1);
+ // }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AttributeTypeTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AttributeTypeTest.java
new file mode 100644
index 0000000000..51ad91260a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/AttributeTypeTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeTypeTest {
+ @Ignore
+ @Test
+ public void test() {
+
+ }
+ //
+ // @Override
+ // public void testDirty() throws OseeCoreException {
+ // AttributeType attributeType = OseeTypesUtil.createAttributeType(attrCache, factory, "GUID", "AttributeDirtyTest");
+ // Assert.assertTrue(attributeType.isDirty());
+ // attributeType.clearDirty();
+ //
+ // String initialValue = attributeType.getName();
+ // attributeType.setName("My Name Has Changes");
+ // Assert.assertTrue(attributeType.isDirty());
+ //
+ // // Remains Dirty
+ // attributeType.setName(initialValue);
+ // Assert.assertTrue(attributeType.isDirty());
+ //
+ // // attributeType.setFields(name, baseAttributeTypeId, attributeProviderNameId, baseAttributeClass,
+ // // providerAttributeClass, fileTypeExtension, defaultValue, oseeEnumType, minOccurrences, maxOccurrences,
+ // // description, taggerId);
+ //
+ // }
+ //
+ // // private void checkDirty(AttributeType attributeType) {
+ // // // DirtyStateDetail details = attributeType.getDirtyDetails();
+ // // // details.
+ // // }
+ //
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BaseOseeTypeTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BaseOseeTypeTest.java
new file mode 100644
index 0000000000..310ef9a9f6
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BaseOseeTypeTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.eclipse.osee.framework.core.model.test.mocks.MockAbstractOseeType;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test Case for {@link AbstractOseeTest}
+ *
+ * @author Roberto E. Escobar
+ */
+@RunWith(Parameterized.class)
+public class BaseOseeTypeTest extends AbstractOseeTypeTest<MockAbstractOseeType> {
+
+ public BaseOseeTypeTest(MockAbstractOseeType type, String guid, String name) {
+ super(type, guid, name);
+ }
+
+ @Parameters
+ public static Collection<Object[]> getData() {
+ Collection<Object[]> data = new ArrayList<Object[]>();
+ for (int index = 1; index <= 2; index++) {
+ String guid = GUID.create();
+ String name = "index: " + index;
+ data.add(new Object[] {new MockAbstractOseeType(guid, name), guid, name});
+ }
+ return data;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BranchTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BranchTest.java
new file mode 100644
index 0000000000..30e9840fd4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/BranchTest.java
@@ -0,0 +1,331 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BranchTest {
+
+ @Ignore
+ @Test
+ public void test() {
+
+ }
+
+ // @Test
+ // public void testSystemRootBranch() throws OseeCoreException {
+ // Branch systemRootBranch = cache.getSystemRootBranch();
+ // Assert.assertNotNull(systemRootBranch);
+ // }
+ //
+ // @Test
+ // public void testBranchHierarchy() throws OseeCoreException {
+ // OseeTypesUtil.checkHierarchy(cache, "AAA", "BBB", "CCC");
+ // OseeTypesUtil.checkHierarchy(cache, "BBB", "DDD", "EEE");
+ // OseeTypesUtil.checkHierarchy(cache, "CCC", "FFF", "GGG", "HHH");
+ // }
+ //
+ // @Test
+ // public void testMergeBranches() throws OseeCoreException {
+ // OseeTypesUtil.checkMergeBranch(cache, null, "HHH", "AAA");
+ // OseeTypesUtil.checkMergeBranch(cache, "III", "DDD", "BBB");
+ // OseeTypesUtil.checkMergeBranch(cache, "JJJ", "GGG", "CCC");
+ // OseeTypesUtil.checkMergeBranch(cache, "KKK", "HHH", "CCC");
+ // }
+ //
+ // @Test
+ // public void testBranchAliases() throws OseeCoreException {
+ // OseeTypesUtil.checkAliases(cache, "AAA", "root", "system", "main");
+ // OseeTypesUtil.checkAliases(cache, "BBB", "base 1", "build 1", "common");
+ // OseeTypesUtil.checkAliases(cache, "CCC", "base 2", "build 2");
+ //
+ // OseeTypesUtil.checkAliases(cache, "DDD");
+ // OseeTypesUtil.checkAliases(cache, "EEE");
+ // OseeTypesUtil.checkAliases(cache, "FFF");
+ // OseeTypesUtil.checkAliases(cache, "GGG");
+ // OseeTypesUtil.checkAliases(cache, "HHH");
+ // OseeTypesUtil.checkAliases(cache, "III");
+ // }
+ //
+ // @Test
+ // public void testSameAliasForMultipleBranches() throws OseeCoreException {
+ // OseeTypesUtil.checkAliases(cache, "JJJ", "a merge branch");
+ // OseeTypesUtil.checkAliases(cache, "KKK", "a merge branch");
+ //
+ // List<Branch> aliasedbranch = new ArrayList<Branch>(cache.getByAlias("a merge branch"));
+ // Assert.assertEquals(2, aliasedbranch.size());
+ //
+ // Collections.sort(aliasedbranch);
+ // Assert.assertEquals(cache.getByGuid("JJJ"), aliasedbranch.get(0));
+ // Assert.assertEquals(cache.getByGuid("KKK"), aliasedbranch.get(1));
+ // }
+ //
+ // @Test
+ // public void testSetAliasForBranch() throws OseeCoreException {
+ // Branch branch = cache.getByGuid("JJJ");
+ // Assert.assertNotNull(branch);
+ //
+ // branch.setAliases("One", "Two", "Three");
+ // OseeTypesUtil.checkAliases(cache, "JJJ", "one", "two", "three");
+ //
+ // branch.setAliases("One", "Three");
+ // OseeTypesUtil.checkAliases(cache, "JJJ", "one", "three");
+ //
+ // branch.setAliases();
+ // OseeTypesUtil.checkAliases(cache, "JJJ");
+ //
+ // branch.setAliases("a merge branch");
+ // OseeTypesUtil.checkAliases(cache, "JJJ", "a merge branch");
+ // }
+ //
+ // @Test
+ // public void testBaseTransaction() throws OseeCoreException {
+ // Branch branch = cache.getByGuid("BBB");
+ // Assert.assertNotNull(branch);
+ //
+ // Assert.assertNull(branch.getBaseTransaction());
+ //
+ // TransactionRecord expectedTx =
+ // new TransactionRecord(1, branch, "Transaction 1", new Date(), 1, 2, TransactionDetailsType.Baselined);
+ // cache.cacheBaseTransaction(branch, expectedTx);
+ //
+ // TransactionRecord actualTx = branch.getBaseTransaction();
+ // Assert.assertEquals(expectedTx, actualTx);
+ // }
+ //
+ // @Test
+ // public void testInvalidBaseTransactionCaching() throws OseeCoreException {
+ // Branch branch = cache.getByGuid("BBB");
+ // Assert.assertNotNull(branch);
+ // TransactionRecord expectedTx =
+ // new TransactionRecord(1, branch, "Transaction 1", new Date(), 1, 2, TransactionDetailsType.NonBaselined);
+ //
+ // try {
+ // cache.cacheBaseTransaction(null, expectedTx);
+ // Assert.assertTrue("This line should not be executed", true);
+ // } catch (Exception ex) {
+ // Assert.assertTrue(ex instanceof OseeArgumentException);
+ // }
+ //
+ // try {
+ // cache.cacheBaseTransaction(branch, null);
+ // Assert.assertTrue("This line should not be executed", true);
+ // } catch (Exception ex) {
+ // Assert.assertTrue(ex instanceof OseeArgumentException);
+ // }
+ //
+ // try {
+ // cache.cacheBaseTransaction(branch, expectedTx);
+ // Assert.assertTrue("This line should not be executed", true);
+ // } catch (Exception ex) {
+ // Assert.assertTrue(ex instanceof OseeArgumentException);
+ // }
+ // }
+ //
+ // @Test
+ // public void testSourceTransaction() throws OseeCoreException {
+ // Branch branch = cache.getByGuid("BBB");
+ // Assert.assertNotNull(branch);
+ //
+ // Assert.assertNull(branch.getSourceTransaction());
+ //
+ // TransactionRecord expectedTx =
+ // new TransactionRecord(1, null, "Transaction 1", new Date(), 1, 2, TransactionDetailsType.NonBaselined);
+ // cache.cacheSourceTransaction(branch, expectedTx);
+ //
+ // TransactionRecord actualTx = branch.getSourceTransaction();
+ // Assert.assertEquals(expectedTx, actualTx);
+ // }
+ //
+ // @Test
+ // public void testInvalidSourceTransaction() throws OseeCoreException {
+ // Branch branch = cache.getByGuid("BBB");
+ // Assert.assertNotNull(branch);
+ // TransactionRecord expectedTx =
+ // new TransactionRecord(1, branch, "Transaction 1", new Date(), 1, 2, TransactionDetailsType.NonBaselined);
+ // cache.cacheSourceTransaction(branch, expectedTx);
+ //
+ // try {
+ // cache.cacheSourceTransaction(null, expectedTx);
+ // Assert.assertTrue("This line should not be executed", true);
+ // } catch (Exception ex) {
+ // Assert.assertTrue(ex instanceof OseeArgumentException);
+ // }
+ //
+ // try {
+ // cache.cacheSourceTransaction(branch, null);
+ // Assert.assertTrue("This line should not be executed", true);
+ // } catch (Exception ex) {
+ // Assert.assertTrue(ex instanceof OseeArgumentException);
+ // }
+ // }
+ //
+ // @Test
+ // public void testAssociatedArtifact() throws OseeCoreException {
+ // Assert.assertEquals(defaultAssociatedArtifact, cache.getDefaultAssociatedArtifact());
+ //
+ // Branch branch = cache.getByGuid("BBB");
+ // Assert.assertNotNull(branch);
+ //
+ // Assert.assertEquals(defaultAssociatedArtifact, branch.getAssociatedArtifact());
+ //
+ // String guid = GUID.create();
+ // IBasicArtifact<?> expectedArtifact = new TestArtifact(100, guid, "Test Artifact");
+ // branch.setAssociatedArtifact(expectedArtifact);
+ //
+ // Assert.assertEquals(branch.getAssociatedArtifact(), expectedArtifact);
+ //
+ // branch.setAssociatedArtifact(null);
+ // Assert.assertEquals(defaultAssociatedArtifact, branch.getAssociatedArtifact());
+ // }
+ //
+ // @Override
+ // public void testDirty() throws OseeCoreException {
+ // // TODO test Rename
+ //
+ // // AttributeType attributeType = OseeTypesUtil.createAttributeType(attrCache, factory, "GUID", "AttributeDirtyTest");
+ // // Assert.assertTrue(attributeType.isDirty());
+ // // attributeType.clearDirty();
+ // //
+ // // String initialValue = attributeType.getName();
+ // // attributeType.setName("My Name Has Changes");
+ // // Assert.assertTrue(attributeType.isDirty());
+ // //
+ // // // Remains Dirty
+ // // attributeType.setName(initialValue);
+ // // Assert.assertTrue(attributeType.isDirty());
+ // //
+ // // // attributeType.setFields(name, baseAttributeTypeId, attributeProviderNameId, baseAttributeClass,
+ // // // providerAttributeClass, fileTypeExtension, defaultValue, oseeEnumType, minOccurrences, maxOccurrences,
+ // // // description, taggerId);
+ //
+ // }
+ //
+ // private final static class TestArtifact implements IBasicArtifact<Object> {
+ //
+ // private final int artId;
+ // private final String guid;
+ // private final String name;
+ //
+ // public TestArtifact(int uniqueId, String guid, String name) {
+ // this.artId = uniqueId;
+ // this.guid = guid;
+ // this.name = name;
+ // }
+ //
+ // @Override
+ // public int getArtId() {
+ // return artId;
+ // }
+ //
+ // @Override
+ // public ArtifactType getArtifactType() {
+ // return null;
+ // }
+ //
+ // @Override
+ // public IBasicArtifact<Object> getFullArtifact() throws OseeCoreException {
+ // return null;
+ // }
+ //
+ // @Override
+ // public String getGuid() {
+ // return guid;
+ // }
+ //
+ // @Override
+ // public String getName() {
+ // return name;
+ // }
+ //
+ // @Override
+ // public Branch getBranch() {
+ // return null;
+ // }
+ // }
+ //
+ // private final static class BranchDataAccessor extends MockOseeDataAccessor<Branch> {
+ //
+ // private final List<Branch> data;
+ //
+ // public BranchDataAccessor(List<Branch> data) {
+ // super();
+ // this.data = data;
+ // }
+ //
+ // @Override
+ // public void load(AbstractOseeCache<Branch> cache) throws OseeCoreException {
+ // super.load(cache);
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "AAA", "Root", BranchType.SYSTEM_ROOT,
+ // BranchState.CREATED, false));
+ //
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "BBB", "B-Branch", BranchType.BASELINE,
+ // BranchState.CREATED, false));
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "CCC", "C-Branch", BranchType.BASELINE,
+ // BranchState.MODIFIED, false));
+ //
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "DDD", "D-Branch", BranchType.WORKING,
+ // BranchState.MODIFIED, false));
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "EEE", "E-Branch", BranchType.WORKING,
+ // BranchState.MODIFIED, false));
+ //
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "FFF", "F-Branch", BranchType.WORKING,
+ // BranchState.MODIFIED, false));
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "GGG", "G-Branch", BranchType.WORKING,
+ // BranchState.MODIFIED, true));
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "HHH", "H-Branch", BranchType.WORKING,
+ // BranchState.MODIFIED, true));
+ //
+ // // Merge Branches
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "III", "Merge-A", BranchType.MERGE, BranchState.CREATED,
+ // false));
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "JJJ", "Merge-B", BranchType.MERGE, BranchState.CREATED,
+ // false));
+ // data.add(OseeTypesUtil.createBranch(cache, factory, "KKK", "Merge-C", BranchType.MERGE, BranchState.CREATED,
+ // false));
+ //
+ // int typeId = 500;
+ // for (Branch type : data) {
+ // type.setId(typeId++);
+ // cache.cache(type);
+ // }
+ // BranchCache branchCache = (BranchCache) cache;
+ // loadBranchHierarchy(branchCache);
+ // loadMergeBranches(branchCache);
+ // loadBranchAliases(branchCache);
+ // }
+ //
+ // private void loadBranchHierarchy(BranchCache cache) throws OseeCoreException {
+ // OseeTypesUtil.createBranchHierarchy(cache, "AAA", "BBB", "CCC");
+ // OseeTypesUtil.createBranchHierarchy(cache, "BBB", "DDD", "EEE");
+ // OseeTypesUtil.createBranchHierarchy(cache, "CCC", "FFF", "GGG", "HHH");
+ // }
+ //
+ // private void loadMergeBranches(BranchCache branchCache) throws OseeCoreException {
+ // OseeTypesUtil.createMergeBranch(cache, "III", "DDD", "BBB");
+ // OseeTypesUtil.createMergeBranch(cache, "JJJ", "GGG", "CCC");
+ // OseeTypesUtil.createMergeBranch(cache, "KKK", "HHH", "CCC");
+ // }
+ //
+ // private void loadBranchAliases(BranchCache branchCache) throws OseeCoreException {
+ // OseeTypesUtil.createAlias(cache, "AAA", "Root", "System", "Main");
+ // OseeTypesUtil.createAlias(cache, "BBB", "Base 1", "Build 1", "common");
+ // OseeTypesUtil.createAlias(cache, "CCC", "Base 2", "Build 2");
+ //
+ // OseeTypesUtil.createAlias(cache, "JJJ", "a merge branch");
+ // OseeTypesUtil.createAlias(cache, "KKK", "a merge branch");
+ // }
+ // }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ModelTestSuite.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ModelTestSuite.java
new file mode 100644
index 0000000000..fdeb6c443b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/ModelTestSuite.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {//
+ArtifactTypeTest.class, //
+ AttributeTypeTest.class, //
+ BaseOseeTypeTest.class, //
+ BranchTest.class, //
+ OseeEnumTypeTest.class, //
+ RelationTypeTest.class, //
+})
+/**
+ * @author Roberto E. Escobar
+ */
+public class ModelTestSuite {
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/OseeEnumTypeTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/OseeEnumTypeTest.java
new file mode 100644
index 0000000000..e1966911f6
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/OseeEnumTypeTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OseeEnumTypeTest {
+ @Ignore
+ @Test
+ public void test() {
+
+ }
+ // @Override
+ // public void testDirty() throws OseeCoreException {
+ // }
+ //
+ // @org.junit.Test
+ // public void testAddOseeEnumEntry() throws OseeCoreException {
+ // OseeEnumType enum1 =
+ // OseeTypesUtil.createEnumType(cache, factory, "Test 1", "Test 1", "OneEntry", 0, "TwoEntry", 1);
+ // OseeTypesUtil.checkOseeEnumEntries(enum1.values(), "OneEntry", 0, "TwoEntry", 1);
+ //
+ // OseeEnumEntry entry = factory.createEnumEntry(cache, "C", "AddedEntry", 4);
+ // enum1.addEntry(entry);
+ //
+ // OseeTypesUtil.checkOseeEnumEntries(enum1.values(), "OneEntry", 0, "TwoEntry", 1, "AddedEntry", 4);
+ //
+ // enum1.removeEntry(entry);
+ // OseeTypesUtil.checkOseeEnumEntries(enum1.values(), "OneEntry", 0, "TwoEntry", 1);
+ //
+ // enum1.removeEntry(enum1.values()[0]);
+ // OseeTypesUtil.checkOseeEnumEntries(enum1.values(), "TwoEntry", 1);
+ // }
+ //
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/RelationTypeTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/RelationTypeTest.java
new file mode 100644
index 0000000000..8662dc2c0c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/RelationTypeTest.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class RelationTypeTest {
+ @Ignore
+ @Test
+ public void test() {
+
+ }
+ // @org.junit.Test
+ // public void testRelationTypeSides() throws OseeCoreException {
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "1A", RelationSide.SIDE_A, 1, "111");
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "1A", RelationSide.SIDE_B, 1, "444", "555");
+ //
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "2B", RelationSide.SIDE_A, 1, "555");
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "2B", RelationSide.SIDE_B, Integer.MAX_VALUE, "000",
+ // "111", "222", "333", "444", "555", "666");
+ //
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "3C", RelationSide.SIDE_A, Integer.MAX_VALUE, "222",
+ // "333", "444", "555", "666");
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "3C", RelationSide.SIDE_B, 1, "333", "444", "555",
+ // "666");
+ //
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "4D", RelationSide.SIDE_A, Integer.MAX_VALUE, "666");
+ // OseeTypesUtil.checkRelationTypeInheritance(cache, artCache, "4D", RelationSide.SIDE_B, Integer.MAX_VALUE, "666");
+ // }
+ //
+ // @Override
+ // public void testDirty() throws OseeCoreException {
+ // }
+ //
+ // private final static class ArtifactDataAccessor extends MockOseeDataAccessor<ArtifactType> {
+ // private final List<ArtifactType> artifactTypes;
+ //
+ // public ArtifactDataAccessor(List<ArtifactType> artifactTypes) {
+ // super();
+ // this.artifactTypes = artifactTypes;
+ // }
+ //
+ // @Override
+ // public void load(AbstractOseeCache<ArtifactType> cache) throws OseeCoreException {
+ // super.load(cache);
+ // artifactTypes.add(factory.createArtifactType(cache, "000", true, "BaseArtifactType"));
+ // artifactTypes.add(factory.createArtifactType(cache, "111", true, "ArtifactType1"));
+ // artifactTypes.add(factory.createArtifactType(cache, "222", false, "ArtifactType2"));
+ // artifactTypes.add(factory.createArtifactType(cache, "333", true, "ArtifactType3"));
+ // artifactTypes.add(factory.createArtifactType(cache, "444", false, "ArtifactType4"));
+ // artifactTypes.add(factory.createArtifactType(cache, "555", true, "ArtifactType5"));
+ // artifactTypes.add(factory.createArtifactType(cache, "666", false, "ArtifactType6"));
+ // int typeId = 100;
+ // for (ArtifactType type : artifactTypes) {
+ // type.setId(typeId++);
+ // cache.cache(type);
+ // }
+ // ArtifactTypeCache artCache = (ArtifactTypeCache) cache;
+ // setUpArtifactTypeInheritance(artCache);
+ // }
+ //
+ // private void setUpArtifactTypeInheritance(ArtifactTypeCache cache) throws OseeCoreException {
+ // ArtifactType baseType = cache.getUniqueByName("BaseArtifactType");
+ //
+ // Set<ArtifactType> baseSuperType = new HashSet<ArtifactType>();
+ // baseSuperType.add(baseType);
+ // // 0<-1
+ // cache.cacheArtifactSuperType(cache.getByGuid("111"), baseSuperType);
+ // // 0<-2
+ // cache.cacheArtifactSuperType(cache.getByGuid("222"), baseSuperType);
+ // // 2<-3
+ // cache.cacheArtifactSuperType(cache.getByGuid("333"), Arrays.asList(cache.getByGuid("222")));
+ // // 2,3<-4
+ // cache.cacheArtifactSuperType(cache.getByGuid("444"), Arrays.asList(cache.getByGuid("222"),
+ // cache.getByGuid("333"), baseType));
+ // // 4<-5
+ // cache.cacheArtifactSuperType(cache.getByGuid("555"), Arrays.asList(cache.getByGuid("444"), baseType));
+ // // 3<-6
+ // cache.cacheArtifactSuperType(cache.getByGuid("666"), Arrays.asList(cache.getByGuid("333"), baseType));
+ // }
+ // }
+ //
+ // private final static class RelationDataAccessor extends MockOseeDataAccessor<RelationType> {
+ // private final List<RelationType> relationTypes;
+ // private final AbstractOseeCache<ArtifactType> artCache;
+ //
+ // public RelationDataAccessor(AbstractOseeCache<ArtifactType> artCache, List<RelationType> relationTypes) {
+ // super();
+ // this.artCache = artCache;
+ // this.relationTypes = relationTypes;
+ // }
+ //
+ // @Override
+ // public void load(AbstractOseeCache<RelationType> cache) throws OseeCoreException {
+ // artCache.ensurePopulated();
+ // super.load(cache);
+ // relationTypes.add(OseeTypesUtil.createRelationType(cache, artCache, factory, "1A", "REL_1", "111", "444",
+ // RelationTypeMultiplicity.ONE_TO_ONE));
+ // relationTypes.add(OseeTypesUtil.createRelationType(cache, artCache, factory, "2B", "REL_2", "555", "000",
+ // RelationTypeMultiplicity.ONE_TO_MANY));
+ // relationTypes.add(OseeTypesUtil.createRelationType(cache, artCache, factory, "3C", "REL_3", "222", "333",
+ // RelationTypeMultiplicity.MANY_TO_ONE));
+ // relationTypes.add(OseeTypesUtil.createRelationType(cache, artCache, factory, "4D", "REL_4", "666", "666",
+ // RelationTypeMultiplicity.MANY_TO_MANY));
+ // int typeId = 300;
+ // for (RelationType type : relationTypes) {
+ // type.setId(typeId++);
+ // cache.cache(type);
+ // }
+ // }
+ // }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/TransactionRecordTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/TransactionRecordTest.java
new file mode 100644
index 0000000000..fc96f13488
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/type/TransactionRecordTest.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.model.test.type;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test Case for {@link TransactionRecord}
+ *
+ * @author Megumi Telles
+ */
+@RunWith(Parameterized.class)
+public class TransactionRecordTest {
+
+ private final TransactionRecord transaction;
+ private final int transactionNumber;
+ private final int branchId;
+ private final TransactionDetailsType txType;
+
+ private final String comment;
+ private final Date time;
+ private final int authorArtId;
+ private final int commitArtId;
+
+ public TransactionRecordTest(int transactionNumber, int branchId, String comment, Date time, int authorArtId, int commitArtId, TransactionDetailsType txType) {
+ this.transaction =
+ new TransactionRecord(transactionNumber, branchId, comment, time, authorArtId, commitArtId, txType);
+ this.transactionNumber = transactionNumber;
+ this.branchId = branchId;
+ this.comment = comment;
+ this.time = time;
+ this.authorArtId = authorArtId;
+ this.commitArtId = commitArtId;
+ this.txType = txType;
+ }
+
+ @Test
+ public void getBranch() {
+ Assert.assertEquals(branchId, transaction.getBranchId());
+ }
+
+ @Test
+ public void getId() {
+ Assert.assertEquals(transactionNumber, transaction.getId());
+ }
+
+ @Test
+ public void getTxType() {
+ Assert.assertEquals(txType, transaction.getTxType());
+ }
+
+ @Test
+ public void testGetSetComment() {
+ Assert.assertEquals(comment, transaction.getComment());
+
+ transaction.setComment("test set comment");
+ Assert.assertEquals("test set comment", transaction.getComment());
+
+ transaction.setComment(comment);
+ }
+
+ @Test
+ public void testGetSetDate() {
+ Assert.assertEquals(time, transaction.getTimeStamp());
+
+ Date anotherDate = new Date(11111111111L);
+ transaction.setTimeStamp(anotherDate);
+ Assert.assertEquals(anotherDate, transaction.getTimeStamp());
+
+ transaction.setTimeStamp(time);
+ }
+
+ @Test
+ public void testGetSetAuthor() {
+ Assert.assertEquals(authorArtId, transaction.getAuthor());
+
+ transaction.setAuthor(authorArtId * 101);
+ Assert.assertEquals(authorArtId * 101, transaction.getAuthor());
+
+ transaction.setAuthor(authorArtId);
+ }
+
+ @Test
+ public void testGetSetCommit() {
+ Assert.assertEquals(commitArtId, transaction.getCommit());
+
+ transaction.setCommit(commitArtId * 333);
+ Assert.assertEquals(commitArtId * 333, transaction.getCommit());
+
+ transaction.setCommit(commitArtId);
+ }
+
+ @Test
+ public void testEqualsAndHashCode() {
+ TransactionRecord tx1 = MockDataFactory.createTransaction(99, 1);
+ TransactionRecord tx2 = MockDataFactory.createTransaction(99, 2);
+
+ // Add some variation to tx2 so we are certain that only the txId is used in the equals method;
+ tx2.setAuthor(0);
+ tx2.setComment("a");
+ tx2.setCommit(1);
+ tx2.setTimeStamp(new Date(11111111111L));
+
+ Assert.assertNotSame(tx1, tx2);
+ Assert.assertTrue(tx1.equals(tx2));
+ Assert.assertTrue(tx2.equals(tx1));
+ Assert.assertEquals(tx1.hashCode(), tx2.hashCode());
+
+ Assert.assertFalse(transaction.equals(tx1));
+ Assert.assertFalse(transaction.equals(tx2));
+ Assert.assertFalse(transaction.hashCode() == tx1.hashCode());
+ Assert.assertFalse(transaction.hashCode() == tx2.hashCode());
+ }
+
+ @Test
+ public void testAdaptable() {
+ Assert.assertNull(transaction.getAdapter(null));
+ Assert.assertNull(transaction.getAdapter(Object.class));
+ Assert.assertSame(transaction, transaction.getAdapter(TransactionRecord.class));
+ }
+
+ @Test
+ public void testToString() {
+ Assert.assertEquals(transactionNumber + ":" + branchId, transaction.toString());
+ }
+
+ @Parameters
+ public static Collection<Object[]> getData() {
+ Collection<Object[]> data = new ArrayList<Object[]>();
+ for (int index = 1; index <= 2; index++) {
+ int transactionNumber = index * 11;
+ int branchId = index * 9;
+ String comment = GUID.create();
+ Date time = new Date();
+ int authorArtId = index * 47;
+ int commitArtId = index * 37;
+ TransactionDetailsType txType = TransactionDetailsType.toEnum(index % TransactionDetailsType.values().length);
+ data.add(new Object[] {transactionNumber, branchId, comment, time, authorArtId, commitArtId, txType});
+ }
+ return data;
+ }
+}

Back to the top