Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2010-07-27 15:52:18 -0400
committerjphillips2010-07-27 15:52:18 -0400
commit3cbe0f8f4c5894fbffa2a5432c2feccb0bd14f95 (patch)
tree2685f0ce02b5566ffbd68d188f55daf5bb517287 /plugins
parent983510153388f186bed6904c7820c4a8b3bea040 (diff)
downloadorg.eclipse.osee-3cbe0f8f4c5894fbffa2a5432c2feccb0bd14f95.tar.gz
org.eclipse.osee-3cbe0f8f4c5894fbffa2a5432c2feccb0bd14f95.tar.xz
org.eclipse.osee-3cbe0f8f4c5894fbffa2a5432c2feccb0bd14f95.zip
Merge access control changes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java108
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessDataTest.java118
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataQueryTest.java146
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataTest.java52
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessFilterChainTest.java (renamed from plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java)2
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionTest.java (renamed from plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/PermissionTest.java)2
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockArtifact.java54
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java38
8 files changed, 254 insertions, 266 deletions
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java
deleted file mode 100644
index ebbfcc4555..0000000000
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessCollectorTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Created on Jul 20, 2010
- *
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
-package org.eclipse.osee.framework.access.test.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import junit.framework.Assert;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.model.DefaultBasicArtifact;
-import org.eclipse.osee.framework.core.model.IBasicArtifact;
-import org.eclipse.osee.framework.core.model.access.exp.AccessCollector;
-import org.eclipse.osee.framework.core.model.access.exp.ArtifactAccessFilter;
-import org.eclipse.osee.framework.core.model.access.exp.AttributeTypeAccessFilter;
-import org.eclipse.osee.framework.core.model.access.exp.BranchAccessFilter;
-import org.eclipse.osee.framework.core.model.access.exp.IAccessFilter;
-import org.junit.Test;
-
-/**
- * @author Jeff C. Phillips
- */
-public class AccessCollectorTest {
-
- @Test
- public void testAttrUseCase() {
- IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
- IAttributeType wordAttrType = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
- IAttributeType phoneType = CoreAttributeTypes.PHONE;
- List<IAccessFilter> filters = new ArrayList<IAccessFilter>();
-
- BranchAccessFilter branchAccessFilter = new BranchAccessFilter(basicArtifact, PermissionEnum.READ);
- ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(basicArtifact, PermissionEnum.WRITE);
- AttributeTypeAccessFilter wordTypeFilter =
- new AttributeTypeAccessFilter(PermissionEnum.WRITE, basicArtifact, wordAttrType);
- AttributeTypeAccessFilter phoneTypeFilter =
- new AttributeTypeAccessFilter(PermissionEnum.READ, basicArtifact, phoneType);
-
- filters.add(artifactAccessFilter);
- filters.add(branchAccessFilter);
- filters.add(phoneTypeFilter);
- filters.add(wordTypeFilter);
-
- AccessCollector<IAttributeType> collector = new AccessCollector<IAttributeType>(filters);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.WRITE).size() == 1);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.READ).size() == 2);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.DENY).isEmpty());
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.FULLACCESS).isEmpty());
- }
-
- @Test
- public void testAttrUseCaseMissingBranchFilters() {
- IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
- IAttributeType wordAttrType = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
- IAttributeType phoneType = CoreAttributeTypes.PHONE;
- List<IAccessFilter> filters = new ArrayList<IAccessFilter>();
-
- AttributeTypeAccessFilter wordTypeFilter =
- new AttributeTypeAccessFilter(PermissionEnum.WRITE, basicArtifact, wordAttrType);
- AttributeTypeAccessFilter phoneTypeFilter =
- new AttributeTypeAccessFilter(PermissionEnum.READ, basicArtifact, phoneType);
-
- filters.add(phoneTypeFilter);
- filters.add(wordTypeFilter);
-
- AccessCollector<IAttributeType> collector = new AccessCollector<IAttributeType>(filters);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.WRITE).size() == 1);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.READ).size() == 2);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.DENY).isEmpty());
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.FULLACCESS).isEmpty());
- }
-
- @Test
- public void testAttrUseCaseMissingAttrFilters() {
- IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
- IAttributeType wordAttrType = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
- IAttributeType phoneType = CoreAttributeTypes.PHONE;
- List<IAccessFilter> filters = new ArrayList<IAccessFilter>();
-
- BranchAccessFilter branchAccessFilter = new BranchAccessFilter(basicArtifact, PermissionEnum.READ);
- ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(basicArtifact, PermissionEnum.WRITE);
-
- filters.add(artifactAccessFilter);
- filters.add(branchAccessFilter);
-
- AccessCollector<IAttributeType> collector = new AccessCollector<IAttributeType>(filters);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.WRITE).size() == 2);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.READ).size() == 2);
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.DENY).isEmpty());
- Assert.assertTrue(collector.getAttributeTypesToMatch(basicArtifact, Arrays.asList(wordAttrType, phoneType),
- PermissionEnum.FULLACCESS).isEmpty());
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessDataTest.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessDataTest.java
deleted file mode 100644
index 7039e64984..0000000000
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessDataTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * 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.access.test.internal;
-
-import org.eclipse.osee.framework.core.model.access.AccessData;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Test Case for {@link AccessData}
- *
- * @author Jeff C. Phillips
- */
-public class AccessDataTest {
-
- @Ignore
- @Test
- public void testObjectBase() {
- }
-
- // @Test
- // public void testObjectBase() {
- // AccessData accessData = new AccessData();
- // Assert.assertFalse(accessData.matchesAll(PermissionEnum.READ));
- //
- // IBasicArtifact<?> basicArtifact2 = new DefaultBasicArtifact(2, "2", "Name2");
- // accessData.add(basicArtifact2, PermissionEnum.WRITE);
- // IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "Name");
- // accessData.add(basicArtifact, PermissionEnum.READ);
- //
- // Assert.assertTrue(accessData.matchesAll(PermissionEnum.READ));
- // Assert.assertFalse(accessData.matchesAll(PermissionEnum.WRITE));
- // }
- //
- // @Test
- // public void testObjectBaseDeny() {
- // AccessData accessData = new AccessData();
- // Assert.assertFalse(accessData.matchesAll(PermissionEnum.READ));
- //
- // IBasicArtifact<?> basicArtifact2 = new DefaultBasicArtifact(2, "2", "Name2");
- // accessData.add(basicArtifact2, PermissionEnum.DENY);
- // IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "Name");
- // accessData.add(basicArtifact, PermissionEnum.READ);
- //
- // Assert.assertFalse(accessData.matchesAll(PermissionEnum.READ));
- // }
- //
- // @Test
- // public void testAttributeTypeFilter() {
- // AccessData accessData = new AccessData();
- // Assert.assertFalse(accessData.matchesAll(PermissionEnum.READ));
- //
- // IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "Name");
- // IBasicArtifact<?> basicArtifact2 = new DefaultBasicArtifact(2, "2", "Name Two");
- // accessData.add(basicArtifact, CoreAttributeTypes.WORD_TEMPLATE_CONTENT, PermissionEnum.READ);
- // accessData.add(basicArtifact2, CoreAttributeTypes.WORD_TEMPLATE_CONTENT, PermissionEnum.WRITE);
- //
- // Assert.assertTrue(!accessData.getAttributeTypeMatches(basicArtifact, CoreAttributeTypes.WORD_TEMPLATE_CONTENT,
- // PermissionEnum.READ).isEmpty());
- // Assert.assertTrue(accessData.getAttributeTypeMatches(basicArtifact, CoreAttributeTypes.WORD_TEMPLATE_CONTENT,
- // PermissionEnum.WRITE).isEmpty());
- // Assert.assertTrue(accessData.matchesAll(PermissionEnum.READ));
- // Assert.assertFalse(accessData.matchesAll(PermissionEnum.WRITE));
- // }
- //
- // @Test
- // public void testArtifactTypeFilter() {
- // AccessData accessData = new AccessData();
- // Assert.assertFalse(accessData.matchesAll(PermissionEnum.READ));
- //
- // IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "Name");
- // accessData.add(basicArtifact, CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.READ);
- // Assert.assertTrue(!accessData.getArtifactTypeMatches(basicArtifact,
- // CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.READ).isEmpty());
- // Assert.assertTrue(accessData.getArtifactTypeMatches(basicArtifact, CoreArtifactTypes.AbstractSoftwareRequirement,
- // PermissionEnum.WRITE).isEmpty());
- // }
- //
- // @Test
- // public void testMerge() {
- // AccessData mainAccessData = new AccessData();
- // AccessData subAccessData = new AccessData();
- //
- // IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "Name");
- // mainAccessData.add(basicArtifact, CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.READ);
- // subAccessData.add(basicArtifact, CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.WRITE);
- // mainAccessData.merge(subAccessData);
- //
- // Assert.assertTrue(!mainAccessData.getArtifactTypeMatches(basicArtifact,
- // CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.READ).isEmpty());
- //
- // IBasicArtifact<?> basicArtifact2 = new DefaultBasicArtifact(2, "2", "NameTwo");
- // mainAccessData.add(basicArtifact2, CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.WRITE);
- // subAccessData.add(basicArtifact2, CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.READ);
- //
- // mainAccessData.merge(subAccessData);
- //
- // Assert.assertTrue(!mainAccessData.getArtifactTypeMatches(basicArtifact2,
- // CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.READ).isEmpty());
- //
- // mainAccessData.add(basicArtifact2, CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.WRITE);
- // subAccessData.add(basicArtifact2, CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.DENY);
- //
- // mainAccessData.merge(subAccessData);
- //
- // Assert.assertFalse(!mainAccessData.getArtifactTypeMatches(basicArtifact2,
- // CoreArtifactTypes.AbstractSoftwareRequirement, PermissionEnum.READ).isEmpty());
- // }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataQueryTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataQueryTest.java
new file mode 100644
index 0000000000..08fe6c46fb
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataQueryTest.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * 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 junit.framework.Assert;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.PermissionEnum;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.access.AccessData;
+import org.eclipse.osee.framework.core.model.access.AccessDataQuery;
+import org.eclipse.osee.framework.core.model.access.AccessDetail;
+import org.eclipse.osee.framework.core.model.access.PermissionStatus;
+import org.eclipse.osee.framework.core.model.test.mocks.MockArtifact;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AccessDataQuery}
+ *
+ * @author Jeff C. Phillips
+ */
+public class AccessDataQueryTest {
+
+ @Test
+ public void testBranch() throws OseeCoreException {
+ IOseeBranch branchToCheck = CoreBranches.SYSTEM_ROOT;
+
+ TestObject testObject = getTestData();
+ AccessData data = testObject.getAccessData();
+
+ AccessDataQuery query = new AccessDataQuery(data);
+ PermissionStatus status = new PermissionStatus();
+
+ query.branchMatches(PermissionEnum.WRITE, branchToCheck, status);
+ Assert.assertTrue(status.matches());
+
+ query.branchMatches(PermissionEnum.FULLACCESS, branchToCheck, status);
+ Assert.assertFalse(status.matches());
+ }
+
+ @Test
+ public void testArtifactType() throws OseeCoreException {
+ TestObject testObject = getTestData();
+ AccessData data = testObject.getAccessData();
+ IBasicArtifact<?> artifactToCheck = testObject.getArtifact();
+
+ AccessDataQuery query = new AccessDataQuery(data);
+ PermissionStatus status = new PermissionStatus();
+
+ query.artifactTypeMatches(PermissionEnum.WRITE, artifactToCheck, status);
+ Assert.assertTrue(status.matches());
+
+ query.artifactTypeMatches(PermissionEnum.FULLACCESS, artifactToCheck, status);
+ Assert.assertFalse(status.matches());
+ }
+
+ @Test
+ public void testArtifact() throws OseeCoreException {
+ TestObject testObject = getTestData();
+ AccessData data = testObject.getAccessData();
+ IBasicArtifact<?> artifactToCheck = testObject.getArtifact();
+
+ AccessDataQuery query = new AccessDataQuery(data);
+ PermissionStatus status = new PermissionStatus();
+
+ query.artifactMatches(PermissionEnum.WRITE, artifactToCheck, status);
+ Assert.assertTrue(status.matches());
+ }
+
+ @Test
+ public void testAttributeType() throws OseeCoreException {
+ TestObject testObject = getTestData();
+ AccessData data = testObject.getAccessData();
+ IBasicArtifact<?> artifactToCheck = testObject.getArtifact();
+
+ IAttributeType attributeType = CoreAttributeTypes.PARAGRAPH_NUMBER;
+ IAttributeType wordAttributeType = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
+
+ data.add(artifactToCheck, new AccessDetail<IAttributeType>(attributeType, PermissionEnum.WRITE));
+ data.add(artifactToCheck, new AccessDetail<IAttributeType>(wordAttributeType, PermissionEnum.READ));
+
+ AccessDataQuery query = new AccessDataQuery(data);
+ PermissionStatus status = new PermissionStatus();
+
+ query.artifactMatches(PermissionEnum.WRITE, artifactToCheck, status);
+ Assert.assertTrue(status.matches());
+
+ query.attributeTypeMatches(PermissionEnum.READ, artifactToCheck, wordAttributeType, status);
+ Assert.assertTrue(status.matches());
+
+ query.attributeTypeMatches(PermissionEnum.WRITE, artifactToCheck, wordAttributeType, status);
+ Assert.assertFalse(status.matches());
+
+ query.artifactTypeMatches(PermissionEnum.WRITE, artifactToCheck, status);
+ Assert.assertTrue(status.matches());
+
+ query.artifactTypeMatches(PermissionEnum.FULLACCESS, artifactToCheck, status);
+ Assert.assertFalse(status.matches());
+ }
+
+ private TestObject getTestData() throws OseeCoreException {
+ IOseeBranch branchToCheck = CoreBranches.SYSTEM_ROOT;
+ IArtifactType artifactType = CoreArtifactTypes.AbstractSoftwareRequirement;
+ IBasicArtifact<?> artifactToCheck = new MockArtifact(GUID.create(), "Hello", branchToCheck, artifactType, 12);
+ AccessData data = new AccessData();
+
+ data.add(branchToCheck, new AccessDetail<IOseeBranch>(branchToCheck, PermissionEnum.WRITE));
+ data.add(artifactToCheck, new AccessDetail<IBasicArtifact<?>>(artifactToCheck, PermissionEnum.WRITE));
+ data.add(artifactToCheck, new AccessDetail<IArtifactType>(artifactType, PermissionEnum.WRITE));
+
+ return new TestObject(artifactToCheck, data);
+ }
+
+ private class TestObject {
+ final IBasicArtifact<?> artifact;
+ final AccessData accessData;
+
+ public TestObject(IBasicArtifact<?> artifact, AccessData accessData) {
+ super();
+ this.artifact = artifact;
+ this.accessData = accessData;
+ }
+
+ public IBasicArtifact<?> getArtifact() {
+ return artifact;
+ }
+
+ public AccessData getAccessData() {
+ return accessData;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataTest.java
new file mode 100644
index 0000000000..c87291d954
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessDataTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.PermissionEnum;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.DefaultBasicArtifact;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.access.AccessData;
+import org.eclipse.osee.framework.core.model.access.AccessDetail;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AccessData}
+ *
+ * @author Jeff C. Phillips
+ */
+public class AccessDataTest {
+
+ @Test
+ public void testAddingData() throws OseeCoreException {
+ IOseeBranch branchToCheck = CoreBranches.SYSTEM_ROOT;
+ IArtifactType artifactType = CoreArtifactTypes.AbstractSoftwareRequirement;
+ IAttributeType attributeType = CoreAttributeTypes.PARAGRAPH_NUMBER;
+ IAttributeType wordAttributeType = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
+
+ IBasicArtifact<?> artifactToCheck = new DefaultBasicArtifact(12, GUID.create(), "Hello");
+
+ AccessData data = new AccessData();
+ data.add(branchToCheck, new AccessDetail<IOseeBranch>(branchToCheck, PermissionEnum.WRITE));
+
+ data.add(artifactToCheck, new AccessDetail<IBasicArtifact<?>>(artifactToCheck, PermissionEnum.WRITE));
+ data.add(artifactToCheck, new AccessDetail<IArtifactType>(artifactType, PermissionEnum.WRITE));
+ data.add(artifactToCheck, new AccessDetail<IAttributeType>(attributeType, PermissionEnum.WRITE));
+ data.add(artifactToCheck, new AccessDetail<IAttributeType>(wordAttributeType, PermissionEnum.READ));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessFilterChainTest.java
index a132582c1a..7b0fb84b50 100644
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/AccessFilterChainTest.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.access.test.internal;
+package org.eclipse.osee.framework.core.model.test.access;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IAttributeType;
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/PermissionTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionTest.java
index 71137a2414..243ab7fece 100644
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/PermissionTest.java
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/access/PermissionTest.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.access.test.internal;
+package org.eclipse.osee.framework.core.model.test.access;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockArtifact.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockArtifact.java
new file mode 100644
index 0000000000..c8ae9cc83b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/test/mocks/MockArtifact.java
@@ -0,0 +1,54 @@
+/*
+ * Created on Jul 26, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.core.model.test.mocks;
+
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.NamedIdentity;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class MockArtifact extends NamedIdentity implements IBasicArtifact<Object> {
+
+ private final Branch branch;
+ private final ArtifactType artifactType;
+ private final int artId;
+
+ public MockArtifact(String guid, String name, IOseeBranch branch, IArtifactType artifactType, int artId) {
+ super(guid, name);
+ this.branch = new Branch(branch.getGuid(), branch.getName(), BranchType.WORKING, BranchState.MODIFIED, false);
+ this.artifactType = new ArtifactType(artifactType.getGuid(), artifactType.getName(), false);
+ this.artId = artId;
+ }
+
+ @Override
+ public int getArtId() {
+ return artId;
+ }
+
+ @Override
+ public Branch getBranch() {
+ return branch;
+ }
+
+ @Override
+ public ArtifactType getArtifactType() {
+ return artifactType;
+ }
+
+ @Override
+ public Object getFullArtifact() throws OseeCoreException {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java
deleted file mode 100644
index 21ecda833d..0000000000
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/exp/AccessCollector.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Created on Jul 20, 2010
- *
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
-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.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.model.IBasicArtifact;
-
-/**
- * @author Jeff C. Phillips
- * @param <T>
- */
-public class AccessCollector<T> {
-
- private final Collection<IAccessFilter> filters;
-
- public AccessCollector(Collection<IAccessFilter> filters) {
- this.filters = filters;
- }
-
- public List<T> getAttributeTypesToMatch(IBasicArtifact<?> artifact, Collection<T> toCheck, PermissionEnum permission) {
- List<T> validObjects = new ArrayList<T>();
- AccessFilterChain chain = new AccessFilterChain();
- chain.addAll(filters);
-
- for (T object : toCheck) {
- if (chain.doFilter(artifact, object, permission, null)) {
- validObjects.add(object);
- }
- }
- return validObjects;
- }
-}

Back to the top