001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.test.uml.cdfs;
043:
044: import org.netbeans.test.uml.cdfs.utils.CDFSUtil;
045: import org.netbeans.jellytools.nodes.Node;
046: import org.netbeans.jemmy.EventTool;
047: import org.netbeans.jemmy.TimeoutExpiredException;
048: import org.netbeans.junit.NbTestSuite;
049: import org.netbeans.test.umllib.DiagramElementOperator;
050: import org.netbeans.test.umllib.DiagramOperator;
051: import org.netbeans.test.umllib.NewDiagramWizardOperator;
052: import org.netbeans.test.umllib.project.JavaProject;
053: import org.netbeans.test.umllib.project.Project;
054: import org.netbeans.test.umllib.project.ProjectType;
055: import org.netbeans.test.umllib.project.UMLProject;
056: import org.netbeans.test.umllib.testcases.UMLTestCase;
057:
058: public class CreateActivityDiagramTests extends UMLTestCase {
059:
060: private EventTool eventTool = new EventTool();
061:
062: public CreateActivityDiagramTests(String name) {
063: super (name);
064: }
065:
066: public static NbTestSuite suite() {
067: NbTestSuite suite = new NbTestSuite(
068: CreateActivityDiagramTests.class);
069: return suite;
070: }
071:
072: /******************const section*************************/
073: private String PROJECT_NAME = "CDFS_uml_Act";
074: private String EXCEPTION_DLG = "Exception";
075: private String JAVA_PROJECT_NAME = "CDFS_java";
076: private final String PROJECT_PATH = System
077: .getProperty("xtest.workdir");
078: /********************************************************/
079:
080: private static boolean isNotInitialized = true;
081:
082: CDFSUtil util = new CDFSUtil(PROJECT_NAME);
083:
084: public void testCreateActivityDiagramFromClass() {
085: final String PATH_TO_CLASS = "Model|cdfs|Customer";
086: final String CLASS_NAME = "Customer";
087: final String DIA_NAME = "DGAD";
088: util = new CDFSUtil(PROJECT_NAME, this );
089:
090: Node node = util.getNode(PATH_TO_CLASS);
091:
092: util.createDiagram(new Node[] { node },
093: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
094:
095: //checking diagram was opened
096: DiagramOperator dia = new DiagramOperator(DIA_NAME);
097:
098: DiagramElementOperator comp = new DiagramElementOperator(dia,
099: CLASS_NAME);
100:
101: //checking only required elements are present on diagram
102: if (!util.diagramHasExactElements(
103: new DiagramElementOperator[] { comp }, dia)) {
104: fail("testCreateActivityDiagramFromClass verification failed");
105: }
106:
107: //checking a node was created
108: //TODO: add later
109:
110: }
111:
112: public void testCreateActivityDiagramFromManyClasses() {
113: final String PATH_TO_CLASSES = "Model|cdfs|";
114: final String[] classNames = new String[] { "Address",
115: "Customer", "CustomerAccount", "GovermentCustomer" };
116: final String DIA_NAME = "DGAllAD";
117: util = new CDFSUtil(PROJECT_NAME, this );
118:
119: Node[] nodes = new Node[classNames.length];
120: for (int i = 0; i < classNames.length; i++) {
121: nodes[i] = util.getNode(PATH_TO_CLASSES + classNames[i]);
122: }
123:
124: util.createDiagram(nodes,
125: NewDiagramWizardOperator.ACTIVITY_DIAGRAM, DIA_NAME);
126:
127: //checking diagram was opened
128: DiagramOperator dia = new DiagramOperator(DIA_NAME);
129:
130: //checking only required elements are present on diagram
131: if (!util.diagramHasExactElements(classNames, dia)) {
132: fail("testCreateActivityDiagramFromManyClasses verification failed");
133: }
134:
135: //checking a node was created
136: //TODO: add later
137:
138: }
139:
140: public void testCreateActivityDiagramFromOperation() {
141: final String PATH_TO_OPERATION = "Model|cdfs|Customer|Operations|process";
142: final String DIA_NAME = "DGOPAD";
143: util = new CDFSUtil(PROJECT_NAME, this );
144:
145: Node node = util.getNode(PATH_TO_OPERATION);
146: node.performPopupActionNoBlock(util.CDFS_MENU);
147:
148: NewDiagramWizardOperator wizard = new NewDiagramWizardOperator();
149: if (wizard
150: .isDiagramAllowed(NewDiagramWizardOperator.ACTIVITY_DIAGRAM)) {
151: fail("testCreateActivityDiagramFromOperation verification failed ");
152: }
153:
154: }
155:
156: protected void setUp() {
157: if (isNotInitialized) {
158: Project.openProject(CDFSUtil.CDFS_XTEST_PROJECT_DIR + "/"
159: + JAVA_PROJECT_NAME);
160: UMLProject.createProject(PROJECT_NAME,
161: ProjectType.UML_JAVA_REVERSE_ENGINEERING,
162: new JavaProject(JAVA_PROJECT_NAME));
163: isNotInitialized = false;
164: }
165: }
166:
167: public void tearDown() {
168: closeAllModal();
169: org.netbeans.test.umllib.util.Utils.tearDown();
170: new EventTool().waitNoEvent(1000);
171:
172: try {
173: DiagramOperator d = new DiagramOperator("DG");
174: d.closeAllDocuments();
175: } catch (TimeoutExpiredException tee) {
176: }
177:
178: new EventTool().waitNoEvent(1000);
179: }
180:
181: }
|