Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5689e231bdb7a36026007a43fe629508c7c8d1bb (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
/*******************************************************************************
 * 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.ev;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.ev.IAtsWorkPackage;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
import org.eclipse.osee.ats.client.demo.DemoArtifactToken;
import org.eclipse.osee.ats.client.demo.DemoUtil;
import org.eclipse.osee.ats.client.integration.tests.AtsClientService;
import org.eclipse.osee.ats.core.client.ev.EarnedValueReportOperation;
import org.eclipse.osee.ats.core.client.ev.EarnedValueReportResult;
import org.eclipse.osee.ats.core.client.ev.SearchWorkPackageOperation;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.enums.Active;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.junit.Assert;
import org.junit.Test;

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

   @Test
   public void test() throws OseeCoreException {
      List<IAtsTeamDefinition> teamDefs = new ArrayList<IAtsTeamDefinition>();
      IAtsTeamDefinition teamDef =
         (IAtsTeamDefinition) AtsClientService.get().getAtsConfig().getSoleByGuid(DemoArtifactToken.SAW_SW.getGuid());
      teamDefs.add(teamDef);
      SearchWorkPackageOperation srch =
         new SearchWorkPackageOperation("srch", teamDefs, true, new ArrayList<IAtsActionableItem>(), false, Active.Both);
      Operations.executeWorkAndCheckStatus(srch);
      Set<IAtsWorkPackage> workPackages = srch.getResults();
      Assert.assertEquals(3, workPackages.size());

      // Confirm that report is empty for Work Packages
      EarnedValueReportOperation earnedValueoperation = new EarnedValueReportOperation("report", workPackages);
      Operations.executeWorkAndCheckStatus(earnedValueoperation);
      Assert.assertEquals(0, earnedValueoperation.getResults().size());

      // Setup TeamWfs to have selected Work Pacakges
      SkynetTransaction transaction =
         TransactionManager.createTransaction(AtsUtil.getAtsBranchToken(), getClass().getSimpleName());
      TeamWorkFlowArtifact commWf = DemoUtil.getSawCodeCommittedWf();
      commWf.setSoleAttributeValue(AtsAttributeTypes.WorkPackageGuid,
         DemoArtifactToken.SAW_Code_Team_WorkPackage_01.getGuid());
      commWf.persist(transaction);

      TeamWorkFlowArtifact unCommWf = DemoUtil.getSawCodeUnCommittedWf();
      unCommWf.setSoleAttributeValue(AtsAttributeTypes.WorkPackageGuid,
         DemoArtifactToken.SAW_Code_Team_WorkPackage_01.getGuid());
      unCommWf.persist(transaction);

      TeamWorkFlowArtifact noBranchWf = DemoUtil.getSawCodeNoBranchWf();
      noBranchWf.setSoleAttributeValue(AtsAttributeTypes.WorkPackageGuid,
         DemoArtifactToken.SAW_Code_Team_WorkPackage_03.getGuid());
      noBranchWf.persist(transaction);
      transaction.execute();

      // Run report and validate results
      EarnedValueReportOperation earnedValueOperation2 = new EarnedValueReportOperation("report2", workPackages);
      Operations.executeWorkAndCheckStatus(earnedValueOperation2);
      Assert.assertEquals(3, earnedValueOperation2.getResults().size());
      int num01 = 0, num03 = 0;
      for (EarnedValueReportResult result : earnedValueOperation2.getResults()) {
         String id = result.getValue(EarnedValueReportOperation.Work_Package_Id);
         if (id.endsWith("01")) {
            num01++;
         } else if (id.endsWith("03")) {
            num03++;
         } else {
            Assert.fail(String.format("Unexpected result [%s]", id));
         }
      }
      Assert.assertEquals("Should be 2 items with WP_01, was %d", 2, num01);
      Assert.assertEquals("Should be 1 items with WP_03, was %d", 1, num03);
   }
}

Back to the top