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
|
/*******************************************************************************
* Copyright (c) 2012 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.client.workflow.transition;
import java.util.Collections;
import junit.framework.Assert;
import org.eclipse.osee.ats.core.client.AtsTestUtil;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.util.AtsUsersClient;
import org.eclipse.osee.ats.core.client.workflow.HoursSpentUtil;
import org.eclipse.osee.ats.core.client.workflow.StateManager;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.junit.Test;
/**
* @author John Misinco
*/
public class StateManagerTest {
@Test
public void testUpdateMetrics() throws OseeCoreException {
AtsTestUtil.cleanupAndReset(getClass().getSimpleName());
TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
StateManager stateMgr = teamWf.getStateMgr();
stateMgr.updateMetrics(AtsTestUtil.getAnalyzeStateDef(), 1.1, 1, false);
ITransitionHelper helper =
new MockTransitionHelper("dodad", Collections.singletonList(teamWf),
AtsTestUtil.getImplementStateDef().getName(), Collections.singleton(AtsUsersClient.getUser()), null);
TransitionManager manager = new TransitionManager(helper);
TransitionResults results = manager.handleAll();
manager.getTransaction().execute();
Assert.assertTrue(results.isEmpty());
stateMgr.updateMetrics(AtsTestUtil.getImplementStateDef(), 2.2, 1, false);
helper =
new MockTransitionHelper("dodad", Collections.singletonList(teamWf),
AtsTestUtil.getCompletedStateDef().getName(), Collections.singleton(AtsUsersClient.getUser()), null);
manager = new TransitionManager(helper);
results = manager.handleAll();
manager.getTransaction().execute();
Assert.assertTrue(results.toString(), results.isEmpty());
Assert.assertEquals(3.3, HoursSpentUtil.getHoursSpentTotal(teamWf), 0.001);
stateMgr.updateMetrics(AtsTestUtil.getCompletedStateDef(), -2.2, 1, false);
Assert.assertEquals(1.1, HoursSpentUtil.getHoursSpentTotal(teamWf), 0.001);
stateMgr.updateMetrics(AtsTestUtil.getCompletedStateDef(), -2.2, 1, false);
Assert.assertEquals(0, HoursSpentUtil.getHoursSpentTotal(teamWf), 0.001);
AtsTestUtil.cleanup();
}
}
|