Skip to main content
summaryrefslogtreecommitdiffstats
blob: 831e969f4c47cbf00632c651803fe9048f37286f (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
/*******************************************************************************
 * 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.framework.ui.skynet.test.cases;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.data.SystemUser;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.update.InterArtifactExplorerDropHandler;
import org.junit.Before;

/**
 * Tests cross branch drag and drop.
 * 
 * @author Jeff C. Phillips
 */
public class InterArtifactDropTest {
   private static Artifact sourceArtifact;
   private Branch sourceBranch;
   private Branch destinationBranch;
   private Branch updateTestParentSourceBranch;
   private Branch updateTestSourceBranch;

   @Before
   public void setUp() throws Exception {
      assertFalse("This test can not be run on Production", ClientSessionManager.isProductionDataStore());

      String sourceBranchName = "Source Branch" + GUID.create();
      String destinationBranchName = "Destination Branch" + GUID.create();
      String updateSourceBranchName = "updateTestParentSourceBranch" + GUID.create();
      String updateTestSourceName = "updateTestSourceBranch" + GUID.create();

      sourceBranch =
         BranchManager.createWorkingBranch(CoreBranches.SYSTEM_ROOT, sourceBranchName,
            UserManager.getUser(SystemUser.OseeSystem));
      sleep(5000);

      sourceArtifact = ArtifactTypeManager.addArtifact(CoreArtifactTypes.SoftwareRequirement, sourceBranch);
      sourceArtifact.persist();

      destinationBranch =
         BranchManager.createWorkingBranch(CoreBranches.SYSTEM_ROOT, destinationBranchName,
            UserManager.getUser(SystemUser.OseeSystem));

      updateTestParentSourceBranch =
         BranchManager.createWorkingBranch(sourceBranch, updateSourceBranchName,
            UserManager.getUser(SystemUser.OseeSystem));

      updateTestSourceBranch =
         BranchManager.createWorkingBranch(updateTestParentSourceBranch, updateTestSourceName,
            UserManager.getUser(SystemUser.OseeSystem));

      sleep(5000);
   }

   @org.junit.Test
   public void testIntroduceCrossBranch() throws Exception {
      SevereLoggingMonitor monitorLog = new SevereLoggingMonitor();
      OseeLog.registerLoggerListener(monitorLog);

      InterArtifactExplorerDropHandler dropHandler = new InterArtifactExplorerDropHandler();
      dropHandler.dropArtifactIntoDifferentBranch(
         OseeSystemArtifacts.getDefaultHierarchyRootArtifact(destinationBranch), new Artifact[] {sourceArtifact}, false);

      sleep(5000);
      //Acquire the introduced artifact
      Artifact destArtifact = ArtifactQuery.getArtifactFromId(sourceArtifact.getArtId(), destinationBranch);

      assertTrue(sourceArtifact.getName().equals(destArtifact.getName()));
   }

   @org.junit.Test
   public void testUpdateBranch() throws Exception {
      SevereLoggingMonitor monitorLog = new SevereLoggingMonitor();
      OseeLog.registerLoggerListener(monitorLog);

      Artifact updateTestArtifact = ArtifactQuery.getArtifactFromId(sourceArtifact.getArtId(), updateTestSourceBranch);
      updateTestArtifact.setName("I am an update branch test");
      updateTestArtifact.persist();

      InterArtifactExplorerDropHandler dropHandler = new InterArtifactExplorerDropHandler();
      dropHandler.dropArtifactIntoDifferentBranch(sourceArtifact, new Artifact[] {updateTestArtifact}, false);

      sleep(5000);
      //Acquire the updated artifact
      Artifact destArtifact =
         ArtifactQuery.getArtifactFromId(updateTestArtifact.getArtId(), sourceArtifact.getBranch());
      destArtifact.reloadAttributesAndRelations();
      assertTrue(updateTestArtifact.getName().equals(destArtifact.getName()));
   }

   public static void sleep(long milliseconds) throws Exception {
      OseeLog.log(SkynetGuiPlugin.class, Level.INFO, "Sleeping " + milliseconds);
      Thread.sleep(milliseconds);
      OseeLog.log(SkynetGuiPlugin.class, Level.INFO, "Awake");
   }

}

Back to the top