Skip to main content
summaryrefslogtreecommitdiffstats
blob: a575d3cd031d15928586d950533ff1bf3250c39c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*******************************************************************************
 * Copyright (c) 2013 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.mockito.Mockito.when;
import java.util.Arrays;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
import org.eclipse.osee.ats.api.review.IAtsAbstractReview;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
import org.eclipse.osee.ats.api.version.IAtsVersion;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.junit.Assert;
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

/**
 * Test Case for {@link ParentTopTeamColumn}
 *
 * @author Donald G. Dunne
 */
public class ParentTopTeamColumnTest {

   // @formatter:off

   @Mock private IAtsTeamWorkflow teamWf1;
   @Mock private IAtsTeamDefinition teamDef_top;
   @Mock private IAtsTeamDefinition teamDef_child;
   @Mock private IAtsActionableItem aia1;
   @Mock private IAtsActionableItem aia_parent;
   @Mock private IAtsVersion ver1;
   @Mock private IAtsAbstractReview rev1;

   // @formatter:on

   @Before
   public void setup() throws OseeCoreException {
      MockitoAnnotations.initMocks(this);
      when(teamWf1.getParentTeamWorkflow()).thenReturn(teamWf1);
      when(teamWf1.getTeamDefinition()).thenReturn(teamDef_child);
      when(teamDef_child.getTeamDefinitionHoldingVersions()).thenReturn(teamDef_top);
      when(teamDef_child.getName()).thenReturn("TEAM child");
      when(teamDef_top.getName()).thenReturn("TEAM top");
   }

   /**
    * Test that team name comes from parent team definition when workflow given
    */
   @org.junit.Test
   public void testGetColumnText_fromTeamWf() throws Exception {
      when(teamDef_top.getVersions()).thenReturn(Arrays.asList(ver1));

      String columnText = ParentTopTeamColumn.getColumnText(teamWf1);

      Assert.assertEquals("TEAM top", columnText);
   }

   /**
    * Test that team name comes from parent team definition when review with related teamDef given
    */
   @org.junit.Test
   public void testGetColumnText_fromRelatedReview() throws Exception {
      when(teamDef_top.getVersions()).thenReturn(Arrays.asList(ver1));
      when(rev1.getParentTeamWorkflow()).thenReturn(teamWf1);

      String columnText = ParentTopTeamColumn.getColumnText(rev1);

      Assert.assertEquals("TEAM top", columnText);
   }

   /**
    * Test that team name comes from parent team definition when review with NO related teamDef but Actionable Item is
    * related to Team Def
    */
   @org.junit.Test
   public void testGetColumnText_fromStandAloneReview() throws Exception {
      when(aia1.getTeamDefinition()).thenReturn(teamDef_child);
      when(rev1.getActionableItems()).thenReturn(Collections.asHashSet(aia1));

      String columnText = ParentTopTeamColumn.getColumnText(rev1);

      Assert.assertEquals("TEAM top", columnText);
   }

   /**
    * Test that team name comes from parent team definition when review with NO related teamDef but inherited Actionable
    * Item is related to Team Def
    */
   @org.junit.Test
   public void testGetColumnText_fromStandAloneReview_inheritedAi() throws Exception {
      when(rev1.getActionableItems()).thenReturn(Collections.asHashSet(aia1));
      when(aia1.getTeamDefinitionInherited()).thenReturn(teamDef_child);

      String columnText = ParentTopTeamColumn.getColumnText(rev1);

      Assert.assertEquals("TEAM top", columnText);
   }

   /**
    * Test that get empty string when no AIs and no Team Defs related
    */
   @org.junit.Test
   public void testGetColumnText_fromStandAloneReview_noAis() throws Exception {
      when(rev1.getActionableItems()).thenReturn(java.util.Collections.<IAtsActionableItem> emptySet());
      when(aia1.getTeamDefinitionInherited()).thenReturn(teamDef_child);

      String columnText = ParentTopTeamColumn.getColumnText(rev1);

      Assert.assertEquals("", columnText);
   }

   /**
    * Test that get current Team Def if no versionss and no ais
    */
   @org.junit.Test
   public void testGetTopTeamDefName_noVersions() throws Exception {
      IAtsTeamDefinition noVersions = Mockito.mock(IAtsTeamDefinition.class);
      when(noVersions.getName()).thenReturn("TEAM");
      when(noVersions.getTeamDefinitionHoldingVersions()).thenReturn(null);

      String topTeamDefName = ParentTopTeamColumn.getTopTeamDefName(noVersions);

      Assert.assertEquals("TEAM", topTeamDefName);
   }

}

Back to the top