Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2015-07-16 19:36:30 -0400
committerAngel Avila2015-09-11 20:56:22 -0400
commit467849887d177c4cd7a543a8596e39abc6bdfe39 (patch)
tree83e0dabbbe725bcfad1308beac6e577cac747234 /plugins/org.eclipse.osee.ats.core.test
parent0615d9781c8a10dec9d8bd08487d29f794867573 (diff)
downloadorg.eclipse.osee-467849887d177c4cd7a543a8596e39abc6bdfe39.tar.gz
org.eclipse.osee-467849887d177c4cd7a543a8596e39abc6bdfe39.tar.xz
org.eclipse.osee-467849887d177c4cd7a543a8596e39abc6bdfe39.zip
feature[ats_ATS186279]: Performance Report - Add country, prog, insert and activity columns
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.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/AtsCore_Column_JT_Suite.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/CountryColumnTest.java67
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionActivityColumnTest.java70
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionColumnTest.java67
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ProgramColumnTest.java67
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/AtsCore_Config_JT_Suite.java37
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/WorkPackageUtilityTest.java203
8 files changed, 518 insertions, 1 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 5cb73d0364..334cbb9399 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
@@ -12,6 +12,7 @@ package org.eclipse.osee.ats.core;
import org.eclipse.osee.ats.core.ai.AtsCore_AI_Suite;
import org.eclipse.osee.ats.core.column.AtsCore_Column_JT_Suite;
+import org.eclipse.osee.ats.core.config.AtsCore_Config_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;
@@ -31,6 +32,7 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({
AtsCore_AI_Suite.class,
AtsCore_Column_JT_Suite.class,
+ AtsCore_Config_JT_Suite.class,
AtsTest_Internal_Log_Suite.class,
AtsCore_Internal_State_Suite.class,
AtsCore_Internal_Util_Suite.class,
@@ -45,7 +47,7 @@ import org.junit.runners.Suite;
AtsCore_Workflow_JT_Suite.class})
/**
* This test suite contains tests that can be run as stand-alone JUnit tests (JT)
- *
+ *
* @author Donald G. Dunne
*/
public class AllAtsCoreTestSuite {
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/AtsCore_Column_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/AtsCore_Column_JT_Suite.java
index d87a39f9b6..8ffcff553a 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/AtsCore_Column_JT_Suite.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/AtsCore_Column_JT_Suite.java
@@ -21,8 +21,12 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({
ActionableItemsColumnTest.class,
AssigneeColumnTest.class,
+ CountryColumnTest.class,
ImplementersColumnTest.class,
+ InsertionColumnTest.class,
+ InsertionActivityColumnTest.class,
ParentTopTeamColumnTest.class,
+ ProgramColumnTest.class,
TeamColumnUtilityTest.class})
/**
* This test suite contains tests that can be run as stand-alone JUnit tests (JT)
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/CountryColumnTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/CountryColumnTest.java
new file mode 100644
index 0000000000..b61ddf0c88
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/CountryColumnTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.column;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.ats.api.IAtsObject;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.country.IAtsCountry;
+import org.eclipse.osee.ats.core.config.WorkPackageUtility;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test case for {@link CountryColumn}
+ *
+ * @author Donald G. Dunne
+ */
+public class CountryColumnTest extends CountryColumn {
+
+ // @formatter:off
+ @Mock private WorkPackageUtility util;
+ @Mock private IAtsServices services;
+ @Mock private IAtsWorkItem workItem;
+ @Mock private IAtsObject object;
+ @Mock private IAtsCountry country;
+ // @formatter:on
+
+ @Before
+ public void setup() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test() {
+ String str = CountryColumn.getCountryStr(object, services, util);
+ assertEquals(str, "");
+
+ when(util.getCountry(services, workItem)).thenReturn(new Pair<IAtsCountry, Boolean>(null, false));
+
+ str = CountryColumn.getCountryStr(workItem, services, util);
+ assertEquals(str, "");
+
+ when(util.getCountry(services, workItem)).thenReturn(new Pair<IAtsCountry, Boolean>(country, false));
+ when(country.getName()).thenReturn("Country");
+ str = CountryColumn.getCountryStr(workItem, services, util);
+ assertEquals(str, "Country");
+
+ when(util.getCountry(services, workItem)).thenReturn(new Pair<IAtsCountry, Boolean>(country, true));
+ str = CountryColumn.getCountryStr(workItem, services, util);
+ assertEquals(str, "Country (I)");
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionActivityColumnTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionActivityColumnTest.java
new file mode 100644
index 0000000000..70604be481
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionActivityColumnTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.column;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.ats.api.IAtsObject;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity;
+import org.eclipse.osee.ats.core.config.WorkPackageUtility;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test case for {@link InsertionColumn}
+ *
+ * @author Donald G. Dunne
+ */
+public class InsertionActivityColumnTest extends InsertionColumn {
+
+// @formatter:off
+ @Mock private WorkPackageUtility util;
+ @Mock private IAtsServices services;
+ @Mock private IAtsWorkItem workItem;
+ @Mock private IAtsObject object;
+ @Mock private IAtsInsertionActivity program;
+ // @formatter:on
+
+ @Before
+ public void setup() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test() {
+ String str = InsertionActivityColumn.getInsertionActivityStr(object, services, util);
+ assertEquals(str, "");
+
+ when(util.getInsertionActivity(services, workItem)).thenReturn(
+ new Pair<IAtsInsertionActivity, Boolean>(null, false));
+
+ str = InsertionActivityColumn.getInsertionActivityStr(workItem, services, util);
+ assertEquals(str, "");
+
+ when(util.getInsertionActivity(services, workItem)).thenReturn(
+ new Pair<IAtsInsertionActivity, Boolean>(program, false));
+ when(program.getName()).thenReturn("Country");
+ str = InsertionActivityColumn.getInsertionActivityStr(workItem, services, util);
+ assertEquals(str, "Country");
+
+ when(util.getInsertionActivity(services, workItem)).thenReturn(
+ new Pair<IAtsInsertionActivity, Boolean>(program, true));
+ str = InsertionActivityColumn.getInsertionActivityStr(workItem, services, util);
+ assertEquals(str, "Country (I)");
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionColumnTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionColumnTest.java
new file mode 100644
index 0000000000..cc54a0a698
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/InsertionColumnTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.column;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.ats.api.IAtsObject;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.insertion.IAtsInsertion;
+import org.eclipse.osee.ats.core.config.WorkPackageUtility;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test case for {@link InsertionColumn}
+ *
+ * @author Donald G. Dunne
+ */
+public class InsertionColumnTest extends InsertionColumn {
+
+ // @formatter:off
+ @Mock private WorkPackageUtility util;
+ @Mock private IAtsServices services;
+ @Mock private IAtsWorkItem workItem;
+ @Mock private IAtsObject object;
+ @Mock private IAtsInsertion program;
+ // @formatter:on
+
+ @Before
+ public void setup() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test() {
+ String str = InsertionColumn.getInsertionStr(object, services, util);
+ assertEquals(str, "");
+
+ when(util.getInsertion(services, workItem)).thenReturn(new Pair<IAtsInsertion, Boolean>(null, false));
+
+ str = InsertionColumn.getInsertionStr(workItem, services, util);
+ assertEquals(str, "");
+
+ when(util.getInsertion(services, workItem)).thenReturn(new Pair<IAtsInsertion, Boolean>(program, false));
+ when(program.getName()).thenReturn("Country");
+ str = InsertionColumn.getInsertionStr(workItem, services, util);
+ assertEquals(str, "Country");
+
+ when(util.getInsertion(services, workItem)).thenReturn(new Pair<IAtsInsertion, Boolean>(program, true));
+ str = InsertionColumn.getInsertionStr(workItem, services, util);
+ assertEquals(str, "Country (I)");
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ProgramColumnTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ProgramColumnTest.java
new file mode 100644
index 0000000000..01c97d0980
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ProgramColumnTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.column;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.ats.api.IAtsObject;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.program.IAtsProgram;
+import org.eclipse.osee.ats.core.config.WorkPackageUtility;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test case for {@link ProgramColumn}
+ *
+ * @author Donald G. Dunne
+ */
+public class ProgramColumnTest extends ProgramColumn {
+
+ // @formatter:off
+ @Mock private WorkPackageUtility util;
+ @Mock private IAtsServices services;
+ @Mock private IAtsWorkItem workItem;
+ @Mock private IAtsObject object;
+ @Mock private IAtsProgram program;
+ // @formatter:on
+
+ @Before
+ public void setup() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test() {
+ String str = ProgramColumn.getProgramStr(object, services, util);
+ assertEquals(str, "");
+
+ when(util.getProgram(services, workItem)).thenReturn(new Pair<IAtsProgram, Boolean>(null, false));
+
+ str = ProgramColumn.getProgramStr(workItem, services, util);
+ assertEquals(str, "");
+
+ when(util.getProgram(services, workItem)).thenReturn(new Pair<IAtsProgram, Boolean>(program, false));
+ when(program.getName()).thenReturn("Country");
+ str = ProgramColumn.getProgramStr(workItem, services, util);
+ assertEquals(str, "Country");
+
+ when(util.getProgram(services, workItem)).thenReturn(new Pair<IAtsProgram, Boolean>(program, true));
+ str = ProgramColumn.getProgramStr(workItem, services, util);
+ assertEquals(str, "Country (I)");
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/AtsCore_Config_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/AtsCore_Config_JT_Suite.java
new file mode 100644
index 0000000000..fc99b1ccb9
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/AtsCore_Config_JT_Suite.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.config;
+
+import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({WorkPackageUtilityTest.class})
+/**
+ * This test suite contains tests that can be run as stand-alone JUnit tests (JT)
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Config_JT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_Config_JT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_Config_JT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/WorkPackageUtilityTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/WorkPackageUtilityTest.java
new file mode 100644
index 0000000000..2fb5a94a60
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/config/WorkPackageUtilityTest.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.country.IAtsCountry;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.data.AtsRelationTypes;
+import org.eclipse.osee.ats.api.insertion.IAtsInsertion;
+import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity;
+import org.eclipse.osee.ats.api.program.IAtsProgram;
+import org.eclipse.osee.ats.api.team.IAtsConfigItemFactory;
+import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
+import org.eclipse.osee.ats.api.workdef.IRelationResolver;
+import org.eclipse.osee.ats.api.workflow.IAtsGoal;
+import org.eclipse.osee.ats.api.workflow.IAtsTask;
+import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link WorkPackageUtility}
+ *
+ * @author Donald G. Dunne
+ */
+public class WorkPackageUtilityTest {
+
+ // @formatter:off
+ @Mock private IAtsGoal goal;
+ @Mock private IAtsTeamWorkflow teamWf;
+ @Mock private IAtsTask task;
+ @Mock private ArtifactId workPackageArt;
+
+ @Mock private IAtsServices services;
+ @Mock private IAttributeResolver attributeResolver;
+ @Mock private IRelationResolver relationResolver;
+
+ @Mock private ArtifactId activityArt;
+ @Mock private IAtsInsertionActivity activity;
+
+ @Mock private IAtsInsertion insertion;
+ @Mock private IAtsProgram program;
+ @Mock private IAtsCountry country;
+
+ @Mock private IAtsConfigItemFactory factory;
+ // @formatter:on
+
+ private WorkPackageUtility util;
+
+ @Before
+ public void setup() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ when(teamWf.isTeamWorkflow()).thenReturn(true);
+
+ when(task.getParentTeamWorkflow()).thenReturn(teamWf);
+ when(task.isTeamWorkflow()).thenReturn(false);
+
+ when(services.getAttributeResolver()).thenReturn(attributeResolver);
+ when(services.getRelationResolver()).thenReturn(relationResolver);
+ when(services.getConfigItemFactory()).thenReturn(factory);
+
+ util = new WorkPackageUtility();
+ }
+
+ @org.junit.Test
+ public void testGetWorkPackageArtifact() throws Exception {
+ when(attributeResolver.getSoleAttributeValue(teamWf, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn(null);
+ Pair<ArtifactId, Boolean> result = util.getWorkPackageArtifact(services, teamWf);
+ assertResult(result, null, false);
+
+ when(attributeResolver.getSoleAttributeValue(teamWf, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn("guid");
+ when(services.getArtifactById("guid")).thenReturn(null);
+ result = util.getWorkPackageArtifact(services, teamWf);
+ assertResult(result, null, false);
+
+ when(services.getArtifactById("guid")).thenReturn(workPackageArt);
+ result = util.getWorkPackageArtifact(services, teamWf);
+ assertResult(result, workPackageArt, false);
+
+ when(attributeResolver.getSoleAttributeValue(task, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn(null);
+ result = util.getWorkPackageArtifact(services, task);
+ assertResult(result, workPackageArt, true);
+ }
+
+ @org.junit.Test
+ public void testGetInsertionActivity() throws Exception {
+ when(attributeResolver.getSoleAttributeValue(teamWf, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn("guid");
+ when(services.getArtifactById("guid")).thenReturn(null);
+ Pair<IAtsInsertionActivity, Boolean> result = util.getInsertionActivity(services, teamWf);
+ assertResult(result, null, false);
+
+ when(services.getArtifactById("guid")).thenReturn(workPackageArt);
+ when(relationResolver.getRelatedOrNull(workPackageArt,
+ AtsRelationTypes.InsertionActivityToWorkPackage_InsertionActivity)).thenReturn(null);
+ result = util.getInsertionActivity(services, teamWf);
+ assertResult(result, null, false);
+
+ when(relationResolver.getRelatedOrNull(workPackageArt,
+ AtsRelationTypes.InsertionActivityToWorkPackage_InsertionActivity)).thenReturn(activityArt);
+ when(factory.getInsertionActivity(activityArt)).thenReturn(activity);
+ result = util.getInsertionActivity(services, teamWf);
+ assertResult(result, activity, false);
+
+ when(attributeResolver.getSoleAttributeValue(task, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn(null);
+ result = util.getInsertionActivity(services, task);
+ assertResult(result, activity, true);
+ }
+
+ @Test
+ public void testGetInsertion() throws Exception {
+ when(attributeResolver.getSoleAttributeValue(teamWf, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn("guid");
+ when(relationResolver.getRelatedOrNull(workPackageArt,
+ AtsRelationTypes.InsertionActivityToWorkPackage_InsertionActivity)).thenReturn(activityArt);
+ when(services.getArtifactById("guid")).thenReturn(workPackageArt);
+ when(factory.getInsertionActivity(activityArt)).thenReturn(null);
+
+ Pair<IAtsInsertion, Boolean> result = util.getInsertion(services, teamWf);
+ assertResult(result, null, false);
+
+ when(factory.getInsertionActivity(activityArt)).thenReturn(activity);
+ when(relationResolver.getRelatedOrNull(activity, AtsRelationTypes.InsertionToInsertionActivity_Insertion,
+ IAtsInsertion.class)).thenReturn(insertion);
+ result = util.getInsertion(services, teamWf);
+ assertResult(result, insertion, false);
+
+ when(attributeResolver.getSoleAttributeValue(task, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn(null);
+ result = util.getInsertion(services, task);
+ assertResult(result, insertion, true);
+ }
+
+ @Test
+ public void testGetProgram() throws Exception {
+ when(attributeResolver.getSoleAttributeValue(teamWf, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn("guid");
+ when(relationResolver.getRelatedOrNull(workPackageArt,
+ AtsRelationTypes.InsertionActivityToWorkPackage_InsertionActivity)).thenReturn(activityArt);
+ when(services.getArtifactById("guid")).thenReturn(workPackageArt);
+ when(factory.getInsertionActivity(activityArt)).thenReturn(null);
+ when(factory.getInsertionActivity(activityArt)).thenReturn(activity);
+ when(relationResolver.getRelatedOrNull(activity, AtsRelationTypes.InsertionToInsertionActivity_Insertion,
+ IAtsInsertion.class)).thenReturn(insertion);
+
+ Pair<IAtsProgram, Boolean> result = util.getProgram(services, teamWf);
+ assertResult(result, null, false);
+
+ when(relationResolver.getRelatedOrNull(insertion, AtsRelationTypes.ProgramToInsertion_Program,
+ IAtsProgram.class)).thenReturn(program);
+ result = util.getProgram(services, teamWf);
+ assertResult(result, program, false);
+
+ when(attributeResolver.getSoleAttributeValue(task, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn(null);
+ result = util.getProgram(services, task);
+ assertResult(result, program, true);
+ }
+
+ @Test
+ public void testGetCountry() throws Exception {
+ when(attributeResolver.getSoleAttributeValue(teamWf, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn("guid");
+ when(relationResolver.getRelatedOrNull(workPackageArt,
+ AtsRelationTypes.InsertionActivityToWorkPackage_InsertionActivity)).thenReturn(activityArt);
+ when(services.getArtifactById("guid")).thenReturn(workPackageArt);
+ when(factory.getInsertionActivity(activityArt)).thenReturn(null);
+ when(factory.getInsertionActivity(activityArt)).thenReturn(activity);
+ when(relationResolver.getRelatedOrNull(activity, AtsRelationTypes.InsertionToInsertionActivity_Insertion,
+ IAtsInsertion.class)).thenReturn(insertion);
+ when(relationResolver.getRelatedOrNull(insertion, AtsRelationTypes.ProgramToInsertion_Program,
+ IAtsProgram.class)).thenReturn(program);
+
+ Pair<IAtsCountry, Boolean> result = util.getCountry(services, teamWf);
+ assertResult(result, null, false);
+
+ when(relationResolver.getRelatedOrNull(program, AtsRelationTypes.CountryToProgram_Country,
+ IAtsCountry.class)).thenReturn(country);
+ result = util.getCountry(services, teamWf);
+ assertResult(result, country, false);
+
+ when(attributeResolver.getSoleAttributeValue(task, AtsAttributeTypes.WorkPackageGuid, null)).thenReturn(null);
+ result = util.getCountry(services, task);
+ assertResult(result, country, true);
+ }
+
+ private void assertResult(Pair<? extends Object, Boolean> result, Object object, boolean inherited) {
+ assertNotNull(result);
+ assertEquals(result.getFirst(), object);
+ assertEquals(inherited, result.getSecond());
+ }
+
+}

Back to the top