Skip to main content
summaryrefslogtreecommitdiffstats
blob: cef6c46a3d2fd9a5d6d9ba910b6270e84b93bae0 (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
/*******************************************************************************
 * 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.client.integration.tests.ats.review;

import static org.junit.Assert.assertTrue;
import java.util.Collection;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.client.demo.DemoUsers;
import org.eclipse.osee.ats.client.integration.tests.util.DemoTestUtil;
import org.eclipse.osee.ats.client.integration.tests.util.NavigateTestUtil;
import org.eclipse.osee.ats.client.integration.tests.util.WorldEditorUtil;
import org.eclipse.osee.ats.core.client.util.AtsUsersClient;
import org.eclipse.osee.ats.navigate.SearchNavigateItem;
import org.eclipse.osee.ats.navigate.VisitedItems;
import org.eclipse.osee.ats.review.GenerateReviewParticipationReport;
import org.eclipse.osee.ats.review.ReviewNavigateViewItems;
import org.eclipse.osee.ats.world.WorldEditor;
import org.eclipse.osee.ats.world.search.UserSearchItem;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassArtifactEditor;

/**
 * Test case for @link {@link ReviewNavigateViewItems}
 * 
 * @author Donald G. Dunne
 */
public class ReviewNavigateItemsToWorldViewTest {

   @org.junit.Test
   public void testDemoDatabase() throws Exception {
      VisitedItems.clearVisited();
      DemoTestUtil.setUpTest();
      assertTrue(DemoTestUtil.getDemoUser(DemoUsers.Kay_Jones) != null);
   }

   @org.junit.Test
   public void testMyReviews() throws Exception {
      // two exist cause ATS has one in it's list
      XNavigateItem item = NavigateTestUtil.getAtsNavigateItems("My Reviews").iterator().next();
      runGeneralLoadingTest(item, AtsArtifactTypes.DecisionReview, 2, null);
      runGeneralLoadingTest(item, AtsArtifactTypes.PeerToPeerReview, 2, null);
   }

   @org.junit.Test
   public void testOtherUsersWorld_KayJones() throws Exception {
      XNavigateItem item = NavigateTestUtil.getAtsNavigateItems("User's Reviews").iterator().next();
      runGeneralLoadingTest(item, AtsArtifactTypes.PeerToPeerReview, 1,
         AtsUsersClient.getUserFromToken(DemoUsers.Kay_Jones));
   }

   @org.junit.Test
   public void testOtherUsersWorld_JoeSmith() throws Exception {
      XNavigateItem item = NavigateTestUtil.getAtsNavigateItems("User's Reviews").iterator().next();
      runGeneralLoadingTest(item, AtsArtifactTypes.DecisionReview, 2,
         AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith));
      runGeneralLoadingTest(item, AtsArtifactTypes.PeerToPeerReview, 2,
         AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith));
   }

   @org.junit.Test
   public void testOpenDecisionReviews() throws Exception {
      runGeneralLoadingTest("Show Open Decision Reviews", AtsArtifactTypes.DecisionReview, 5, null);
   }

   @org.junit.Test
   public void testWorkflowsWaitingDecisionReviews() throws Exception {
      runGeneralLoadingTest("Show Workflows Waiting Decision Reviews", AtsArtifactTypes.TeamWorkflow, 5, null);
   }

   @org.junit.Test
   public void testOpenPeerReviews() throws Exception {
      runGeneralLoadingTest("Show Open PeerToPeer Reviews", AtsArtifactTypes.PeerToPeerReview, 5, null);
   }

   @org.junit.Test
   public void testWorkflowsWaitingPeerToPeerReviews() throws Exception {
      runGeneralLoadingTest("Show Workflows Waiting PeerToPeer Reviews", AtsArtifactTypes.TeamWorkflow, 4, null);
   }

   @org.junit.Test
   public void testReviewParticipationReport() throws Exception {
      MassArtifactEditor.closeAll();
      XNavigateItem item =
         NavigateTestUtil.getAtsNavigateItems("Generate Review Participation Report").iterator().next();
      ((GenerateReviewParticipationReport) item).setSelectedUser(AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith));

      item.run(TableLoadOption.ForcePend);

      MassArtifactEditor editor = getSingleEditorOrFail();
      Collection<Artifact> arts = editor.getLoadedArtifacts();
      NavigateTestUtil.testExpectedVersusActual(item.getName(), arts, AtsArtifactTypes.PeerToPeerReview, 2);
      NavigateTestUtil.testExpectedVersusActual(item.getName(), arts, AtsArtifactTypes.DecisionReview, 3);
   }

   private Collection<Artifact> runGeneralLoadingTest(String xNavigateItemName, IArtifactType artifactType, int numOfType, IAtsUser user) throws Exception {
      XNavigateItem item = NavigateTestUtil.getAtsNavigateItem(xNavigateItemName);
      return runGeneralLoadingTest(item, artifactType, numOfType, user);
   }

   private Collection<Artifact> runGeneralLoadingTest(XNavigateItem item, IArtifactType artifactType, int numOfType, IAtsUser user) throws Exception {
      return runGeneralLoadingTest(item, artifactType, numOfType, user, TableLoadOption.None);
   }

   private Collection<Artifact> runGeneralLoadingTest(XNavigateItem item, IArtifactType artifactType, int numOfType, IAtsUser user, TableLoadOption tableLoadOption) throws Exception {
      WorldEditor.closeAll();
      // Find the correct navigate item
      if (user != null && item instanceof SearchNavigateItem) {
         if (((SearchNavigateItem) item).getWorldSearchItem() instanceof UserSearchItem) {
            ((UserSearchItem) ((SearchNavigateItem) item).getWorldSearchItem()).setSelectedUser(user);
         }
      }
      // Simulate double-click of navigate item
      item.run(TableLoadOption.ForcePend, TableLoadOption.NoUI, tableLoadOption);

      WorldEditor worldEditor = WorldEditorUtil.getSingleEditorOrFail();
      Collection<Artifact> arts = worldEditor.getLoadedArtifacts();
      NavigateTestUtil.testExpectedVersusActual(item.getName(), arts, artifactType, numOfType);
      return arts;
   }

   private static MassArtifactEditor getSingleEditorOrFail() {
      // Retrieve results from opened editor and test
      Collection<MassArtifactEditor> editors = MassArtifactEditor.getEditors();
      assertTrue("Expecting 1 editor open, currently " + editors.size(), editors.size() == 1);
      return editors.iterator().next();
   }
}

Back to the top