Adding diagram testcases
diff --git a/org.eclipse.epf.diagram.tests/.classpath b/org.eclipse.epf.diagram.tests/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.epf.diagram.tests/.cvsignore b/org.eclipse.epf.diagram.tests/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/org.eclipse.epf.diagram.tests/.project b/org.eclipse.epf.diagram.tests/.project
new file mode 100644
index 0000000..0bdb896
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.epf.diagram.tests</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/org.eclipse.epf.diagram.tests/META-INF/MANIFEST.MF b/org.eclipse.epf.diagram.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..df17710
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: EPF Diagram Tests
+Bundle-SymbolicName: org.eclipse.epf.diagram.tests
+Bundle-Version: 1.2.0
+Bundle-Activator: org.eclipse.epf.diagram.tests.DiagramTestPlugin
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.junit,
+ org.eclipse.epf.diagram.ui,
+ org.eclipse.epf.library.tests,
+ org.eclipse.epf.uma,
+ org.eclipse.gmf.runtime.notation,
+ org.eclipse.epf.authoring.ui,
+ org.eclipse.epf.library.xmi,
+ org.eclipse.uml2.uml,
+ org.eclipse.epf.diagram.core
+Eclipse-LazyStart: true
diff --git a/org.eclipse.epf.diagram.tests/build.properties b/org.eclipse.epf.diagram.tests/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTestCase.java b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTestCase.java
new file mode 100644
index 0000000..93471a3
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTestCase.java
@@ -0,0 +1,49 @@
+package org.eclipse.epf.diagram.tests;
+
+import junit.framework.TestCase;
+
+import org.eclipse.epf.authoring.ui.AuthoringUIPlugin;
+import org.eclipse.epf.library.tests.LibraryTestHelper;
+import org.eclipse.epf.uma.MethodLibrary;
+
+/**
+* The abstract base class for all Diagram JUnit test cases.
+* 
+* @author Shilpa Toraskar
+* @since 1.2
+*/
+public abstract class DiagramTestCase extends TestCase {
+
+	protected MethodLibrary library;
+
+	protected boolean deleteLibraryOnExit = false;
+
+	public DiagramTestCase(String name) {
+		super(name);
+	}
+
+	
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		LibraryTestHelper.createTestMethodLibrary();
+		
+		// activate the Authoring plugins to initialize something
+		// the reason to put it after the library is created is to avoid the Open Library dialog
+		AuthoringUIPlugin.getDefault();
+
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		
+		LibraryTestHelper.closeLibrary();
+	}
+
+}
diff --git a/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTestPlugin.java b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTestPlugin.java
new file mode 100644
index 0000000..e5b77df
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTestPlugin.java
@@ -0,0 +1,64 @@
+//------------------------------------------------------------------------------
+//Copyright (c) 2005, 2006 IBM Corporation and others.
+//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:
+//IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.diagram.tests;
+
+import org.eclipse.epf.common.plugin.AbstractPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+* The Tests plug-in class.
+* 
+* @author	Shilpa Toraskar
+* @since	1.2
+*/
+public class DiagramTestPlugin extends AbstractPlugin {
+
+	// The plug-in ID.
+	public static final String PLUGIN_ID = DiagramTestPlugin.class.getName();
+	
+	// The shared plug-in instance.
+	private static DiagramTestPlugin plugin;
+	
+	/**
+	 * Default constructor.
+	 */
+	public DiagramTestPlugin() {
+		super();
+		plugin = this;
+	}
+
+	/**
+	 * This method is called upon plug-in activation.
+	 * 
+	 * @see org.eclipse.epf.uma.core.plugin.AbstractPlugin#start(BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+	}
+
+	/**
+	 * This method is called when the plug-in is stopped.
+	 * 
+	 * @see org.eclipse.epf.uma.core.plugin.AbstractPlugin#start(BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		super.stop(context);
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared plug-in instance.
+	 */
+	public static DiagramTestPlugin getDefault() {
+		return plugin;
+	}
+
+}
diff --git a/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTests.java b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTests.java
new file mode 100644
index 0000000..89838cc
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramTests.java
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2006 IBM Corporation and others.
+// 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:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.diagram.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * JUnit test suite for org.eclipse.epf.diagram.
+ * 
+ * @author Shilpa Toraskar
+ * @since 1.2
+ */
+public class DiagramTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(DiagramTests.class.getPackage().getName());
+		//$JUnit-BEGIN$
+		suite.addTestSuite(DiagramUIServiceTest.class);
+		
+		//$JUnit-END$
+		return suite;
+	}
+
+}
diff --git a/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramUIServiceTest.java b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramUIServiceTest.java
new file mode 100644
index 0000000..8b3396b
--- /dev/null
+++ b/org.eclipse.epf.diagram.tests/src/org/eclipse/epf/diagram/tests/DiagramUIServiceTest.java
@@ -0,0 +1,140 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2006 IBM Corporation and others.
+// 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:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.diagram.tests;
+
+import java.util.List;
+
+import org.eclipse.epf.diagram.ui.service.DiagramUIService;
+import org.eclipse.epf.diagram.ui.service.IDiagramUIService;
+import org.eclipse.epf.library.tests.LibraryTestHelper;
+import org.eclipse.epf.uma.Activity;
+import org.eclipse.epf.uma.CapabilityPattern;
+import org.eclipse.epf.uma.ContentPackage;
+import org.eclipse.epf.uma.MethodConfiguration;
+import org.eclipse.epf.uma.MethodPlugin;
+import org.eclipse.epf.uma.ProcessComponent;
+import org.eclipse.epf.uma.Task;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Node;
+
+/**
+ * JUnit tests for the org.eclipse.epf.diagram.ui.DiagramUIService classes.
+ * 
+ * @author Shilpa Toraskar
+ * @since 1.2
+ */
+public class DiagramUIServiceTest extends DiagramTestCase {
+
+	private IDiagramUIService diagramUIService = null;
+
+	/**
+	 * Creates a new instance.
+	 */
+	public DiagramUIServiceTest(String name) {
+		super(name);
+	}
+
+	/**
+	 * Tests the DiagamUIService.createDiagram method.
+	 */
+	public void testCreateDiagram() throws Exception {
+
+		// create method plugin
+		MethodPlugin plugin = LibraryTestHelper
+				.createMethodPlugin("Test Plugin");
+		ContentPackage pkg = LibraryTestHelper.createContentPackage(plugin,
+				"p1");
+
+		// create configuration
+		MethodConfiguration config = LibraryTestHelper
+				.createConfiguration("Test Config");
+
+		// create process
+		CapabilityPattern cp1 = LibraryTestHelper.createCapabilityPattern(
+				plugin, "cp1", config);
+
+		// update the configuration
+		config.getMethodPluginSelection().add(plugin);
+		config.getMethodPackageSelection().add(pkg);
+		config.getMethodPackageSelection().add(
+				(ProcessComponent) cp1.eContainer());
+
+		// create task
+		Task task1 = LibraryTestHelper.createTask(pkg, "Task1");
+		Task task2 = LibraryTestHelper.createTask(pkg, "Task2");
+		Task[] tasks = new Task[] { task1, task2 };
+
+		Activity act1 = LibraryTestHelper.createActivity(plugin, cp1, "A1",
+				tasks);
+		Activity act2 = LibraryTestHelper.createActivity(plugin, cp1, "A1",
+				tasks);
+
+		diagramUIService = new DiagramUIService();
+		
+		Diagram diagram = diagramUIService.createActivityDiagram(cp1);
+
+		assertTrue(diagram != null);
+	
+		
+		Node act1Node = diagramUIService.createNode(diagram,  act1);
+		Node initialNode = diagramUIService.createNode(diagram, IDiagramUIService.INITIAL_NODE, "initial");
+		Node act2Node = diagramUIService.createNode(diagram, act2);
+		Node decisionNode = diagramUIService.createNode(diagram, IDiagramUIService.DECISION_NODE, "decision");
+		Node endNode = diagramUIService.createNode(diagram, IDiagramUIService.FINAL_NODE, "end");
+		
+		diagramUIService.createEdge(diagram, initialNode, act1Node, "link1");
+		diagramUIService.createEdge(diagram, act1Node, decisionNode, "link2");
+		diagramUIService.createEdge(diagram, decisionNode, act2Node, "link3");
+		diagramUIService.createEdge(diagram, act2Node, endNode, "link4");
+		
+		
+		List nodes = diagramUIService.getNodes(diagram, cp1, IDiagramUIService.ACTIVITY_NODE);
+		if (!nodes.isEmpty()) {
+			System.out.println("****** ACTIVITY Nodes - ");
+			for (int i=0; i < nodes.size(); i++)
+				System.out.println(nodes.get(i));
+		}
+		
+		nodes = diagramUIService.getNodes(diagram, cp1, IDiagramUIService.INITIAL_NODE);
+		if (!nodes.isEmpty()) {
+			System.out.println("****** Initial Nodes - ");
+			for (int i=0; i < nodes.size(); i++)
+				System.out.println(nodes.get(i));
+		}
+		
+		nodes = diagramUIService.getNodes(diagram, cp1, IDiagramUIService.DECISION_NODE);
+		if (!nodes.isEmpty()) {
+			System.out.println("****** Decision Nodes - ");
+			for (int i=0; i < nodes.size(); i++)
+				System.out.println(nodes.get(i));
+		}
+		
+		nodes = diagramUIService.getAllNodes(diagram);
+		if (!nodes.isEmpty()) {
+			System.out.println("****** ALL Nodes - ");
+			for (int i=0; i < nodes.size(); i++)
+				System.out.println(nodes.get(i));
+		}
+		
+		assertTrue(!nodes.isEmpty());
+		
+		List edges = diagramUIService.getEdges(diagram);
+		if (!edges.isEmpty()) {
+			System.out.println("****** ALL Edges - ");
+			for (int i=0; i < edges.size(); i++)
+				System.out.println(edges.get(i));
+		}
+		
+		assertTrue(!edges.isEmpty());
+		
+	}
+
+}