Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-05 01:46:46 +0000
committerrescobar2010-08-05 01:46:46 +0000
commitf21c3ec19a963e1d794924a00690f43588014f4b (patch)
treefa2110ff47a19361629a386e2734faf028bac47e /plugins/org.eclipse.osee.framework.core.dsl.integration.test
parent0a15e32ada695990f9ee69c7c8da1809e0e87e97 (diff)
downloadorg.eclipse.osee-f21c3ec19a963e1d794924a00690f43588014f4b.tar.gz
org.eclipse.osee-f21c3ec19a963e1d794924a00690f43588014f4b.tar.xz
org.eclipse.osee-f21c3ec19a963e1d794924a00690f43588014f4b.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/internal/AccessModelInterpreterImplTest.java141
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/InternalTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/OseeAccessModelInterpreterTest.java65
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/CheckAccessDetailCollectorNotCalled.java27
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockArtifactDataProvider.java60
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockRestrictionHandler.java57
6 files changed, 286 insertions, 66 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/AccessModelInterpreterImplTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/AccessModelInterpreterImplTest.java
new file mode 100644
index 00000000000..b5f30e6d1ec
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/AccessModelInterpreterImplTest.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.dsl.integration.test.internal;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.dsl.integration.internal.AccessModelInterpreterImpl;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.CheckAccessDetailCollectorNotCalled;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockAccessContextId;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockArtifactDataProvider;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockModel;
+import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockRestrictionHandler;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.access.AccessDetailCollector;
+import org.eclipse.osee.framework.core.model.test.mocks.MockAccessDetailCollector;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AccessModelInterpreterImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccessModelInterpreterImplTest {
+ private MockAccessContextId contextId1;
+ private MockAccessContextId contextId2;
+
+ private AccessContext expectedContext1;
+ private AccessContext expectedContext2;
+
+ private AccessModelInterpreterImpl interpreterNoArtData;
+
+ @Before
+ public void setup() {
+ interpreterNoArtData = new AccessModelInterpreterImpl(null);
+
+ contextId1 = new MockAccessContextId(GUID.create(), "Context 1");
+ contextId2 = new MockAccessContextId(GUID.create(), "Context 2");
+
+ expectedContext1 = MockModel.createAccessContext(contextId1.getGuid(), "c1");
+ expectedContext2 = MockModel.createAccessContext(contextId2.getGuid(), "c2");
+ }
+
+ @Test
+ public void testGetContext() throws OseeCoreException {
+
+ Collection<AccessContext> contexts = Arrays.asList(expectedContext1, expectedContext2);
+ AccessContext actualContext1 = interpreterNoArtData.getContext(contexts, contextId1);
+ Assert.assertEquals(expectedContext1, actualContext1);
+
+ AccessContext actualContext2 = interpreterNoArtData.getContext(contexts, contextId2);
+ Assert.assertEquals(expectedContext2, actualContext2);
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testGetContextNullCheck1() throws OseeCoreException {
+ interpreterNoArtData.getContext(null, contextId1);
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testGetContextNullCheck2() throws OseeCoreException {
+ interpreterNoArtData.getContext(Collections.<AccessContext> emptyList(), null);
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullCheck1() throws OseeCoreException {
+ interpreterNoArtData.computeAccessDetails(null, expectedContext1, new Object());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullCheck2() throws OseeCoreException {
+ interpreterNoArtData.computeAccessDetails(new MockAccessDetailCollector(), null, new Object());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessNullCheck3() throws OseeCoreException {
+ interpreterNoArtData.computeAccessDetails(new MockAccessDetailCollector(), expectedContext1, null);
+ }
+
+ @Test
+ public void testComputeAccessNotApplicableObject() throws OseeCoreException {
+ final Object objectToCheck = new Object();
+ MockArtifactDataProvider provider = new MockArtifactDataProvider(false, objectToCheck, null);
+ AccessModelInterpreterImpl interpreter = new AccessModelInterpreterImpl(provider);
+ interpreter.computeAccessDetails(new CheckAccessDetailCollectorNotCalled(), expectedContext1, objectToCheck);
+ Assert.assertTrue("Provider isApplicableCalled failed", provider.wasIsApplicableCalled());
+ Assert.assertFalse("Provider asCastedObjectCalled failed", provider.wasAsCastedObjectCalled());
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testComputeAccessCastedObjectNull() throws OseeCoreException {
+ final Object objectToCheck = new Object();
+ MockArtifactDataProvider provider = new MockArtifactDataProvider(true, objectToCheck, null);
+ AccessModelInterpreterImpl interpreter = new AccessModelInterpreterImpl(provider);
+ try {
+ interpreter.computeAccessDetails(new CheckAccessDetailCollectorNotCalled(), expectedContext1, objectToCheck);
+ } finally {
+ Assert.assertTrue("Provider isApplicableCalled failed", provider.wasIsApplicableCalled());
+ Assert.assertTrue("Provider asCastedObjectCalled failed", provider.wasAsCastedObjectCalled());
+ }
+ }
+
+ @Test
+ public void testComputeAccessCheckRestriction() throws OseeCoreException {
+ AccessContext accessContext = MockModel.createAccessContext(contextId2.getGuid(), "c2");
+
+ MockArtifactData artifactData = new MockArtifactData("1234", null);
+
+ ObjectRestriction objectRestriction = null;
+ assertComputeDetails(accessContext, artifactData, objectRestriction, false);
+ }
+
+ private static void assertComputeDetails(AccessContext accessContext, MockArtifactData artifactData, ObjectRestriction objectRestriction, boolean expectedProcessCalled) throws OseeCoreException {
+ final Object objectToCheck = new Object();
+ MockArtifactDataProvider provider = new MockArtifactDataProvider(true, objectToCheck, artifactData);
+ AccessDetailCollector collector = new CheckAccessDetailCollectorNotCalled();
+ MockRestrictionHandler restrictionHandler =
+ new MockRestrictionHandler(objectRestriction, artifactData, collector);
+ AccessModelInterpreterImpl interpreter = new AccessModelInterpreterImpl(provider, restrictionHandler);
+ interpreter.computeAccessDetails(collector, accessContext, objectToCheck);
+ Assert.assertTrue("Provider isApplicableCalled failed", provider.wasIsApplicableCalled());
+ Assert.assertTrue("Provider asCastedObjectCalled failed", provider.wasAsCastedObjectCalled());
+ Assert.assertEquals("Restriction process called check failed", expectedProcessCalled,
+ restrictionHandler.wasProcessCalled());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/InternalTestSuite.java
index f1cbcf28cab..081ac03598a 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/InternalTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/InternalTestSuite.java
@@ -22,7 +22,7 @@ ArtifactInstanceRestrictionHandlerTest.class, //
ArtifactTypeRestrictionHandlerTest.class, //
AttributeTypeRestrictionHandlerTest.class, //
RelationTypeRestrictionHandlerTest.class, //
- OseeAccessModelInterpreterTest.class, //
+ AccessModelInterpreterImplTest.class, //
})
public class InternalTestSuite {
// Test Suite
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/OseeAccessModelInterpreterTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/OseeAccessModelInterpreterTest.java
deleted file mode 100644
index 75ed3ad6d05..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/OseeAccessModelInterpreterTest.java
+++ /dev/null
@@ -1,65 +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.core.dsl.integration.test.internal;
-
-import java.util.Arrays;
-import java.util.Collection;
-import junit.framework.Assert;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider;
-import org.eclipse.osee.framework.core.dsl.integration.ModelUtil;
-import org.eclipse.osee.framework.core.dsl.integration.internal.AccessModelInterpreterImpl;
-import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockAccessContextId;
-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.jdk.core.util.GUID;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test Case for {@link ModelUtil}
- *
- * @author Roberto E. Escobar
- */
-public class OseeAccessModelInterpreterTest {
- private static final MockAccessContextId CONTEXT_1 = new MockAccessContextId(GUID.create(), "Context 1");
- private static final MockAccessContextId CONTEXT_2 = new MockAccessContextId(GUID.create(), "Context 2");
- private static final MockAccessContextId FULL_CONTEXT = null;
-
- private AccessModelInterpreterImpl interpreter;
-
- @Before
- public void setup() {
- ArtifactDataProvider accessor = null;
- interpreter = new AccessModelInterpreterImpl(accessor);
- }
-
- @Test
- public void testGetContext() {
- AccessContext expectedContext1 = MockModel.createAccessContext(CONTEXT_1.getGuid(), "c1");
- AccessContext expectedContext2 = MockModel.createAccessContext(CONTEXT_2.getGuid(), "c2");
-
- Collection<AccessContext> contexts = Arrays.asList(expectedContext1, expectedContext2);
-
- AccessContext actualContext1 = interpreter.getContext(contexts, CONTEXT_1);
- Assert.assertEquals(expectedContext1, actualContext1);
-
- AccessContext actualContext2 = interpreter.getContext(contexts, CONTEXT_2);
- Assert.assertEquals(expectedContext2, actualContext2);
- }
-
- // @Test
- // public void testComputeAccessDetails() {
- // Collection<AccessDetail<?>> details = new ArrayList<AccessDetail<?>>();
- //
- // // interpreter.computeAccessDetails(FULL_CONTEXT, objectToCheck, details);
- // }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/CheckAccessDetailCollectorNotCalled.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/CheckAccessDetailCollectorNotCalled.java
new file mode 100644
index 00000000000..96c13e00eec
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/CheckAccessDetailCollectorNotCalled.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.model.access.AccessDetail;
+import org.eclipse.osee.framework.core.model.access.AccessDetailCollector;
+import org.junit.Assert;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class CheckAccessDetailCollectorNotCalled implements AccessDetailCollector {
+
+ @Override
+ public void collect(AccessDetail<?> accessDetail) {
+ Assert.fail("Method was unexpectedly called");
+ }
+
+}; \ 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/MockArtifactDataProvider.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockArtifactDataProvider.java
new file mode 100644
index 00000000000..0d23171ba36
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockArtifactDataProvider.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.ArtifactDataProvider;
+import org.junit.Assert;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class MockArtifactDataProvider implements ArtifactDataProvider {
+
+ private final boolean isApplicable;
+ private final Object expectedObject;
+ private final ArtifactData artifactData;
+ private boolean wasIsApplicableCalled;
+ private boolean wasAsCastedObjectCalled;
+
+ public MockArtifactDataProvider(boolean isApplicable, Object expectedObject, ArtifactData artifactData) {
+ this.isApplicable = isApplicable;
+ this.expectedObject = expectedObject;
+ this.artifactData = artifactData;
+ reset();
+ }
+
+ public void reset() {
+ wasIsApplicableCalled = false;
+ wasAsCastedObjectCalled = false;
+ }
+
+ @Override
+ public boolean isApplicable(Object object) {
+ wasIsApplicableCalled = true;
+ Assert.assertEquals(expectedObject, object);
+ return isApplicable;
+ }
+
+ @Override
+ public ArtifactData asCastedObject(Object object) {
+ wasAsCastedObjectCalled = true;
+ Assert.assertEquals(expectedObject, object);
+ return artifactData;
+ }
+
+ public boolean wasIsApplicableCalled() {
+ return wasIsApplicableCalled;
+ }
+
+ public boolean wasAsCastedObjectCalled() {
+ return wasAsCastedObjectCalled;
+ }
+} \ 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/MockRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockRestrictionHandler.java
new file mode 100644
index 00000000000..28328587b8f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/mocks/MockRestrictionHandler.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.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.model.access.AccessDetailCollector;
+import org.junit.Assert;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockRestrictionHandler implements RestrictionHandler<Object> {
+
+ private final ObjectRestriction expectedObjectRestriction;
+ private final ArtifactData expectedArtifactData;
+ private final AccessDetailCollector expectedCollector;
+ private boolean wasProcessCalled;
+
+ public MockRestrictionHandler(ObjectRestriction expectedObjectRestriction, ArtifactData expectedArtifactData, AccessDetailCollector expectedCollector) {
+ super();
+ this.expectedObjectRestriction = expectedObjectRestriction;
+ this.expectedArtifactData = expectedArtifactData;
+ this.expectedCollector = expectedCollector;
+ reset();
+ }
+
+ @Override
+ public Object asCastedObject(ObjectRestriction objectRestriction) {
+ return null;
+ }
+
+ public void reset() {
+ wasProcessCalled = false;
+ }
+
+ public boolean wasProcessCalled() {
+ return wasProcessCalled;
+ }
+
+ @Override
+ public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) {
+ wasProcessCalled = true;
+ Assert.assertEquals(expectedObjectRestriction, objectRestriction);
+ Assert.assertEquals(expectedArtifactData, artifactData);
+ Assert.assertEquals(expectedCollector, collector);
+ }
+} \ No newline at end of file

Back to the top