Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-09 21:28:02 +0000
committerrescobar2010-08-09 21:28:02 +0000
commita07121cb68c27ded9530b6cb1a6454416d2ffebf (patch)
treee96751f20991a50a78f851d4fd5e93ff446e21be /plugins/org.eclipse.osee.framework.core.dsl.integration.test
parent1d390c3af405ffa18c5dd036a0df6fe92cc5667b (diff)
downloadorg.eclipse.osee-a07121cb68c27ded9530b6cb1a6454416d2ffebf.tar.gz
org.eclipse.osee-a07121cb68c27ded9530b6cb1a6454416d2ffebf.tar.xz
org.eclipse.osee-a07121cb68c27ded9530b6cb1a6454416d2ffebf.zip
"Team Workflow" - YGHW1 - "Block changes to requirements unless done under an appropriate action."
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.integration.test')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/AllDslIntegrationTestSuite.java1
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/OseeDslAccessModelTest.java174
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockDslProvider.java59
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockModel.java7
4 files changed, 241 insertions, 0 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 5cf50cb66b7..80d900ba79d 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
@@ -22,6 +22,7 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({ //
InternalTestSuite.class, //
DslUtilTestSuite.class, //
+ OseeDslAccessModelTest.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/OseeDslAccessModelTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/OseeDslAccessModelTest.java
new file mode 100644
index 00000000000..7aadbe94d07
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/OseeDslAccessModelTest.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import org.eclipse.osee.framework.core.data.AccessContextId;
+import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter;
+import org.eclipse.osee.framework.core.dsl.integration.OseeDslAccessModel;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockAccessContextId;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockDslProvider;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockModel;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
+import org.eclipse.osee.framework.core.enums.PermissionEnum;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.access.AccessData;
+import org.eclipse.osee.framework.core.model.access.AccessDetail;
+import org.eclipse.osee.framework.core.model.access.AccessDetailCollector;
+import org.eclipse.osee.framework.core.model.access.AccessModel;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link OseeDslAccessModel}
+ *
+ * @author Roberto E. Escobar
+ */
+public class OseeDslAccessModelTest {
+
+ private static AccessContextId accessContextId;
+
+ @BeforeClass
+ public static void setUp() {
+ accessContextId = new MockAccessContextId(GUID.create(), "Context 1");
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullAgumentCheck1() throws OseeCoreException {
+ AccessModel accessModel = new OseeDslAccessModel(null, null);
+ accessModel.computeAccess(null, new ArrayList<Object>(), new AccessData());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullAgumentCheck2() throws OseeCoreException {
+ AccessModel accessModel = new OseeDslAccessModel(null, null);
+ accessModel.computeAccess(accessContextId, null, new AccessData());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullAgumentCheck3() throws OseeCoreException {
+ AccessModel accessModel = new OseeDslAccessModel(null, null);
+ accessModel.computeAccess(accessContextId, Collections.emptyList(), null);
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullDsl() throws OseeCoreException {
+ MockDslProvider dslProvider = new MockDslProvider(null);
+ AccessModel accessModel = new OseeDslAccessModel(null, dslProvider);
+ accessModel.computeAccess(accessContextId, Collections.emptyList(), new AccessData());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullAccessContext() throws OseeCoreException {
+ MockAccessModelInterpreter interpreter = new MockAccessModelInterpreter(null);
+ MockDslProvider dslProvider = new MockDslProvider(MockModel.createDsl());
+ AccessModel accessModel = new OseeDslAccessModel(interpreter, dslProvider);
+ accessModel.computeAccess(accessContextId, Collections.emptyList(), new AccessData());
+ }
+
+ @Test
+ public void testComputeAccessTestCollection() throws OseeCoreException {
+
+ final Object checkedObject = new Object();
+
+ final AccessDetail<?> detail1 = new AccessDetail<Object>(checkedObject, PermissionEnum.READ, "detail 1");
+ final AccessDetail<?> detail2 = new AccessDetail<Object>(checkedObject, PermissionEnum.WRITE, "detail 2");
+
+ final AccessData accessData = new AccessData();
+
+ final AccessContext accessContext = MockModel.createAccessContext(GUID.create(), "Access Context");
+
+ OseeDsl oseeDsl = MockModel.createDsl();
+ oseeDsl.getAccessDeclarations().add(accessContext);
+
+ MockDslProvider dslProvider = new MockDslProvider(oseeDsl);
+ MockAccessModelInterpreter interpreter = new MockAccessModelInterpreter(accessContext) {
+
+ @Override
+ public void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) throws OseeCoreException {
+ super.computeAccessDetails(collector, accessContext, objectToCheck);
+ Assert.assertEquals(accessContext, context);
+ Assert.assertEquals(checkedObject, objectToCheck);
+ Assert.assertNotNull(collector);
+
+ Assert.assertTrue(accessData.isEmpty());
+
+ collector.collect(detail1);
+ collector.collect(detail2);
+ }
+
+ };
+
+ AccessModel accessModel = new OseeDslAccessModel(interpreter, dslProvider);
+ accessModel.computeAccess(accessContextId, Collections.singleton(checkedObject), accessData);
+
+ Assert.assertEquals(accessContextId, interpreter.getContextId());
+ Collection<AccessContext> context = interpreter.getContexts();
+ Assert.assertEquals(1, context.size());
+ Assert.assertEquals(accessContext, context.iterator().next());
+ Assert.assertTrue(interpreter.wasComputeCalled());
+
+ Assert.assertFalse(accessData.isEmpty());
+ Collection<AccessDetail<?>> details = accessData.getAccess(checkedObject);
+ Assert.assertEquals(1, details.size());
+
+ AccessDetail<?> actualDetail = details.iterator().next();
+ Assert.assertEquals(PermissionEnum.READ, actualDetail.getPermission());
+ Assert.assertEquals("detail 1", actualDetail.getReason());
+ Assert.assertEquals(checkedObject, actualDetail.getAccessObject());
+ Assert.assertEquals(detail1, actualDetail);
+ }
+
+ private static class MockAccessModelInterpreter implements AccessModelInterpreter {
+
+ private final AccessContext contextToReturn;
+ private Collection<AccessContext> contexts;
+ private AccessContextId contextId;
+ private boolean wasComputeCalled;
+
+ public MockAccessModelInterpreter(AccessContext contextToReturn) {
+ this.contextToReturn = contextToReturn;
+ }
+
+ public Collection<AccessContext> getContexts() {
+ return contexts;
+ }
+
+ public AccessContextId getContextId() {
+ return contextId;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public AccessContext getContext(Collection<AccessContext> contexts, AccessContextId contextId) throws OseeCoreException {
+ this.contextId = contextId;
+ this.contexts = contexts;
+ return contextToReturn;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) throws OseeCoreException {
+ //
+ wasComputeCalled = true;
+ }
+
+ public boolean wasComputeCalled() {
+ return wasComputeCalled;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockDslProvider.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockDslProvider.java
new file mode 100644
index 00000000000..fc06ae804d5
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockDslProvider.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.mocks;
+
+import org.eclipse.osee.framework.core.dsl.integration.OseeDslProvider;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockDslProvider implements OseeDslProvider {
+
+ private final OseeDsl dslToReturn;
+
+ private boolean wasLoadDslCalled;
+ private boolean wasGetDslCalled;
+ private OseeDsl dslToStore;
+
+ public MockDslProvider(OseeDsl dslToReturn) {
+ this.dslToReturn = dslToReturn;
+ }
+
+ @Override
+ public void loadDsl() {
+ wasLoadDslCalled = true;
+ }
+
+ @Override
+ public OseeDsl getDsl() {
+ wasGetDslCalled = true;
+ return dslToReturn;
+ }
+
+ @Override
+ public void storeDsl(OseeDsl dsl) {
+ dslToStore = dsl;
+ }
+
+ public OseeDsl getDslToStore() {
+ return dslToStore;
+ }
+
+ public boolean wasLoadDslCalled() {
+ return wasLoadDslCalled;
+ }
+
+ public boolean wasGetDslCalled() {
+ return wasGetDslCalled;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockModel.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockModel.java
index 9f93f274ed0..8276d1da9b5 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockModel.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockModel.java
@@ -16,6 +16,7 @@ import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactInstanceRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
+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.RelationTypeRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactRef;
@@ -32,6 +33,12 @@ public final class MockModel {
// Utility class
}
+ public static OseeDsl createDsl() {
+ OseeDsl dsl = OseeDslFactory.eINSTANCE.createOseeDsl();
+ Assert.assertNotNull(dsl);
+ return dsl;
+ }
+
public static AccessContext createAccessContext(String guid, String name) {
AccessContext toReturn = OseeDslFactory.eINSTANCE.createAccessContext();
Assert.assertNotNull(toReturn);

Back to the top