Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java23
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java66
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java55
5 files changed, 151 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF
index 685c85fd3d5..3e2c6222e6a 100644
--- a/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF
@@ -8,5 +8,9 @@ Fragment-Host: org.eclipse.osee.framework.branch.management;bundle-version="0.4.
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit
Import-Package: org.eclipse.osee.framework.core.message.test.mocks,
- org.eclipse.osee.framework.core.test.mocks
+ org.eclipse.osee.framework.core.test.mocks,
+ org.eclipse.osee.framework.skynet.core,
+ org.eclipse.osee.framework.skynet.core.artifact,
+ org.eclipse.osee.framework.skynet.core.transaction,
+ org.eclipse.osee.support.test.util
Export-Package: org.eclipse.osee.framework.branch.management.test
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java
index 2649718a81e..35e64360798 100644
--- a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.framework.branch.management.test;
import org.eclipse.osee.framework.branch.management.test.change.ChangeTestSuite;
import org.eclipse.osee.framework.branch.management.test.commit.CommitTestSuite;
import org.eclipse.osee.framework.branch.management.test.exchange.ExchangeTestSuite;
+import org.eclipse.osee.framework.branch.management.test.purge.PurgeTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -21,6 +22,7 @@ import org.junit.runners.Suite;
ChangeTestSuite.class, //
CommitTestSuite.class, //
ExchangeTestSuite.class,//
+ PurgeTestSuite.class,//
})
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java
new file mode 100644
index 00000000000..5632ca12bf4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.framework.branch.management.test.purge;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({TestPurgeBranchRecursive.class})
+/**
+ * @author John Misinco
+ */
+public class PurgeTestSuite {
+ // test provided above
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java
new file mode 100644
index 00000000000..323fe2c7724
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.framework.branch.management.test.purge;
+
+import static org.junit.Assert.assertFalse;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.branch.management.purge.PurgeBranchRecursive;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.support.test.util.TestUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestPurgeBranchRecursive {
+
+ @Before
+ public void checkTestDb() throws OseeCoreException {
+ assertFalse(TestUtil.isProductionDb());
+ }
+
+ @Test
+ public void testPurgeBranchRecursive() throws OseeCoreException {
+ //create a root branch
+ Branch root = BranchManager.createTopLevelBranch("root");
+ //add a child to root (parent)
+ Branch parent = BranchManager.createWorkingBranch(root, "parent", UserManager.getUser());
+
+ //add children branches to parent
+ Branch child1 = BranchManager.createWorkingBranch(parent, "child1", UserManager.getUser());
+ Branch child2 = BranchManager.createWorkingBranch(parent, "child2", UserManager.getUser());
+ Branch child3 = BranchManager.createWorkingBranch(parent, "child3", UserManager.getUser());
+ //make one a merge branch
+ child3.setBranchType(BranchType.MERGE);
+
+ Branch grandChild1 = BranchManager.createWorkingBranch(child1, "grandChild1", UserManager.getUser());
+ grandChild1.setBranchType(BranchType.MERGE);
+ Branch grandChild2 = BranchManager.createWorkingBranch(child2, "grandChild1", UserManager.getUser());
+ Branch grandChild3 = BranchManager.createWorkingBranch(child3, "grandChild1", UserManager.getUser());
+
+ //count how many children of root there are
+ Assert.assertEquals(7, root.getAllChildBranches(true).size());
+ //call purgeBranch recursive
+ OperationLogger ol = new OperationLogger() {
+ @Override
+ public void log(String... row) {
+ //do nothing
+ }
+ };
+
+ PurgeBranchRecursive purge = new PurgeBranchRecursive(ol, parent, null, null);
+ //count how many children branches are in root (should be 0)
+ Assert.assertEquals(7, root.getAllChildBranches(true).size());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java
new file mode 100644
index 00000000000..0d8da87d64d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.framework.branch.management.purge;
+
+import java.util.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.branch.management.internal.Activator;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+
+/**
+ * @author John Misinco
+ */
+
+public class PurgeBranchRecursive extends AbstractOperation {
+
+ private final IOseeCachingService cachingService;
+ private final IOseeDatabaseService databaseService;
+ private final Branch toDelete;
+
+ public PurgeBranchRecursive(OperationLogger logger, Branch toDelete, IOseeCachingService cachingService, IOseeDatabaseService databaseService) {
+ super("Purge Branch Recursive", Activator.PLUGIN_ID, logger);
+ this.cachingService = cachingService;
+ this.databaseService = databaseService;
+ this.toDelete = toDelete;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws OseeCoreException {
+ Collection<Branch> children = toDelete.getAllChildBranches(true);
+ //add parent so it gets deleted last
+ children.add(toDelete);
+ logf("Found %s branches to purge.", children.size());
+ for (Branch branch : children) {
+ logf("Purging %s.", branch);
+ try {
+ doSubWork(new PurgeBranchOperation(getLogger(), branch, cachingService, databaseService), monitor, 0);
+ } catch (OseeCoreException ex) {
+ log(ex);
+ }
+ }
+ }
+}

Back to the top