Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2010-07-20 15:26:34 -0400
committerjphillips2010-07-20 15:26:34 -0400
commit3adc5fa026233019214bf8ec5f153da04fa84224 (patch)
treeea40cce0ef96355e9097263c4111987bfdb047ff /plugins/org.eclipse.osee.framework.access.test
parent40625015d8b817e888f9aeb092dc8065f1ebf94b (diff)
downloadorg.eclipse.osee-3adc5fa026233019214bf8ec5f153da04fa84224.tar.gz
org.eclipse.osee-3adc5fa026233019214bf8ec5f153da04fa84224.tar.xz
org.eclipse.osee-3adc5fa026233019214bf8ec5f153da04fa84224.zip
Commit blocking changes support
Diffstat (limited to 'plugins/org.eclipse.osee.framework.access.test')
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java84
2 files changed, 85 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.access.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.access.test/META-INF/MANIFEST.MF
index 6f340478e5..39eff82ef3 100644
--- a/plugins/org.eclipse.osee.framework.access.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.access.test/META-INF/MANIFEST.MF
@@ -8,3 +8,4 @@ Fragment-Host: org.eclipse.osee.framework.access;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.access.test
+Import-Package: org.eclipse.osee.framework.core.model.access.exp
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.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java
new file mode 100644
index 0000000000..c32e2ed9df
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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 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.AccessFilterChain;
+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.junit.Test;
+
+/**
+ * Test Case for {@link AccessFilterChain}
+ *
+ * @author Jeff C. Phillips
+ */
+public class AccessFilterChainTest {
+
+ @Test
+ public void testUseCase1() {
+ //Can we edit this attribute on an artifact
+ AccessFilterChain chain = new AccessFilterChain();
+ IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
+ IAttributeType wordAttribute = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
+
+ BranchAccessFilter branchAccessFilter = new BranchAccessFilter(PermissionEnum.READ);
+ ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(PermissionEnum.WRITE, basicArtifact);
+ AttributeTypeAccessFilter attributeTypeAccessFilter =
+ new AttributeTypeAccessFilter(PermissionEnum.WRITE, basicArtifact);
+
+ chain.add(artifactAccessFilter);
+ chain.add(branchAccessFilter);
+
+ PermissionEnum agrPermission = null;
+ Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.READ, agrPermission));
+ Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.WRITE, agrPermission));
+ }
+
+ @Test
+ public void testChain() {
+ AccessFilterChain chain = new AccessFilterChain();
+ IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
+
+ BranchAccessFilter branchAccessFilter = new BranchAccessFilter(PermissionEnum.READ);
+ ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(PermissionEnum.WRITE);
+ AttributeTypeAccessFilter attributeTypeAccessFilter =
+ new AttributeTypeAccessFilter(PermissionEnum.WRITE, basicArtifact);
+
+ chain.add(artifactAccessFilter);
+ chain.add(branchAccessFilter);
+
+ PermissionEnum agrPermission = null;
+ Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.READ, agrPermission));
+ Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.WRITE, agrPermission));
+ }
+
+ @Test
+ public void testChainDeny() {
+ AccessFilterChain chain = new AccessFilterChain();
+ BranchAccessFilter branchAccessFilter = new BranchAccessFilter(PermissionEnum.DENY);
+ ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(PermissionEnum.WRITE);
+
+ chain.add(artifactAccessFilter);
+ chain.add(branchAccessFilter);
+
+ IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
+ PermissionEnum agrPermission = null;
+ Assert.assertFalse(chain.doFilter(basicArtifact, PermissionEnum.READ, agrPermission));
+ Assert.assertFalse(chain.doFilter(basicArtifact, PermissionEnum.WRITE, agrPermission));
+ }
+}

Back to the top