Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-05 20:07:08 -0400
committerrescobar2010-08-05 20:07:08 -0400
commite9583f176b3bd6e378792164817871dae063d76b (patch)
tree97b6c0ef8ef506eea2cefb4470e3a0391fefb0c3 /plugins/org.eclipse.osee.framework.access.test
parentf8ae36f1ea055f1684ef9ec9186f8a9973f2dc85 (diff)
downloadorg.eclipse.osee-e9583f176b3bd6e378792164817871dae063d76b.tar.gz
org.eclipse.osee-e9583f176b3bd6e378792164817871dae063d76b.tar.xz
org.eclipse.osee-e9583f176b3bd6e378792164817871dae063d76b.zip
"Team Workflow" - YGHW1 - "Block changes to requirements unless done under an appropriate action."
Diffstat (limited to 'plugins/org.eclipse.osee.framework.access.test')
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessProviderTest.java34
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessTestSuite.java1
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/ConfigurationManagementProviderTest.java59
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/DefaultConfigurationManagementTest.java29
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockCMWithAccessModel.java41
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagement.java63
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagementProvider.java45
7 files changed, 222 insertions, 50 deletions
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessProviderTest.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessProviderTest.java
index 1d86910d91..119f5712a5 100644
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessProviderTest.java
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessProviderTest.java
@@ -10,10 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.framework.access.test.internal.cm;
-import org.eclipse.osee.framework.access.IAccessProvider;
+import java.util.Collection;
import org.eclipse.osee.framework.access.internal.cm.CMAccessProvider;
-import org.eclipse.osee.framework.core.services.ConfigurationManagementProvider;
-import org.junit.Assert;
+import org.eclipse.osee.framework.core.data.AccessContextId;
+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.AccessModel;
import org.junit.Test;
/**
@@ -25,9 +27,27 @@ public class CMAccessProviderTest {
@Test
public void testCMAccessProvider() {
- Assert.assertFalse(true);
- ConfigurationManagementProvider provider = null;
- IAccessProvider accessProvider = new CMAccessProvider(provider);
- // accessProvider.computeAccess(userArtifact, objToCheck, accessData);
+ IBasicArtifact<?> expectedUser = null;
+ Object expectedObject = null;
+ //
+ // AccessData expectedAccessData = new AccessData();
+ //
+ // AccessModel accessModel = new MockAccessModel();
+ // ConfigurationManagement cm =
+ // new MockCMWithAccessModel(accessModel, expectedUser, expectedObject, true,
+ // Collections.singleton((AccessContextId) CoreAccessContextIds.DEFAULT_SYSTEM_CONTEXT_ID));
+ // ConfigurationManagementProvider provider =
+ // new MockConfigurationManagementProvider(expectedUser, expectedObject, cm);
+ //
+ // IAccessProvider accessProvider = new CMAccessProvider(provider);
+ // accessProvider.computeAccess(expectedUser, expectedObject, expectedAccessData);
}
+
+ private final static class MockAccessModel implements AccessModel {
+
+ @Override
+ public void computeAccess(AccessContextId contextId, Collection<Object> objectsToCheck, AccessData accessData) {
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessTestSuite.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessTestSuite.java
index b12a84e2ff..ba349a18f1 100644
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/CMAccessTestSuite.java
@@ -17,7 +17,6 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({ //
CMAccessProviderTest.class, //
ConfigurationManagementProviderTest.class, //
- DefaultConfigurationManagementTest.class, //
})
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/ConfigurationManagementProviderTest.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/ConfigurationManagementProviderTest.java
index b0699ed0f6..572228a913 100644
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/ConfigurationManagementProviderTest.java
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/ConfigurationManagementProviderTest.java
@@ -10,13 +10,18 @@
*******************************************************************************/
package org.eclipse.osee.framework.access.test.internal.cm;
+import java.util.Collection;
+import java.util.HashSet;
import org.eclipse.osee.framework.access.internal.cm.ConfigurationManagementProviderImpl;
-import org.eclipse.osee.framework.core.data.AccessContextId;
+import org.eclipse.osee.framework.access.test.mocks.MockConfigurationManagement;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.test.mocks.MockDataFactory;
import org.eclipse.osee.framework.core.services.ConfigurationManagement;
import org.eclipse.osee.framework.core.services.ConfigurationManagementProvider;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -26,23 +31,51 @@ import org.junit.Test;
*/
public class ConfigurationManagementProviderTest {
+ private IBasicArtifact<?> user;
+ private Object objectToCheck;
+
+ @Before
+ public void setup() {
+ user = MockDataFactory.createArtifact(4);
+ objectToCheck = new Object();
+ }
+
@Test
- public void testX() {
- Assert.assertTrue(false);
- // ConfigurationManagementProvider provider = new ConfigurationManagementProviderImpl(ConfigurationManagement defaultCM, Collection<ConfigurationManagement> cmServices);
- // ConfigurationManagement getCmService(IBasicArtifact<?> user, Object object)
+ public void testNoCms() throws OseeCoreException {
+ assertCMProvider(user, objectToCheck, null);
}
- private static final class MockConfigurationManagement implements ConfigurationManagement {
+ @Test
+ public void testCmButNotApplicable() throws OseeCoreException {
+ MockConfigurationManagement cm1 = new MockConfigurationManagement(user, objectToCheck, false, null);
+ assertCMProvider(user, objectToCheck, null, cm1);
+ }
- @Override
- public boolean isApplicable(IBasicArtifact<?> userArtifact, Object object) {
- return true;
- }
+ @Test
+ public void testExtraCmApplicable() throws OseeCoreException {
+ MockConfigurationManagement cm1 = new MockConfigurationManagement(user, objectToCheck, false, null);
+ MockConfigurationManagement cm2 = new MockConfigurationManagement(user, objectToCheck, true, null);
+ assertCMProvider(user, objectToCheck, cm2, cm1, cm2);
+ }
- @Override
- public AccessContextId getContextId(IBasicArtifact<?> userArtifact, Object itemToCheck) throws OseeCoreException {
- return null;
+ @Test(expected = OseeStateException.class)
+ public void testMoreThanOneCMApplies() throws OseeCoreException {
+ MockConfigurationManagement cm1 = new MockConfigurationManagement(user, objectToCheck, true, null);
+ MockConfigurationManagement cm2 = new MockConfigurationManagement(user, objectToCheck, true, null);
+ assertCMProvider(user, objectToCheck, null, cm1, cm2);
+ }
+
+ private static void assertCMProvider(IBasicArtifact<?> user, Object objectToCheck, MockConfigurationManagement expectedCM, MockConfigurationManagement... extraCms) throws OseeCoreException {
+ Collection<ConfigurationManagement> cmServices = new HashSet<ConfigurationManagement>();
+ for (ConfigurationManagement extraCm : extraCms) {
+ cmServices.add(extraCm);
+ }
+ ConfigurationManagementProvider provider = new ConfigurationManagementProviderImpl(cmServices);
+ ConfigurationManagement actualCM = provider.getCmService(user, objectToCheck);
+ Assert.assertEquals(expectedCM, actualCM);
+ for (ConfigurationManagement cmService : cmServices) {
+ MockConfigurationManagement cm = (MockConfigurationManagement) cmService;
+ Assert.assertTrue(cm.wasIsApplicableCalled());
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/DefaultConfigurationManagementTest.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/DefaultConfigurationManagementTest.java
deleted file mode 100644
index d4e6796417..0000000000
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/cm/DefaultConfigurationManagementTest.java
+++ /dev/null
@@ -1,29 +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.access.test.internal.cm;
-
-import org.eclipse.osee.framework.access.internal.cm.DefaultConfigurationManagement;
-import org.eclipse.osee.framework.core.services.ConfigurationManagement;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test Case for {@link DefaultConfigurationManagement}{@link ConfigurationManagement}
- *
- * @author Roberto E. Escobar
- */
-public class DefaultConfigurationManagementTest {
-
- @Test
- public void testX() {
- Assert.assertFalse(true);
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockCMWithAccessModel.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockCMWithAccessModel.java
new file mode 100644
index 0000000000..cd741cd5de
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockCMWithAccessModel.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.access.test.mocks;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.AccessContextId;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.access.AccessModel;
+import org.eclipse.osee.framework.core.model.access.HasAccessModel;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class MockCMWithAccessModel extends MockConfigurationManagement implements HasAccessModel {
+
+ private final AccessModel accessModel;
+ private boolean wasGetAccessModelCalled;
+
+ public MockCMWithAccessModel(AccessModel accessModel, IBasicArtifact<?> expectedUser, Object expectedObject, boolean isApplicable, Collection<AccessContextId> contextIds) {
+ super(expectedUser, expectedObject, isApplicable, contextIds);
+ this.accessModel = accessModel;
+ }
+
+ @Override
+ public AccessModel getAccessModel() {
+ this.wasGetAccessModelCalled = true;
+ return accessModel;
+ }
+
+ public boolean wasAccessModelCalled() {
+ return wasGetAccessModelCalled;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagement.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagement.java
new file mode 100644
index 0000000000..ad1b7342b3
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagement.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.access.test.mocks;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.AccessContextId;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.services.ConfigurationManagement;
+import org.junit.Assert;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockConfigurationManagement implements ConfigurationManagement {
+
+ private final IBasicArtifact<?> expectedUser;
+ private final Object expectedObject;
+ private final boolean isApplicable;
+ private final Collection<AccessContextId> contextIds;
+ private boolean wasIsApplicableCalled;
+ private boolean wasGetContextIdCalled;
+
+ public MockConfigurationManagement(IBasicArtifact<?> expectedUser, Object expectedObject, boolean isApplicable, Collection<AccessContextId> contextIds) {
+ super();
+ this.expectedUser = expectedUser;
+ this.expectedObject = expectedObject;
+ this.isApplicable = isApplicable;
+ this.contextIds = contextIds;
+ }
+
+ @Override
+ public boolean isApplicable(IBasicArtifact<?> user, Object object) {
+ wasIsApplicableCalled = true;
+ Assert.assertEquals(expectedUser, user);
+ Assert.assertEquals(expectedObject, object);
+ return isApplicable;
+ }
+
+ @Override
+ public Collection<AccessContextId> getContextId(IBasicArtifact<?> user, Object object) {
+ wasGetContextIdCalled = true;
+ Assert.assertEquals(expectedUser, user);
+ Assert.assertEquals(expectedObject, object);
+ return contextIds;
+ }
+
+ public boolean wasIsApplicableCalled() {
+ return wasIsApplicableCalled;
+ }
+
+ public boolean wasGetContextIdCalled() {
+ return wasGetContextIdCalled;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagementProvider.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagementProvider.java
new file mode 100644
index 0000000000..6643b3f3dc
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/mocks/MockConfigurationManagementProvider.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.access.test.mocks;
+
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.services.ConfigurationManagement;
+import org.eclipse.osee.framework.core.services.ConfigurationManagementProvider;
+import org.junit.Assert;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockConfigurationManagementProvider implements ConfigurationManagementProvider {
+ private final IBasicArtifact<?> expectedUser;
+ private final Object expectedObject;
+ private final ConfigurationManagement cmToReturn;
+ private boolean wasGetCMCalled;
+
+ public MockConfigurationManagementProvider(IBasicArtifact<?> expectedUser, Object expectedObject, ConfigurationManagement cmToReturn) {
+ super();
+ this.expectedUser = expectedUser;
+ this.expectedObject = expectedObject;
+ this.cmToReturn = cmToReturn;
+ }
+
+ @Override
+ public ConfigurationManagement getCmService(IBasicArtifact<?> user, Object object) {
+ wasGetCMCalled = true;
+ Assert.assertEquals(expectedUser, user);
+ Assert.assertEquals(expectedObject, object);
+ return cmToReturn;
+ }
+
+ public boolean wasGetCMCalled() {
+ return wasGetCMCalled;
+ }
+} \ No newline at end of file

Back to the top