diff options
35 files changed, 309 insertions, 171 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/AllDslIntegrationTestSuite.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/AllDslIntegrationTestSuite.java index 3398de3c38b..5cf50cb66b7 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/AllDslIntegrationTestSuite.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/AllDslIntegrationTestSuite.java @@ -11,6 +11,7 @@ package org.eclipse.osee.framework.core.dsl.integration.test; import org.eclipse.osee.framework.core.dsl.integration.test.internal.InternalTestSuite; +import org.eclipse.osee.framework.core.dsl.integration.test.util.DslUtilTestSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -20,8 +21,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ // InternalTestSuite.class, // - ModelUtilTest.class, // - OseeUtilTest.class, // + DslUtilTestSuite.class, // }) public class AllDslIntegrationTestSuite { // Test Suite diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/DslAsserts.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/DslAsserts.java index a33ed684193..dfd682c1829 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/DslAsserts.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/DslAsserts.java @@ -1,19 +1,28 @@ -/* - * Created on Aug 2, 2010 +/******************************************************************************* + * 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 * - * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE - */ + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ package org.eclipse.osee.framework.core.dsl.integration.test.mocks; import junit.framework.Assert; import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData; import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; +import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.model.access.AccessDetail; import org.eclipse.osee.framework.core.model.test.mocks.MockAccessDetailCollector; +/** + * @author Roberto E. Escobar + */ public final class DslAsserts { private DslAsserts() { @@ -36,4 +45,16 @@ public final class DslAsserts { Assert.assertEquals(expectedAccessObject, actualDetail.getAccessObject()); } } + + public static void assertEquals(OseeDsl model1, OseeDsl model2) { + Assert.assertEquals(model1.getAccessDeclarations().size(), model2.getAccessDeclarations().size()); + Assert.assertEquals(model1.getArtifactRefs().size(), model2.getArtifactRefs().size()); + Assert.assertEquals(model1.getArtifactTypes().size(), model2.getArtifactTypes().size()); + Assert.assertEquals(model1.getAttributeTypes().size(), model2.getAttributeTypes().size()); + Assert.assertEquals(model1.getBranchRefs().size(), model2.getBranchRefs().size()); + Assert.assertEquals(model1.getEnumOverrides().size(), model2.getEnumOverrides().size()); + Assert.assertEquals(model1.getEnumTypes().size(), model2.getEnumTypes().size()); + Assert.assertEquals(model1.getImports().size(), model2.getImports().size()); + Assert.assertEquals(model1.getRelationTypes().size(), model2.getRelationTypes().size()); + } } diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/DslUtilTestSuite.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/DslUtilTestSuite.java new file mode 100644 index 00000000000..ea2ac7b258c --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/DslUtilTestSuite.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.dsl.integration.test.util; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Roberto E. Escobar + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ // +ModelUtilTest.class, // + OseeUtilTest.class, // +}) +public class DslUtilTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/ModelUtilTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/ModelUtilTest.java index 385e2d66314..6ca819d4683 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/ModelUtilTest.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/ModelUtilTest.java @@ -8,18 +8,18 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.integration.test; +package org.eclipse.osee.framework.core.dsl.integration.test.util; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.eclipse.osee.framework.core.dsl.integration.ModelUtil; +import org.eclipse.osee.framework.core.dsl.integration.test.mocks.DslAsserts; +import org.eclipse.osee.framework.core.dsl.integration.util.ModelUtil; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; /** @@ -57,24 +57,20 @@ public class ModelUtilTest { String value = outputStream.toString("UTF-8"); OseeDsl model2 = ModelUtil.loadModel("osee:/text2.osee", value); - - Assert.assertEquals(model1.getArtifactTypes().size(), model2.getArtifactTypes().size()); - Assert.assertEquals(model1.getAttributeTypes().size(), model2.getAttributeTypes().size()); - Assert.assertEquals(model1.getRelationTypes().size(), model2.getRelationTypes().size()); - Assert.assertEquals(model1.getImports().size(), model2.getImports().size()); - Assert.assertEquals(model1.getEnumOverrides().size(), model2.getEnumOverrides().size()); - Assert.assertEquals(model1.getEnumTypes().size(), model2.getEnumTypes().size()); + DslAsserts.assertEquals(model1, model2); } - @Ignore @Test public void testModelUtilLoadAccess() throws OseeCoreException, IOException { String rawXTextData = getRawXTextData(ACCESS_TEST_INPUT); OseeDsl model1 = ModelUtil.loadModel("osee:/text.osee", rawXTextData); - Assert.assertEquals(5, model1.getArtifactTypes().size()); - Assert.assertEquals(3, model1.getAttributeTypes().size()); - Assert.assertEquals(1, model1.getRelationTypes().size()); + Assert.assertEquals(2, model1.getArtifactTypes().size()); + Assert.assertEquals(1, model1.getAttributeTypes().size()); + Assert.assertEquals(0, model1.getRelationTypes().size()); + + Assert.assertEquals(3, model1.getArtifactRefs().size()); + Assert.assertEquals(2, model1.getAccessDeclarations().size()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ModelUtil.saveModel(model1, "osee:/text.osee", outputStream, false); @@ -82,13 +78,11 @@ public class ModelUtilTest { String value = outputStream.toString("UTF-8"); OseeDsl model2 = ModelUtil.loadModel("osee:/text2.osee", value); + DslAsserts.assertEquals(model1, model2); - Assert.assertEquals(model1.getArtifactTypes().size(), model2.getArtifactTypes().size()); - Assert.assertEquals(model1.getAttributeTypes().size(), model2.getAttributeTypes().size()); - Assert.assertEquals(model1.getRelationTypes().size(), model2.getRelationTypes().size()); - Assert.assertEquals(model1.getImports().size(), model2.getImports().size()); - Assert.assertEquals(model1.getEnumOverrides().size(), model2.getEnumOverrides().size()); - Assert.assertEquals(model1.getEnumTypes().size(), model2.getEnumTypes().size()); + // String modelRep = + // ModelUtil.modelToStringXText(model1, "osee:/text.osee", Collections.<String, Boolean> emptyMap()); + // OseeDsl model3 = ModelUtil.loadModel("osee:/text3.osee", modelRep); + // DslAsserts.assertEquals(model1, model3); } - } diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/OseeUtilTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/OseeUtilTest.java index 7abd343a4bb..c1054f090ec 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/OseeUtilTest.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/OseeUtilTest.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.integration.test; +package org.eclipse.osee.framework.core.dsl.integration.test.util; import java.util.HashMap; import java.util.Map; @@ -18,7 +18,7 @@ import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.data.IRelationType; import org.eclipse.osee.framework.core.data.Identity; -import org.eclipse.osee.framework.core.dsl.integration.OseeUtil; +import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil; import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum; import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/testAccessModel.osee b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/testAccessModel.osee index aeef9db0441..f859e264424 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/testAccessModel.osee +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/testAccessModel.osee @@ -1,5 +1,4 @@ -import "testTypeModel.osee" - +//import "platform:/org.eclipse.osee.framework.core.dsl.integration.test/testTypeModel.osee" artifactType "Artifact" { guid "BZOUrxO35x+LBZkEYzAA" } @@ -25,7 +24,6 @@ artifact "SubSystems" artGuid "AAMFEcWy0xc4e3tcem77"; accessContext "System Context" { guid "AAMFEcWy0xc4e3tcem11"; DENY edit artifactType "Artifact"; - childrenOf "Software Items" { DENY edit artifactType "Artifact"; } diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/testTypeModel.osee b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/testTypeModel.osee index 318a7fb14e9..318a7fb14e9 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/testTypeModel.osee +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/util/testTypeModel.osee diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF index 947787b0f70..b228dba6367 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/META-INF/MANIFEST.MF @@ -31,4 +31,5 @@ Require-Bundle: org.eclipse.osee.framework.core.dsl, org.eclipse.xtext Eclipse-ExtensibleAPI: true Bundle-Activator: org.eclipse.osee.framework.core.dsl.integration.internal.Activator -Export-Package: org.eclipse.osee.framework.core.dsl.integration +Export-Package: org.eclipse.osee.framework.core.dsl.integration, + org.eclipse.osee.framework.core.dsl.integration.util diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java index 5817833ccf6..c77ba196fc2 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java @@ -17,6 +17,7 @@ import java.util.Map; import java.util.Map.Entry; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osee.framework.core.dsl.integration.internal.Activator; +import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory; import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationMultiplicityEnum; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java index 05b05de900b..5bf515dcb3c 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osee.framework.core.dsl.integration.internal.Activator; +import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil; import org.eclipse.osee.framework.core.dsl.oseeDsl.AddEnum; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java index 06033f74e39..b5e250bb4db 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java @@ -11,7 +11,7 @@ package org.eclipse.osee.framework.core.dsl.integration.internal; import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData; -import org.eclipse.osee.framework.core.dsl.integration.OseeUtil; +import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil; import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactInstanceRestriction; import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java index 6a8aa88191b..11a7bf6d0f8 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java @@ -12,7 +12,7 @@ package org.eclipse.osee.framework.core.dsl.integration.internal; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData; -import org.eclipse.osee.framework.core.dsl.integration.OseeUtil; +import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil; import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction; import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java index 4a224f5c219..f9606dda3fa 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java @@ -13,7 +13,7 @@ package org.eclipse.osee.framework.core.dsl.integration.internal; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData; -import org.eclipse.osee.framework.core.dsl.integration.OseeUtil; +import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil; import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction; import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java index 195a4907ae0..c40364dd39c 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java @@ -20,10 +20,10 @@ import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot; import org.eclipse.emf.compare.diff.metamodel.DiffFactory; import org.eclipse.osee.framework.core.dsl.integration.CreateOseeTypeChangesReportOperation; import org.eclipse.osee.framework.core.dsl.integration.EMFCompareOperation; -import org.eclipse.osee.framework.core.dsl.integration.ModelUtil; import org.eclipse.osee.framework.core.dsl.integration.OseeToXtextOperation; import org.eclipse.osee.framework.core.dsl.integration.OseeTypeCache; import org.eclipse.osee.framework.core.dsl.integration.XTextToOseeTypeOperation; +import org.eclipse.osee.framework.core.dsl.integration.util.ModelUtil; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory; import org.eclipse.osee.framework.core.exception.OseeCoreException; @@ -127,7 +127,7 @@ public class OseeModelingServiceImpl implements IOseeModelingService { if (request.isCreateCompareReport()) { response.setComparisonSnapshotModelName("osee_compare.diff"); String modelString = - ModelUtil.modelToString(comparisonSnapshot, "osee:/osee_compare.diff", + ModelUtil.modelToStringXML(comparisonSnapshot, "osee:/osee_compare.diff", Collections.<String, Boolean> emptyMap()); response.setComparisonSnapshotModel(modelString); } diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java index bcf7cac2497..08946395b76 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java @@ -13,7 +13,7 @@ package org.eclipse.osee.framework.core.dsl.integration.internal; import java.util.Collection; import org.eclipse.osee.framework.core.data.IRelationType; import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData; -import org.eclipse.osee.framework.core.dsl.integration.OseeUtil; +import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil; import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/ModelUtil.java index df1a5314a3c..0cc7184506c 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/ModelUtil.java @@ -8,12 +8,11 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.integration; +package org.eclipse.osee.framework.core.dsl.integration.util; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.util.HashMap; @@ -45,34 +44,13 @@ public final class ModelUtil { // Utility Class } - // private void loadDependencies(OseeTypeModel baseModel, List<OseeTypeModel> models) throws OseeCoreException, URISyntaxException { - // // This is commented out cause we're using a combined file. Once combined files - // // are no longer generated, this should be uncommented. - // // for (Import dependant : baseModel.getImports()) { - // // OseeTypeModel childModel = OseeTypeModelUtil.loadModel(context, new URI(dependant.getImportURI())); - // // loadDependencies(childModel, models); - // // System.out.println("depends on: " + dependant.getImportURI()); - // // } - // // System.out.println("Added on: " + baseModel.eResource().getURI()); - // models.add(baseModel); - // - // } - - // OseeTypeModel targetModel = null; - // try { - // targetModel = OseeTypeModelUtil.loadModel(context, resource); - // } catch (OseeCoreException ex) { - // throw new OseeWrappedException(String.format("Error loading: [%s]", resource), ex); - // } - // loadDependencies(targetModel, models); - public static OseeDsl loadModel(String uri, String xTextData) throws OseeCoreException { try { OseeDslStandaloneSetup setup = new OseeDslStandaloneSetup(); Injector injector = setup.createInjectorAndDoEMFRegistration(); XtextResourceSet set = injector.getInstance(XtextResourceSet.class); - set.setClasspathURIContext(ModelUtil.class); + // set.setClasspathURIContext(ModelUtil.class); set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); Resource resource = set.createResource(URI.createURI(uri)); @@ -87,57 +65,6 @@ public final class ModelUtil { } } - public static OseeDsl loadModel(InputStream inputStream, boolean isZipped) throws OseeCoreException { - Injector injector = new OseeDslStandaloneSetup().createInjectorAndDoEMFRegistration(); - XtextResource resource = injector.getInstance(XtextResource.class); - - Map<String, Boolean> options = new HashMap<String, Boolean>(); - options.put(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); - if (isZipped) { - options.put(Resource.OPTION_ZIP, Boolean.TRUE); - } - try { - resource.setURI(URI.createURI("http://www.eclipse.org/osee/framework/OseeTypes")); - resource.load(inputStream, options); - } catch (IOException ex) { - throw new OseeWrappedException(ex); - } - OseeDsl model = (OseeDsl) resource.getContents().get(0); - for (Diagnostic diagnostic : resource.getErrors()) { - throw new OseeStateException(diagnostic.toString()); - } - return model; - } - - public static OseeDsl loadModel(Object context, java.net.URI target) throws OseeCoreException { - String uri = target.toASCIIString(); - Injector injector = new OseeDslStandaloneSetup().createInjectorAndDoEMFRegistration(); - XtextResourceSet set = injector.getInstance(XtextResourceSet.class); - - set.setClasspathURIContext(context); - set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); - - Resource resource = set.getResource(URI.createURI(uri), true); - OseeDsl model = (OseeDsl) resource.getContents().get(0); - for (Diagnostic diagnostic : resource.getErrors()) { - throw new OseeStateException(diagnostic.toString()); - } - return model; - } - - public static void saveModel(java.net.URI uri, OseeDsl model) throws IOException { - OseeDslStandaloneSetup.doSetup(); - - ResourceSet resourceSet = new ResourceSetImpl(); - Resource resource = resourceSet.createResource(URI.createURI(uri.toASCIIString())); - resource.getContents().add(model); - - Map<String, Boolean> options = new HashMap<String, Boolean>(); - // options.put(XtextResource.OPTION_FORMAT, Boolean.TRUE); - SaveOptions saveOptions = SaveOptions.getOptions(options); - resource.save(saveOptions.toOptionsMap()); - } - public static void saveModel(OseeDsl model, String uri, OutputStream outputStream, boolean isZipped) throws IOException { OseeDslStandaloneSetup.doSetup(); @@ -154,8 +81,7 @@ public final class ModelUtil { resource.save(outputStream, saveOptions.toOptionsMap()); } - private static void storeModel(OutputStream outputStream, EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException { - Resource resource = new XMLResourceImpl(); + private static void storeModel(Resource resource, OutputStream outputStream, EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException { try { resource.setURI(URI.createURI(uri)); resource.getContents().add(object); @@ -165,9 +91,22 @@ public final class ModelUtil { } } - public static String modelToString(EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException { + public static String modelToStringXML(EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException { + return modelToString(new XMLResourceImpl(), object, uri, options); + } + + public static String modelToStringXText(EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException { + OseeDslStandaloneSetup setup = new OseeDslStandaloneSetup(); + Injector injector = setup.createInjectorAndDoEMFRegistration(); + Resource resource = injector.getInstance(XtextResource.class); + Map<String, Boolean> options2 = new HashMap<String, Boolean>(); + options2.put(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); + return modelToString(resource, object, uri, options2); + } + + private static String modelToString(Resource resource, EObject object, String uri, Map<String, Boolean> options) throws OseeCoreException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - storeModel(outputStream, object, uri, options); + storeModel(resource, outputStream, object, uri, options); try { return outputStream.toString("UTF-8"); } catch (UnsupportedEncodingException ex) { diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java index 87694b2264d..764879f6d90 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.integration; +package org.eclipse.osee.framework.core.dsl.integration.util; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF index bd07584e324..e7dc3b9a510 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/META-INF/MANIFEST.MF @@ -18,6 +18,7 @@ Import-Package: org.eclipse.compare, org.eclipse.osee.framework.core.client.server, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.dsl.integration, + org.eclipse.osee.framework.core.dsl.integration.util, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.exception, org.eclipse.osee.framework.core.message, diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java index 097370e7a57..fde3ce4f15b 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java @@ -26,7 +26,7 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot; import org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput; import org.eclipse.osee.framework.core.data.OseeServerContext; -import org.eclipse.osee.framework.core.dsl.integration.ModelUtil; +import org.eclipse.osee.framework.core.dsl.integration.util.ModelUtil; import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; import org.eclipse.osee.framework.core.enums.CoreTranslatorId; import org.eclipse.osee.framework.core.message.OseeImportModelRequest; 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 index d2d8b41a742..92c9167ed94 100644 --- 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 @@ -10,21 +10,23 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.model.test; +import org.eclipse.osee.framework.core.model.test.access.AccessTestSuite; 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.eclipse.osee.framework.core.model.test.type.TypeTestSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({// -CacheTestSuite.class, // +AccessTestSuite.class, // + CacheTestSuite.class, // FieldTestSuite.class, // - ModelTestSuite.class, // + TypeTestSuite.class, // }) /** * @author Roberto E. Escobar */ public class AllCoreModelTestSuite { - + // Test Suite } diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDetailTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDetailTest.java new file mode 100644 index 00000000000..4efc870dbbc --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDetailTest.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2010 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.access; + +import java.util.ArrayList; +import java.util.Collection; +import junit.framework.Assert; +import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.model.access.AccessDetail; +import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * Test Case for {@link AccessDetail} + * + * @author Roberto E. Escobar + */ +@RunWith(Parameterized.class) +public class AccessDetailTest { + + private final Object expAccessObject; + private final PermissionEnum expPermission; + private final String expReason; + private final AccessDetail<?> target; + + public AccessDetailTest(AccessDetail<?> target, Object expAccessObject, PermissionEnum expPermission, String expReason) { + this.target = target; + this.expAccessObject = expAccessObject; + this.expPermission = expPermission; + this.expReason = expReason; + } + + @Test + public void testGetReason() { + Assert.assertEquals(expReason, target.getReason()); + } + + @Test + public void testGetPermission() { + Assert.assertEquals(expPermission, target.getPermission()); + } + + @Test + public void testGetAccessObject() { + Assert.assertEquals(expAccessObject, target.getAccessObject()); + } + + @Test + public void testSetPermission() { + Assert.assertEquals(expPermission, target.getPermission()); + PermissionEnum anotherPermission = PermissionEnum.NONE; + + target.setPermission(anotherPermission); + Assert.assertEquals(anotherPermission, target.getPermission()); + + target.setPermission(expPermission); + Assert.assertEquals(expPermission, target.getPermission()); + } + + @Test + public void testHashCodeAndEquals() { + Assert.assertTrue(target.equals(target)); + Assert.assertTrue(target.hashCode() == target.hashCode()); + + AccessDetail<?> other = MockDataFactory.createAccessDetails(expAccessObject, PermissionEnum.NONE, null); + Assert.assertTrue(target.equals(other)); + Assert.assertTrue(target.hashCode() == other.hashCode()); + + AccessDetail<?> nulled = MockDataFactory.createAccessDetails(null, PermissionEnum.NONE, null); + Assert.assertFalse(target.equals(nulled)); + Assert.assertTrue(target.hashCode() != nulled.hashCode()); + + Collection<AccessDetail<?>> collect = new ArrayList<AccessDetail<?>>(); + collect.add(target); + Assert.assertEquals(1, collect.size()); + Assert.assertTrue(collect.contains(target)); + Assert.assertTrue(collect.contains(other)); + Assert.assertFalse(collect.contains(nulled)); + } + + @Test + public void testToString() { + String expected = + "Access [ accessObject=[" + expAccessObject + "] permission=[" + expPermission + "] reason=[" + expReason + "]]"; + Assert.assertEquals(expected, target.toString()); + } + + @Parameters + public static Collection<Object[]> getData() throws OseeCoreException { + Collection<Object[]> data = new ArrayList<Object[]>(); + addTest(data, "Hello", PermissionEnum.DENY, "A reason"); + addTest(data, 456, PermissionEnum.WRITE, null); + addTest(data, MockDataFactory.createArtifactType(4), PermissionEnum.FULLACCESS, "reason3"); + addTest(data, MockDataFactory.createAttributeType(), PermissionEnum.READ, "xx"); + return data; + } + + private static <T> void addTest(Collection<Object[]> data, T expAccessObject, PermissionEnum expPermission, String expReason) { + String reasonToCheck = expReason; + if (expReason == null) { + reasonToCheck = Strings.emptyString(); + } + AccessDetail<T> target = MockDataFactory.createAccessDetails(expAccessObject, expPermission, expReason); + data.add(new Object[] {target, expAccessObject, expPermission, reasonToCheck}); + } + +}
\ 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/access/AccessTestSuite.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessTestSuite.java new file mode 100644 index 00000000000..e61946437d1 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessTestSuite.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.access; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({// +AccessDataTest.class, // + AccessDataQueryTest.class, // + AccessDetailTest.class, // + PermissionStatusTest.class, // +}) +/** + * @author Roberto E. Escobar + */ +public class AccessTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionStatusTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionStatusTest.java index 4051a3b883f..fca62ecebaf 100644 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionStatusTest.java +++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionStatusTest.java @@ -16,8 +16,9 @@ import org.junit.Test; /** * Test Case for {@link PermissionStatus} - * + * * @author Jeff C. Phillips + * @author Roberto E. Escobar */ public class PermissionStatusTest { @@ -25,6 +26,7 @@ public class PermissionStatusTest { public void testDefaultConstruction() { PermissionStatus permissionStatus = new PermissionStatus(); Assert.assertTrue(permissionStatus.matched()); + Assert.assertEquals("", permissionStatus.getReason()); } @Test @@ -33,4 +35,10 @@ public class PermissionStatusTest { Assert.assertFalse(permissionStatus.matched()); Assert.assertEquals(permissionStatus.getReason(), "Hello"); } + + @Test + public void testToString() { + PermissionStatus permissionStatus = new PermissionStatus(false, "Hello"); + Assert.assertEquals("PermissionStatus [reason=Hello, matchedPermission=false]", permissionStatus.toString()); + } } diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionTest.java deleted file mode 100644 index 243ab7fecef..00000000000 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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.access; - -import org.eclipse.osee.framework.core.enums.PermissionEnum; - -public class PermissionTest { - - public void main(String[] args) { - PermissionEnum[] a = {PermissionEnum.DENY, PermissionEnum.FULLACCESS, null}; - PermissionEnum[] b = {PermissionEnum.LOCK, PermissionEnum.FULLACCESS, null}; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - PermissionEnum branchPermission = a[i]; - PermissionEnum userPermission = b[j]; - if (branchPermission == PermissionEnum.DENY || userPermission == null) { - System.out.print("T"); - } else { - System.out.print("F"); - } - } - System.out.println(); - } - } -} diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessFilterChainTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/exp/AccessFilterChainTest.java index 7b0fb84b50c..6b78af6645f 100644 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessFilterChainTest.java +++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/exp/AccessFilterChainTest.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.model.test.access; +package org.eclipse.osee.framework.core.model.test.access.exp; import junit.framework.Assert; import org.eclipse.osee.framework.core.data.IAttributeType; 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 index 2894213f183..d4398361dd8 100644 --- 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 @@ -26,5 +26,5 @@ ArtifactTypeCacheTest.class, // * @author Roberto E. Escobar */ public class CacheTestSuite { - + // Test Suite } 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 index 165c4d8cc96..413b7547c8b 100644 --- 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 @@ -28,5 +28,5 @@ ArtifactSuperTypeFieldTest.class, // * @author Roberto E. Escobar */ public class FieldTestSuite { - + // Test Suite } 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 index 58ea3a3018d..0f4d69f23eb 100644 --- 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 @@ -16,6 +16,7 @@ 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.PermissionEnum; import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes; import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; @@ -26,6 +27,7 @@ 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.TransactionRecord; +import org.eclipse.osee.framework.core.model.access.AccessDetail; 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; @@ -50,6 +52,16 @@ public final class MockDataFactory { // Utility Class } + public static <T> AccessDetail<T> createAccessDetails(T expAccessObject, PermissionEnum expPermission, String expReason) { + AccessDetail<T> target; + if (expReason != null) { + target = new AccessDetail<T>(expAccessObject, expPermission, expReason); + } else { + target = new AccessDetail<T>(expAccessObject, expPermission); + } + return target; + } + public static IBasicArtifact<?> createArtifact(int index) { return new DefaultBasicArtifact(index * 37, GUID.create(), "user_" + index); } 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/TypeTestSuite.java index 44eafb8d58b..6228f0c7dfd 100644 --- 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/TypeTestSuite.java @@ -25,6 +25,6 @@ ArtifactTypeTest.class, // /** * @author Roberto E. Escobar */ -public class ModelTestSuite { - +public class TypeTestSuite { + // Test Suite } diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessDetail.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessDetail.java index afad06c1393..499f57d8c42 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessDetail.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessDetail.java @@ -48,12 +48,25 @@ public class AccessDetail<T> { @Override public int hashCode() { - return accessObject.hashCode(); + int hashCode = 11; + return hashCode * 37 + (accessObject != null ? accessObject.hashCode() : 0); } @Override public boolean equals(Object obj) { - return accessObject.equals(obj); + if (obj instanceof AccessDetail<?>) { + AccessDetail<?> other = (AccessDetail<?>) obj; + Object object1 = getAccessObject(); + Object object2 = other.getAccessObject(); + boolean result = false; + if (object1 == null && object2 == null) { + result = true; + } else if (object1 != null && object2 != null) { + result = getAccessObject().equals(other.getAccessObject()); + } + return result; + } + return false; } @Override diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/PermissionStatus.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/PermissionStatus.java index 9437b7c5f97..a82ca555ddd 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/PermissionStatus.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/PermissionStatus.java @@ -27,7 +27,9 @@ public final class PermissionStatus { public PermissionStatus(boolean matched, String reason) { this.reason = new StringBuilder(); this.matchedPermission = matched; - append(reason); + if (reason != null) { + append(reason); + } } public boolean matched() { @@ -38,6 +40,11 @@ public final class PermissionStatus { return reason.toString(); } + @Override + public String toString() { + return "PermissionStatus [reason=" + reason + ", matchedPermission=" + matchedPermission + "]"; + } + void append(String reason) { if (Strings.isValid(reason)) { this.reason.append(reason); diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessFilterFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessFilterFactory.java index 1645e7ccd57..9a163b1366f 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessFilterFactory.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessFilterFactory.java @@ -8,12 +8,11 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.model.access; +package org.eclipse.osee.framework.core.model.access.exp; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.eclipse.osee.framework.core.model.access.exp.IAccessFilter; public class AccessFilterFactory { diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/ArtifactTypeFilter.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/ArtifactTypeFilter.java index dfa2fd67384..cd52bc11892 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/ArtifactTypeFilter.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/ArtifactTypeFilter.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.model.access; +package org.eclipse.osee.framework.core.model.access.exp; import java.util.Collection; import java.util.HashSet; diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AttributeTypeFilter.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AttributeTypeFilter.java index 445164fb6e6..d5e8ce8d535 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AttributeTypeFilter.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AttributeTypeFilter.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.model.access; +package org.eclipse.osee.framework.core.model.access.exp; import java.util.Collection; import java.util.HashMap; diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/IAcceptFilter.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/IAcceptFilter.java index 8ad6224509a..b7285735256 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/IAcceptFilter.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/IAcceptFilter.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.model.access; +package org.eclipse.osee.framework.core.model.access.exp; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.model.IBasicArtifact; |