Skip to main content
summaryrefslogtreecommitdiffstats
blob: d0947865c69dd1b103ad5b6b3022ad3a49d00420 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*******************************************************************************
 * Copyright (c) 2011 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.client.integration.tests.ats.core.client.review;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.review.IAtsDecisionReview;
import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.workdef.IAtsDecisionReviewOption;
import org.eclipse.osee.ats.api.workdef.model.ReviewBlockType;
import org.eclipse.osee.ats.client.integration.tests.AtsClientService;
import org.eclipse.osee.ats.client.integration.tests.ats.core.client.AtsTestUtil;
import org.eclipse.osee.ats.core.client.review.DecisionReviewManager;
import org.eclipse.osee.ats.core.client.review.DecisionReviewState;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.workdef.SimpleDecisionReviewOption;
import org.eclipse.osee.ats.core.workflow.state.TeamState;
import org.eclipse.osee.framework.core.enums.DemoUsers;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;

/**
 * Test for {@link DecisionReviewManager}
 *
 * @author Donald G. Dunne
 */
public class DecisionReviewManagerTest extends DecisionReviewManager {

   @BeforeClass
   @AfterClass
   public static void cleanup() throws Exception {
      AtsTestUtil.cleanup();
   }

   @org.junit.Test
   public void testGetDecisionReviewOptionsStr() throws OseeCoreException {
      Assert.assertEquals("Yes;Followup;<3333>\nNo;Completed;\n",
         AtsClientService.get().getReviewService().getDecisionReviewOptionsString(
            AtsClientService.get().getReviewService().getDefaultDecisionReviewOptions()));
   }

   @org.junit.Test
   public void testCreateNewDecisionReviewAndTransitionToDecision__Normal() throws OseeCoreException {
      AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - Normal");
      TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();

      List<IAtsDecisionReviewOption> options = new ArrayList<>();
      options.add(new SimpleDecisionReviewOption(DecisionReviewState.Completed.getName(), false, null));
      options.add(new SimpleDecisionReviewOption(DecisionReviewState.Followup.getName(), true,
         Arrays.asList(AtsClientService.get().getUserService().getCurrentUser().getUserId())));

      // create and transition decision review
      IAtsChangeSet changes = AtsClientService.get().createChangeSet(getClass().getSimpleName());
      String reviewTitle = "Test Review - " + teamWf.getName();
      IAtsDecisionReview decRev =
         AtsClientService.get().getReviewService().createNewDecisionReviewAndTransitionToDecision(teamWf, reviewTitle,
            "my description", AtsTestUtil.getAnalyzeStateDef().getName(), ReviewBlockType.Transition, options,
            Arrays.asList(AtsClientService.get().getUserService().getCurrentUser()), new Date(),
            AtsClientService.get().getUserService().getCurrentUser(), changes);
      changes.execute();

      Assert.assertNotNull(decRev);
      Assert.assertFalse(
         String.format("Decision Review artifact should not be dirty [%s]",
            Artifacts.getDirtyReport(((Artifact) decRev.getStoreObject()))),
         ((Artifact) decRev.getStoreObject()).isDirty());
      Assert.assertEquals(DecisionReviewState.Decision.getName(), decRev.getStateMgr().getCurrentStateName());
      Assert.assertEquals("Joe Smith", decRev.getStateMgr().getAssigneesStr());

   }

   @org.junit.Test
   public void testCreateNewDecisionReviewAndTransitionToDecision__UnAssigned() throws OseeCoreException {
      AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - UnAssigned");
      TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();

      List<IAtsDecisionReviewOption> options = new ArrayList<>();
      options.add(new SimpleDecisionReviewOption(DecisionReviewState.Completed.getName(), false, null));
      options.add(new SimpleDecisionReviewOption(DecisionReviewState.Followup.getName(), true,
         Arrays.asList(AtsClientService.get().getUserService().getCurrentUser().getUserId())));

      // create and transition decision review
      IAtsChangeSet changes = AtsClientService.get().createChangeSet(getClass().getSimpleName());
      String reviewTitle = "Test Review - " + teamWf.getName();
      IAtsDecisionReview decRev =
         AtsClientService.get().getReviewService().createNewDecisionReviewAndTransitionToDecision(teamWf, reviewTitle,
            "my description", AtsTestUtil.getAnalyzeStateDef().getName(), ReviewBlockType.Transition, options,
            Arrays.asList(AtsClientService.get().getUserServiceClient().getUserFromToken(SystemUser.UnAssigned)),
            new Date(), AtsClientService.get().getUserService().getCurrentUser(), changes);
      changes.execute();

      Assert.assertNotNull(decRev);
      Assert.assertEquals(reviewTitle, decRev.getName());
      Assert.assertFalse(
         String.format("Decision Review artifact should not be dirty [%s]",
            Artifacts.getDirtyReport(((Artifact) decRev.getStoreObject()))),
         ((Artifact) decRev.getStoreObject()).isDirty());
      Assert.assertEquals(DecisionReviewState.Decision.getName(), decRev.getStateMgr().getCurrentStateName());
      Assert.assertEquals("UnAssigned", decRev.getStateMgr().getAssigneesStr());

   }

