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
|
/*******************************************************************************
* Copyright (c) 2004, 2007 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.test.workflow;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import org.eclipse.osee.ats.artifact.AtsAttributeTypes;
import org.eclipse.osee.ats.artifact.TaskArtifact;
import org.eclipse.osee.ats.artifact.TaskArtifact.TaskStates;
import org.eclipse.osee.ats.artifact.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.editor.SMAPromptChangeStatus;
import org.eclipse.osee.ats.test.util.DemoTestUtil;
import org.eclipse.osee.ats.test.util.SMATestUtil;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.ats.util.DefaultTeamState;
import org.eclipse.osee.ats.util.TransitionOption;
import org.eclipse.osee.ats.util.widgets.dialog.SimpleTaskResolutionOptionsRule;
import org.eclipse.osee.framework.skynet.core.User;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
/**
* @author Donald G. Dunne
*/
public class SMAPromptChangeStatusTest {
public static TeamWorkFlowArtifact teamArt;
@Before
public void setUp() throws Exception {
// This test should only be run on test db
assertFalse("Test should not be run in production db", AtsUtil.isProductionDb());
}
@BeforeClass
public static void testCleanupPre() throws Exception {
DemoTestUtil.cleanupSimpleTest(SMAPromptChangeStatusTest.class.getSimpleName());
}
@org.junit.Test
public void testInitialize() throws Exception {
SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Prompt Change Status Test");
teamArt = DemoTestUtil.createSimpleAction(getClass().getSimpleName(), transaction);
transaction.execute();
assertNotNull(teamArt);
}
@org.junit.Test
public void testChangeTaskStatusNoResolution() throws Exception {
SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Prompt Change Status Test");
Collection<TaskArtifact> tasks =
DemoTestUtil.createSimpleTasks(teamArt, getClass().getSimpleName() + "_NoRes", 4, transaction);
transaction.execute();
assertTrue(tasks.size() == 4);
assertTrue(SMAPromptChangeStatus.isValidToChangeStatus(tasks).isTrue());
// Change two to 100, 1 hr split
SMAPromptChangeStatus.performChangeStatus(tasks, null, null, 1, 100, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.Completed.name(), 100, 0.25);
// Change two to 100, 1 hr split
// hours should be added to inwork state; make sure completed state isn't statused
SMAPromptChangeStatus.performChangeStatus(tasks, null, null, 1, 100, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.Completed.name(), 100, 0.50);
// Change two to 99, 1 hr split
// transitions to InWork and adds hours
// make sure hours not added to completed state
SMAPromptChangeStatus.performChangeStatus(tasks, null, null, 1, 99, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.InWork.name(), 99, 0.75);
// Change two to 55, 0
// no transition, no hours spent
SMAPromptChangeStatus.performChangeStatus(tasks, null, null, 0, 55, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.InWork.name(), 55, 0.75);
}
@org.junit.Test
public void testChangeTaskStatusWithResolutionOptions() throws Exception {
SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Prompt Change Status Test");
Collection<TaskArtifact> tasks =
DemoTestUtil.createSimpleTasks(teamArt, getClass().getSimpleName() + "_Res", 4, transaction);
transaction.execute();
assertTrue(tasks.size() == 4);
assertTrue(SMAPromptChangeStatus.isValidToChangeStatus(tasks).isTrue());
SimpleTaskResolutionOptionsRule optionsRule = new SimpleTaskResolutionOptionsRule();
// Change two to 100, 1 hr split
SMAPromptChangeStatus.performChangeStatus(tasks, optionsRule.getOptions(),
SimpleTaskResolutionOptionsRule.States.Complete.name(), 1, 100, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.Completed.name(), 100, 0.25);
// Change two to 100, 1 hr split
// hours should be added to inwork state; make sure completed state isn't statused
SMAPromptChangeStatus.performChangeStatus(tasks, optionsRule.getOptions(),
SimpleTaskResolutionOptionsRule.States.Complete.name(), 1, 100, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.Completed.name(), 100, 0.50);
// Change two to 99, 1 hr split
// transitions to InWork and adds hours
// make sure hours not added to completed state
SMAPromptChangeStatus.performChangeStatus(tasks, optionsRule.getOptions(),
SimpleTaskResolutionOptionsRule.States.In_Work.name(), 1, 99, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.InWork.name(), 99, 0.75);
// Change two to 55, 0
// no transition, no hours spent
SMAPromptChangeStatus.performChangeStatus(tasks, optionsRule.getOptions(),
SimpleTaskResolutionOptionsRule.States.In_Work.name(), 0, 55, true, true);
SMATestUtil.validateSMAs(tasks, TaskStates.InWork.name(), 55, 0.75);
}
@org.junit.Test
public void testChangeStatusFailsIfTaskCancelled() throws Exception {
SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Prompt Change Status Test");
Collection<TaskArtifact> tasks =
DemoTestUtil.createSimpleTasks(teamArt, getClass().getSimpleName() + "_Cancel", 2, transaction);
transaction.execute();
assertTrue(tasks.size() == 2);
TaskArtifact cancelTask = tasks.iterator().next();
// test that if one task is cancelled, can't change status
transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Prompt Change Status Test");
cancelTask.transition(TaskStates.Cancelled.name(), (User) null, transaction, TransitionOption.Persist);
transaction.execute();
Result result = SMAPromptChangeStatus.isValidToChangeStatus(tasks);
assertTrue(result.isFalse());
assertTrue(result.getText().contains("Can not status a cancelled"));
}
@org.junit.Test
public void testChangeStatusFailsIfTaskWrongRelatedToState() throws Exception {
SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Prompt Change Status Test");
Collection<TaskArtifact> tasks =
DemoTestUtil.createSimpleTasks(teamArt, getClass().getSimpleName() + "_RelState", 2, transaction);
transaction.execute();
assertTrue(tasks.size() == 2);
TaskArtifact taskArt = tasks.iterator().next();
// test that if task not in related-to state of workflows's current status, can't change status
transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Prompt Change Status Test");
taskArt.setSoleAttributeValue(AtsAttributeTypes.RelatedToState, DefaultTeamState.Analyze.name());
transaction.execute();
Result result = SMAPromptChangeStatus.isValidToChangeStatus(tasks);
assertTrue(result.isFalse());
assertTrue(result.getText().contains("Task work must be done in"));
}
@AfterClass
public static void testCleanupPost() throws Exception {
DemoTestUtil.cleanupSimpleTest(SMAPromptChangeStatusTest.class.getSimpleName());
}
}
|