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
|
/*******************************************************************************
* 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.client.integration.tests.ats.actions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.osee.ats.actions.DuplicateWorkflowAction;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.notify.AtsNotificationEventFactory;
import org.eclipse.osee.ats.api.notify.AtsNotifyType;
import org.eclipse.osee.ats.api.team.CreateTeamOption;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.client.demo.DemoUsers;
import org.eclipse.osee.ats.client.demo.config.DemoDbUtil;
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.action.ActionManager;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.util.AtsChangeSet;
import org.eclipse.osee.ats.core.users.AtsCoreUsers;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.After;
import org.junit.Test;
/**
* @author Donald G. Dunne
*/
public class DuplicateWorkflowActionTest extends AbstractAtsActionRunTest {
private TeamWorkFlowArtifact newTeamArt;
private TeamWorkFlowArtifact dupArt;
@Override
public DuplicateWorkflowAction createAction() throws OseeCoreException {
return new DuplicateWorkflowAction(Collections.singleton(AtsTestUtil.getTeamWf()));
}
@Test
public void testAssigneesAndNotifications() {
AtsTestUtil.cleanupAndReset(getClass().getSimpleName());
TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
List<IAtsUser> assignees = setupAssignees(teamWf);
IAtsUser originator =
AtsClientService.get().getUserServiceClient().getUserFromOseeUser(
DemoDbUtil.getDemoUser(DemoUsers.Jason_Michael));
// new workflow
AtsChangeSet changes = new AtsChangeSet("Duplicate Workflow");
newTeamArt =
ActionManager.createTeamWorkflow(teamWf.getParentActionArtifact(), teamWf.getTeamDefinition(),
teamWf.getActionableItemsDam().getActionableItems(), assignees, changes, new Date(), originator, null,
CreateTeamOption.Duplicate_If_Exists);
assertEquals("invalid number of assignees", 2, newTeamArt.getAssignees().size());
assertEquals("invalid number of notifications", 2,
changes.getNotifications().getWorkItemNotificationEvents().size());
// duplicate workflow
dupArt =
(TeamWorkFlowArtifact) teamWf.duplicate(AtsUtilCore.getAtsBranch(), Arrays.asList(AtsAttributeTypes.AtsId));
dupArt.initializeNewStateMachine(assignees, new Date(), AtsCoreUsers.SYSTEM_USER, changes);
changes.add(dupArt);
changes.getNotifications().addWorkItemNotificationEvent(
AtsNotificationEventFactory.getWorkItemNotificationEvent(teamWf.getAssignees().iterator().next(), dupArt,
AtsNotifyType.Originator, AtsNotifyType.Assigned, AtsNotifyType.SubscribedTeamOrAi));
assertTrue(changes.getNotifications().getWorkItemNotificationEvents().size() == 4);
assertTrue(dupArt.getAssignees().size() == 2);
changes.execute();
}
private List<IAtsUser> setupAssignees(TeamWorkFlowArtifact teamWf) {
List<IAtsUser> assignees = new LinkedList<IAtsUser>();
assignees.addAll(teamWf.getAssignees());
IAtsUser lead =
AtsClientService.get().getUserServiceClient().getUserFromOseeUser(DemoDbUtil.getDemoUser(DemoUsers.Kay_Jones));
assignees.add(lead);
return assignees;
}
@After
public void tearDown() throws Exception {
if (newTeamArt != null) {
newTeamArt.deleteAndPersist();
}
if (dupArt != null) {
dupArt.deleteAndPersist();
}
}
}
|