   @org.junit.Test
   public void testCreateNewDecisionReview__Base() throws OseeCoreException {
      AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - Base");
      TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();

      String reviewTitle = "Test Review - " + teamWf.getName();
      IAtsChangeSet changes = AtsClientService.get().createChangeSet(getClass().getSimpleName());
      IAtsDecisionReview decRev = AtsClientService.get().getReviewService().createNewDecisionReview(teamWf,
         ReviewBlockType.Commit, reviewTitle, TeamState.Implement.getName(), "description",
         AtsClientService.get().getReviewService().getDefaultDecisionReviewOptions(),
         Arrays.asList(AtsClientService.get().getUserServiceClient().getUserFromToken(DemoUsers.Alex_Kay)), new Date(),
         AtsClientService.get().getUserService().getCurrentUser(), changes);
      changes.execute();

      Assert.assertNotNull(decRev);
      Assert.assertEquals(reviewTitle, decRev.getName());
      Assert.assertEquals(DecisionReviewState.Prepare.getName(), decRev.getStateMgr().getCurrentStateName());
      Assert.assertEquals("Alex Kay", decRev.getStateMgr().getAssigneesStr());
      Assert.assertEquals(TeamState.Implement.getName(),
         AtsClientService.get().getAttributeResolver().getSoleAttributeValue(decRev, AtsAttributeTypes.RelatedToState,
            ""));
      Assert.assertEquals(ReviewBlockType.Commit.name(),
         AtsClientService.get().getAttributeResolver().getSoleAttributeValue(decRev, AtsAttributeTypes.ReviewBlocks,
            ""));
   }

   @org.junit.Test
   public void testCreateNewDecisionReview__BaseUnassigned() throws OseeCoreException {
      AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - BaseUnassigned");
      TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();

      String reviewTitle = "Test Review - " + teamWf.getName();
      IAtsChangeSet changes = AtsClientService.get().createChangeSet(getClass().getSimpleName());
      IAtsDecisionReview decRev = AtsClientService.get().getReviewService().createNewDecisionReview(teamWf,
         ReviewBlockType.Commit, reviewTitle, TeamState.Implement.getName(), "description",
         AtsClientService.get().getReviewService().getDefaultDecisionReviewOptions(),
         Arrays.asList(AtsClientService.get().getUserServiceClient().getUserFromToken(SystemUser.UnAssigned)),
         new Date(), AtsClientService.get().getUserService().getCurrentUser(), changes);
      changes.execute();

      Assert.assertNotNull(decRev);
      Assert.assertEquals(reviewTitle, decRev.getName());
      Assert.assertEquals("UnAssigned", decRev.getStateMgr().getAssigneesStr());
   }

   @org.junit.Test
   public void testCreateNewDecisionReview__Sample() throws OseeCoreException {
      AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - Sample");
      TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();

      IAtsChangeSet changes = AtsClientService.get().createChangeSet(getClass().getSimpleName());
      IAtsDecisionReview decRev = AtsClientService.get().getReviewService().createNewDecisionReview(teamWf,
         ReviewBlockType.Commit, true, new Date(), AtsClientService.get().getUserService().getCurrentUser(), changes);
      changes.execute();

      Assert.assertNotNull(decRev);
      Assert.assertEquals("Should we do this?  Yes will require followup, No will not", decRev.getName());
      Assert.assertEquals(DecisionReviewState.Prepare.getName(), decRev.getStateMgr().getCurrentStateName());
      Assert.assertEquals("Joe Smith", decRev.getStateMgr().getAssigneesStr());
      Assert.assertEquals(TeamState.Analyze.getName(),
         AtsClientService.get().getAttributeResolver().getSoleAttributeValue(decRev, AtsAttributeTypes.RelatedToState,
            ""));
      Assert.assertEquals(ReviewBlockType.Commit.name(),
         AtsClientService.get().getAttributeResolver().getSoleAttributeValue(decRev, AtsAttributeTypes.ReviewBlocks,
            ""));
   }

}

Back to the top