diff options
author | donald.g.dunne | 2016-11-10 23:45:43 +0000 |
---|---|---|
committer | David W. Miller | 2016-11-10 23:45:43 +0000 |
commit | 3793c0e1a8603bf1516a60d6dd3a8aa50bc15067 (patch) | |
tree | 744cb4c69d36cff9865ea20a5ecfed49abb1fdb6 /plugins/org.eclipse.osee.ats.core.test | |
parent | 0fa7025afa9631ee6ad835273b07f5121dcd24f4 (diff) | |
download | org.eclipse.osee-3793c0e1a8603bf1516a60d6dd3a8aa50bc15067.tar.gz org.eclipse.osee-3793c0e1a8603bf1516a60d6dd3a8aa50bc15067.tar.xz org.eclipse.osee-3793c0e1a8603bf1516a60d6dd3a8aa50bc15067.zip |
feature[ats_ATS322000]: Improvements to support action
Change-Id: I2a89cf73b29b513f926249df23f81c7c6d1efa16
Diffstat (limited to 'plugins/org.eclipse.osee.ats.core.test')
3 files changed, 203 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 334cbb9399f..d3b1387dce3 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 @@ -18,6 +18,7 @@ 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.query.AtsCore_Query_JT_Suite; import org.eclipse.osee.ats.core.transition.AtsCore_Transition_JT_Suite; import org.eclipse.osee.ats.core.users.AtsCore_Users_JT_Suite; import org.eclipse.osee.ats.core.util.AtsCore_Util_JT_Suite; @@ -37,6 +38,7 @@ import org.junit.runners.Suite; AtsCore_Internal_State_Suite.class, AtsCore_Internal_Util_Suite.class, AtsCore_Workflow_Transition_Suite.class, + AtsCore_Query_JT_Suite.class, AtsCore_InternalColumnEv_JT_Suite.class, AtsCore_ModelImpl_JT_Suite.class, AtsCore_Transition_JT_Suite.class, diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/query/AtsCore_Query_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/query/AtsCore_Query_JT_Suite.java new file mode 100644 index 00000000000..7dab1602227 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/query/AtsCore_Query_JT_Suite.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 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.query; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({AtsWorkItemFilterTest.class}) +/** + * This test suite contains tests that can be run as stand-alone JUnit tests (JT) + * + * @author Donald G. Dunne + */ +public class AtsCore_Query_JT_Suite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/query/AtsWorkItemFilterTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/query/AtsWorkItemFilterTest.java new file mode 100644 index 00000000000..0daa07f2ceb --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/query/AtsWorkItemFilterTest.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2016 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.query; + +import static org.mockito.Mockito.when; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import org.eclipse.osee.ats.api.IAtsServices; +import org.eclipse.osee.ats.api.IAtsWorkItem; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.ats.api.util.IArtifactResolver; +import org.eclipse.osee.ats.api.workdef.IAttributeResolver; +import org.eclipse.osee.ats.api.workdef.StateType; +import org.eclipse.osee.ats.api.workflow.IAtsAction; +import org.eclipse.osee.ats.api.workflow.IAtsTask; +import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow; +import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Donald G. Dunne + */ +public class AtsWorkItemFilterTest { + + // @formatter:off + @Mock IAtsTeamWorkflow teamWf1; + @Mock IAtsTeamDefinition teamDef1; + @Mock IAtsStateManager teamWf1StateMgr; + @Mock IAtsAction action1; + + @Mock IAtsTeamWorkflow teamWf2; + @Mock IAtsTeamDefinition teamDef2; + @Mock IAtsStateManager teamWf2StateMgr; + @Mock IAtsAction action2; + + @Mock IAtsTask task1; + @Mock IAtsServices services; + @Mock IAtsStateManager task1StateMgr; + + @Mock IArtifactResolver artifactResolver; + @Mock IAttributeResolver attributeResolver; + // @formatter:on + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + + when(teamWf1.getTeamDefinition()).thenReturn(teamDef1); + when(teamWf1.getParentTeamWorkflow()).thenReturn(teamWf1); + + when(teamWf2.getTeamDefinition()).thenReturn(teamDef2); + when(teamWf2.getParentTeamWorkflow()).thenReturn(teamWf2); + + when(task1.getParentTeamWorkflow()).thenReturn(teamWf1); + + } + + @Test + public void testIsOfType() { + when(services.getArtifactResolver()).thenReturn(artifactResolver); + when(artifactResolver.isOfType(teamWf1, AtsArtifactTypes.TeamWorkflow)).thenReturn(true); + when(artifactResolver.isOfType(teamWf1, AtsArtifactTypes.Task)).thenReturn(false); + when(artifactResolver.isOfType(teamWf2, AtsArtifactTypes.TeamWorkflow)).thenReturn(true); + when(artifactResolver.isOfType(teamWf2, AtsArtifactTypes.Task)).thenReturn(false); + when(artifactResolver.isOfType(task1, AtsArtifactTypes.Task)).thenReturn(true); + when(artifactResolver.isOfType(task1, AtsArtifactTypes.TeamWorkflow)).thenReturn(false); + + AtsWorkItemFilter filter = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + + Collection<IAtsTask> tasks = filter.isOfType(AtsArtifactTypes.Task).getItems(); + Assert.assertEquals(1, tasks.size()); + Assert.assertEquals(task1, tasks.iterator().next()); + + filter = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + + Collection<IAtsWorkItem> workItems = + filter.isOfType(AtsArtifactTypes.Task, AtsArtifactTypes.TeamWorkflow).getItems(); + Assert.assertEquals(3, workItems.size()); + } + + @Test + public void testUnion() { + AtsWorkItemFilter filter1 = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2), services); + AtsWorkItemFilter filter2 = new AtsWorkItemFilter(Arrays.asList(teamWf2, task1), services); + filter1.union(filter2); + Assert.assertEquals(3, filter1.getItems().size()); + } + + @Test + public void testFromTeam() { + when(teamDef1.getId()).thenReturn(23L); + when(teamDef2.getId()).thenReturn(55L); + + AtsWorkItemFilter filter = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + filter.fromTeam(teamDef1); + Assert.assertEquals(2, filter.getItems().size()); + } + + @Test + public void testIsStateType() { + when(teamWf1.getStateMgr()).thenReturn(teamWf1StateMgr); + when(teamWf1StateMgr.getStateType()).thenReturn(StateType.Completed); + + when(teamWf2.getStateMgr()).thenReturn(teamWf2StateMgr); + when(teamWf2StateMgr.getStateType()).thenReturn(StateType.Cancelled); + + when(task1.getStateMgr()).thenReturn(task1StateMgr); + when(task1StateMgr.getStateType()).thenReturn(StateType.Working); + + AtsWorkItemFilter filter1 = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + filter1.isStateType(StateType.Completed); + Assert.assertEquals(1, filter1.getItems().size()); + + AtsWorkItemFilter filter2 = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + filter2.isStateType(StateType.Completed, StateType.Cancelled); + Assert.assertEquals(2, filter2.getItems().size()); + + AtsWorkItemFilter filter3 = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + filter3.isStateType(StateType.Completed, StateType.Cancelled, StateType.Working); + Assert.assertEquals(3, filter3.getItems().size()); + } + + @Test + public void testWithOrValue() { + when(services.getAttributeResolver()).thenReturn(attributeResolver); + when(attributeResolver.getAttributeValues(teamWf1, AtsAttributeTypes.Category1)).thenReturn( + Arrays.asList("asdf", "green")); + when(attributeResolver.getAttributeValues(teamWf2, AtsAttributeTypes.Category1)).thenReturn( + Arrays.asList("asdf", "blue")); + + AtsWorkItemFilter filter = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + filter.withOrValue(AtsAttributeTypes.Category1, Collections.singleton("asdf")); + Assert.assertEquals(2, filter.getItems().size()); + + filter = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + filter.withOrValue(AtsAttributeTypes.Category1, Collections.singleton("blue")); + Assert.assertEquals(1, filter.getItems().size()); + + filter = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + filter.withOrValue(AtsAttributeTypes.Category1, Arrays.asList("green", "blue")); + Assert.assertEquals(2, filter.getItems().size()); + + } + + @Test + public void testGetActions() { + when(teamWf1.getParentAction()).thenReturn(action1); + when(teamWf2.getParentAction()).thenReturn(action2); + when(task1.getParentAction()).thenReturn(action1); + + AtsWorkItemFilter filter2 = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + Assert.assertEquals(2, filter2.getActions().size()); + } + + @Test + public void testGetTeamWorkflows() { + AtsWorkItemFilter filter2 = new AtsWorkItemFilter(Arrays.asList(teamWf1, teamWf2, task1), services); + Assert.assertEquals(2, filter2.getTeamWorkflows().size()); + } + +} |