Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1bc9f2c79cb3c1d5cb141e9efda3e74bebcaff6e (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
/*******************************************************************************
 * Copyright (c) 2011 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.editor.stateItem;

import static org.junit.Assert.assertFalse;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.client.integration.tests.ats.core.client.AtsTestUtil;
import org.eclipse.osee.ats.client.integration.tests.util.DemoTestUtil;
import org.eclipse.osee.ats.core.client.review.PeerToPeerReviewArtifact;
import org.eclipse.osee.ats.core.client.review.PeerToPeerReviewState;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.demo.api.DemoActionableItems;
import org.eclipse.osee.ats.editor.stateItem.AtsPeerToPeerReviewPrepareStateItem;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.ui.skynet.widgets.XComboDam;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Test Case for {@link AtsPeerToPeerReviewPrepareStateItem}
 * 
 * @author Donald G. Dunne
 */
public class AtsPeerToPeerReviewPrepareStateItemTest {

   public static PeerToPeerReviewArtifact peerRevArt;

   @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());

      if (peerRevArt == null) {
         // setup fake review artifact with decision options set
         peerRevArt = (PeerToPeerReviewArtifact) ArtifactTypeManager.addArtifact(AtsArtifactTypes.PeerToPeerReview,
            AtsUtilCore.getAtsBranch());
         peerRevArt.setName(getClass().getSimpleName());
         // Setup actionable item so don't get error that there is no parent team workflow
         peerRevArt.getActionableItemsDam().addActionableItem(
            DemoTestUtil.getActionableItem(DemoActionableItems.CIS_Code));
         peerRevArt.persist(getClass().getSimpleName());
      }
   }

   @BeforeClass
   @AfterClass
   public static void testCleanup() throws Exception {
      AtsTestUtil.cleanupSimpleTest(AtsPeerToPeerReviewPrepareStateItemTest.class.getSimpleName());
   }

   @Test
   public void testTransitioning() throws OseeCoreException {
      Assert.assertNotNull(peerRevArt);

      // setup fake combo that will hold values
      XComboDam decisionComboDam = new XComboDam(AtsAttributeTypes.ReviewBlocks.getUnqualifiedName());
      decisionComboDam.setDataStrings(new String[] {"None", "Transition", "Commit"});
      Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
      Composite comp = new Composite(shell, SWT.None);
      decisionComboDam.createWidgets(comp, SWT.NONE);
      decisionComboDam.setEnabled(true);
      decisionComboDam.setRequiredEntry(true);

      // verify enabled and required (Default)
      Assert.assertNull(peerRevArt.getParentAWA()); // condition that causes combo to disable
      Assert.assertTrue(decisionComboDam.getComboBox().isEnabled());
      Assert.assertTrue(decisionComboDam.isRequiredEntry());

      IAtsStateDefinition reviewStateDef =
         peerRevArt.getWorkDefinition().getStateByName(PeerToPeerReviewState.Prepare.getName());

      // make call to state item that should
      AtsPeerToPeerReviewPrepareStateItem stateItem = new AtsPeerToPeerReviewPrepareStateItem();
      stateItem.xWidgetCreated(decisionComboDam, null, reviewStateDef, peerRevArt, true);

      // verify the decision combo has been disabled
      Assert.assertFalse(decisionComboDam.getComboBox().isEnabled());
      Assert.assertFalse(decisionComboDam.isRequiredEntry());

   }
}

Back to the top