Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2014-05-28 18:37:53 +0000
committerDonald Dunne2014-06-02 18:50:51 +0000
commit4dc723a175e57ceed0cf183822b4246b5cd45254 (patch)
tree976c2485418e0a4d53f1ea23f95989869bce542f /plugins/org.eclipse.osee.ats.core.test
parent6ee7512b783106e243a740cde0fab375a6bf5c07 (diff)
downloadorg.eclipse.osee-4dc723a175e57ceed0cf183822b4246b5cd45254.tar.gz
org.eclipse.osee-4dc723a175e57ceed0cf183822b4246b5cd45254.tar.xz
org.eclipse.osee-4dc723a175e57ceed0cf183822b4246b5cd45254.zip
feature[ats_ATS34674]: Allow custom ATS Id configuration by team
Diffstat (limited to 'plugins/org.eclipse.osee.ats.core.test')
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AllAtsCoreTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsCore_Internal_Util_Suite.java23
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsIdProviderTest.java123
3 files changed, 148 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AllAtsCoreTestSuite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AllAtsCoreTestSuite.java
index f066202ece8..5cb73d03641 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AllAtsCoreTestSuite.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AllAtsCoreTestSuite.java
@@ -15,6 +15,7 @@ import org.eclipse.osee.ats.core.column.AtsCore_Column_JT_Suite;
import org.eclipse.osee.ats.core.internal.column.ev.AtsCore_InternalColumnEv_JT_Suite;
import org.eclipse.osee.ats.core.internal.log.AtsTest_Internal_Log_Suite;
import org.eclipse.osee.ats.core.internal.state.AtsCore_Internal_State_Suite;
+import org.eclipse.osee.ats.core.internal.util.AtsCore_Internal_Util_Suite;
import org.eclipse.osee.ats.core.model.impl.AtsCore_ModelImpl_JT_Suite;
import org.eclipse.osee.ats.core.transition.AtsCore_Transition_JT_Suite;
import org.eclipse.osee.ats.core.users.AtsCore_Users_JT_Suite;
@@ -32,6 +33,7 @@ import org.junit.runners.Suite;
AtsCore_Column_JT_Suite.class,
AtsTest_Internal_Log_Suite.class,
AtsCore_Internal_State_Suite.class,
+ AtsCore_Internal_Util_Suite.class,
AtsCore_Workflow_Transition_Suite.class,
AtsCore_InternalColumnEv_JT_Suite.class,
AtsCore_ModelImpl_JT_Suite.class,
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsCore_Internal_Util_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsCore_Internal_Util_Suite.java
new file mode 100644
index 00000000000..3c024358dbb
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsCore_Internal_Util_Suite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ats.core.internal.util;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({AtsIdProviderTest.class})
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Internal_Util_Suite {
+ // TestSuite
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsIdProviderTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsIdProviderTest.java
new file mode 100644
index 00000000000..ed870594450
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/internal/util/AtsIdProviderTest.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ats.core.internal.util;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.ats.api.IAtsObject;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
+import org.eclipse.osee.ats.api.util.ISequenceProvider;
+import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link AtsIdProvider}
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsIdProviderTest {
+
+ // @formatter:off
+ @Mock private ISequenceProvider sequenceProvider;
+ @Mock private IAttributeResolver attrResolver;
+ @Mock private IAtsObject newObject;
+ @Mock private IAtsTeamDefinition teamDef;
+ @Mock private IAtsTeamDefinition parentTeamDef;
+ // @formatter:on
+
+ AtsIdProvider atsIdProvider = null;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ atsIdProvider = new AtsIdProvider(sequenceProvider, attrResolver, newObject, teamDef);
+
+ when(sequenceProvider.getNext("ATS_SEQ")).thenReturn(345L);
+ }
+
+ @Test
+ public void testGetNextId() {
+ Assert.assertEquals("ATS345", atsIdProvider.getNextId("ATS", "ATS_SEQ"));
+ }
+
+ @Test
+ public void testGetAttrValue() {
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdPrefix, (String) null)).thenReturn(
+ null);
+ when(teamDef.getTeamDefinitionHoldingVersions()).thenReturn(null);
+
+ Assert.assertNull(atsIdProvider.getAttrValue(AtsAttributeTypes.AtsIdPrefix));
+
+ when(teamDef.getTeamDefinitionHoldingVersions()).thenReturn(parentTeamDef);
+ when(attrResolver.getSoleAttributeValueAsString(parentTeamDef, AtsAttributeTypes.AtsIdPrefix, (String) null)).thenReturn(
+ "ATS");
+
+ Assert.assertEquals("ATS", atsIdProvider.getAttrValue(AtsAttributeTypes.AtsIdPrefix));
+
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdPrefix, (String) null)).thenReturn(
+ "TEST");
+
+ Assert.assertEquals("TEST", atsIdProvider.getAttrValue(AtsAttributeTypes.AtsIdPrefix));
+ }
+
+ @Test
+ public void testGetNextAtsId() {
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdPrefix, (String) null)).thenReturn(
+ "ASDF");
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdSequenceName, (String) null)).thenReturn(
+ "ASDF_SEQ");
+ when(sequenceProvider.getNext("ASDF_SEQ")).thenReturn(333L);
+
+ Assert.assertEquals("ASDF333", atsIdProvider.getNextAtsId());
+ }
+
+ @Test
+ public void testSetAtsId() {
+ when(attrResolver.getSoleAttributeValueAsString(newObject, AtsAttributeTypes.AtsId, (String) null)).thenReturn(
+ null);
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdPrefix, (String) null)).thenReturn(
+ "ASDF");
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdSequenceName, (String) null)).thenReturn(
+ "ASDF_SEQ");
+ when(sequenceProvider.getNext("ASDF_SEQ")).thenReturn(333L);
+ when(teamDef.getTeamDefinitionHoldingVersions()).thenReturn(parentTeamDef);
+
+ atsIdProvider.setAtsId();
+
+ verify(attrResolver).setSoleAttributeValue(newObject, AtsAttributeTypes.AtsId, "ASDF333");
+
+ }
+ @Test
+ public void testNotSetAtsId() {
+ when(attrResolver.getSoleAttributeValueAsString(newObject, AtsAttributeTypes.AtsId, (String) null)).thenReturn(
+ "QQQQ444");
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdPrefix, (String) null)).thenReturn(
+ "ASDF");
+ when(attrResolver.getSoleAttributeValueAsString(teamDef, AtsAttributeTypes.AtsIdSequenceName, (String) null)).thenReturn(
+ "ASDF_SEQ");
+ when(sequenceProvider.getNext("ASDF_SEQ")).thenReturn(333L);
+ when(teamDef.getTeamDefinitionHoldingVersions()).thenReturn(parentTeamDef);
+
+ atsIdProvider.setAtsId();
+
+ verify(attrResolver, never()).setSoleAttributeValue(any(IAtsObject.class), any(IAttributeType.class),
+ any(String.class));
+ }
+}

Back to the top