job #7861 - fixing problem with last merge I did

.//=====================================================================
.//
.// File:      $RCSfile: gen_delete_test.arc,v $
.// Version:   $Revision: 1.24 $
.// Modified:  $Date: 2013/05/10 04:34:14 $
.//
.// (c) Copyright 2004-2014 by Mentor Graphics Corp. All rights reserved.
.//
.//=====================================================================
.// Licensed under the Apache License, Version 2.0 (the "License"); you may not
.// use this file except in compliance with the License.  You may obtain a copy
.// of the License at
.//
.//      http://www.apache.org/licenses/LICENSE-2.0
.//
.// Unless required by applicable law or agreed to in writing, software
.// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
.// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
.// License for the specific language governing permissions and limitations under
.// the License.
.//=====================================================================
.//
.//
.function processClass
  .param Inst_Ref ir
  .param String objtype
  .param String ss
    .assign attr_GroupTest = false
    .assign attr_First = false
    .assign attr_Second = false
    .assign attr_name = "Unassigned Imported Class"
    .if (objtype == "IOBJ")
      .select one obj related by ir->O_OBJ[R101];
      .if (not_empty obj)
        .assign attr_name = "${obj.Name}"
        .if (ss == "O_IOBJ_Delete")
          .invoke gt_result = processForGroupTest(obj)
          .assign attr_GroupTest = gt_result.isGroupTest
          .assign attr_First = gt_result.isFirst
          .assign attr_Second = gt_result.isSecond
        .end if
      .end if
    .elif (objtype == "OBJ")
      .assign attr_name = "${ir.Name}"
    .end if
.end function
.function processForGroupTest
  .param Inst_Ref obj
    .assign attr_isGroupTest = false
    .assign attr_isFirst = false
    .assign attr_isSecond = false
    .if (obj.Descrip == "GT:First")
      .assign attr_isGroupTest = true
      .assign attr_isFirst = true
    .elif (obj.Descrip == "GT:Second")
      .assign attr_isGroupTest = true
      .assign attr_isSecond = true
    .end if
.end function
.function genTestCode
  .param Inst_Ref ic
  .param String ss
  .param Integer count
  .param Integer test_count
  .param String objtype
  .param String testtype
    .assign test_name = ""
    .assign groupTest = false
    .assign isFirst = false
    .assign isSecond = false
    .assign ooa_type = 0
    .if (objtype == "State")
      .assign test_name = ic.Name
      .assign ooa_type = 8
    .else
      .invoke result = processClass(ic, "${objtype}", "${ss}")
      .assign test_name = result.name
      .assign groupTest = result.GroupTest
      .assign isFirst = result.First
      .assign isSecond = result.Second
      .assign ooa_type = 5
    .end if
  	public void doTest$r{test_name}() {
  		test_id = "test_${count}";
    .if (test_count == 1)
      .if (objtype == "State")
        openTestISCDiagram("${ss}");
      .else
        openTestSSDiagram("${ss}");
      .end if
    .end if
        GraphicalEditor ce = ((ModelEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getGraphicalEditor();
      .if (objtype == "IOBJ")
        Shape_c shp = getModelIClassShape("${test_name}");
      .elif (objtype == "OBJ")
        Shape_c shp = CanvasTestUtils.getModelClassShape(modelRoot, "${test_name}");
      .elif (objtype == "State")
        Shape_c shp = CanvasTestUtils.getModelStateShape(modelRoot, "${test_name}");
      .end if
        GraphicalElement_c ge = GraphicalElement_c.getOneGD_GEOnR2(shp);
        Cl_c.Clearselection();
    .if (groupTest)
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
      .if (isFirst)
        Selection.getInstance().addToSelection(ge.getRepresents());
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .elif (isSecond)
        Selection.getInstance().addToSelection(ge2.getRepresents());
        Selection.getInstance().addToSelection(ge.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .end if
    .elif (groupTest == false)
      .if (testtype == "Connector")
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge.getRepresents());
      .end if
    .end if
        DeleteAction da = new DeleteAction(CorePlugin.getImageDescriptor("delete_edit.gif"));
        da.run();

        validateOrGenerateResults(ce, generateResults);
    }
.end function
.//======================================================================
.//======================================================================
.function processClassGenerics
  .param Inst_Ref ir
  .param String objtype
  .param String ss
    .assign attr_GroupTest = false
    .assign attr_First = false
    .assign attr_Second = false
    .assign attr_name = "Unassigned Imported Class"
    .if (objtype == "IOBJ")
      .select one obj related by ir->O_OBJ[R101];
      .if (not_empty obj)
        .assign attr_name = "${obj.Name}"
        .if (ss == "O_IOBJ_Delete")
          .invoke gt_result = processForGroupTestGenerics(obj)
          .assign attr_GroupTest = gt_result.isGroupTest
          .assign attr_First = gt_result.isFirst
          .assign attr_Second = gt_result.isSecond
        .end if
      .end if
    .elif (objtype == "OBJ")
      .assign attr_name = "${ir.Name}"
    .end if
.end function
.function processForGroupTestGenerics
  .param Inst_Ref obj
    .assign attr_isGroupTest = false
    .assign attr_isFirst = false
    .assign attr_isSecond = false
    .if (obj.Descrip == "GT:First")
      .assign attr_isGroupTest = true
      .assign attr_isFirst = true
    .elif (obj.Descrip == "GT:Second")
      .assign attr_isGroupTest = true
      .assign attr_isSecond = true
    .end if
.end function
.function genTestCodeGenerics
  .param Inst_Ref ic
  .param String ss
  .param Integer count
  .param Integer test_count
  .param String objtype
  .param String testtype
    .assign test_name = ""
    .assign groupTest = false
    .assign isFirst = false
    .assign isSecond = false
    .assign ooa_type = 0
    .if (objtype == "State")
      .assign test_name = ic.Name
      .assign ooa_type = 8
    .else
      .invoke result = processClassGenerics(ic, "${objtype}", "${ss}")
      .assign test_name = result.name
      .assign groupTest = result.GroupTest
      .assign isFirst = result.First
      .assign isSecond = result.Second
      .assign ooa_type = 5
    .end if
  	public void doTest$r{test_name}() {
  		test_id = "test_${count}";
    .if (test_count == 1)
      .if (objtype == "State")
        openTestISCDiagram("${ss}");
      .else
        openTestPKGDiagram("${ss}");
      .end if
    .end if
        GraphicalEditor ce = ((ModelEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getGraphicalEditor();
      .if (objtype == "IOBJ")
        Shape_c shp = getModelIClassShape("${test_name}");
      .elif (objtype == "OBJ")
        Shape_c shp = CanvasTestUtils.getModelClassShape(modelRoot, "${test_name}");
      .elif (objtype == "State")
        Shape_c shp = CanvasTestUtils.getModelStateShape(modelRoot, "${test_name}");
      .end if
        GraphicalElement_c ge = GraphicalElement_c.getOneGD_GEOnR2(shp);
        Cl_c.Clearselection();
    .if (groupTest)
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
      .if (isFirst)
        Selection.getInstance().addToSelection(ge.getRepresents());
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .elif (isSecond)
        Selection.getInstance().addToSelection(ge2.getRepresents());
        Selection.getInstance().addToSelection(ge.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .end if
    .elif (groupTest == false)
      .if (testtype == "Connector")
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge.getRepresents());
      .end if
    .end if
        DeleteAction da = new DeleteAction(CorePlugin.getImageDescriptor("delete_edit.gif"));
        da.run();

        validateOrGenerateResults(ce, generateResults);
    }
.end function
//======================================================================
//
// File: DeleteTestGenerics.java
//
// WARNING:      Do not edit this generated file
// Generated by: ${info.arch_file_name}
// Version:      $$Revision: 1.24 $$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
//
package org.xtuml.bp.core.test;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.swt.widgets.Display;

import org.xtuml.bp.core.common.BridgePointPreferencesStore;
import org.xtuml.bp.core.common.ClassQueryInterface_c;
import org.xtuml.bp.core.common.IdAssigner;
import org.xtuml.bp.core.common.PersistableModelComponent;
import org.xtuml.bp.core.CorePlugin;
import org.xtuml.bp.core.DataTypePackage_c;

import org.xtuml.bp.core.ImportedClass_c;
import org.xtuml.bp.core.InstanceStateMachine_c;
import org.xtuml.bp.core.ModelClass_c;
import org.xtuml.bp.core.Ooaofooa;
import org.xtuml.bp.core.Package_c;
import org.xtuml.bp.core.SystemDatatypePackage_c;

import org.xtuml.bp.core.SystemModel_c;
import org.xtuml.bp.core.XtUMLNature;
import org.xtuml.bp.core.ui.DeleteAction;
import org.xtuml.bp.core.ui.Selection;
import org.xtuml.bp.core.ui.perspective.BridgePointPerspective;
import org.xtuml.bp.io.mdl.ImportModel;
import org.xtuml.bp.ui.graphics.editor.*;
import org.xtuml.bp.ui.canvas.CanvasPlugin;
import org.xtuml.bp.ui.canvas.Cl_c;
import org.xtuml.bp.ui.canvas.Connector_c;
import org.xtuml.bp.ui.canvas.Graphconnector_c;
import org.xtuml.bp.ui.canvas.Graphedge_c;
import org.xtuml.bp.ui.canvas.Graphelement_c;
import org.xtuml.bp.ui.canvas.GraphicalElement_c;
import org.xtuml.bp.ui.canvas.Ooaofgraphics;
import org.xtuml.bp.ui.canvas.Shape_c;
import org.xtuml.bp.ui.canvas.test.CanvasTest;
import org.xtuml.bp.test.common.CanvasTestUtils;

public class DeleteTestGenerics extends CanvasTest {

    String test_id = null;
    private static boolean generateResults = false;
    private static boolean initialized = false;
    static String workspace_path = "";

    public DeleteTestGenerics(String name) {
        super("Delete Test", name);
    }

    protected String getResultName() {
        return "DeleteTest" + "_" + test_id;
    }

    protected void setUp() throws Exception {
        super.setUp();

        IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore();
        store.setValue(BridgePointPreferencesStore.DISABLE_GRADIENTS, true);

      if (!initialized) {
            ensureAvailableAndLoaded("org.xtuml.bp.core.test",
                    "DeleteTestModel", false, false, "Package");
            initialized = true;
        }

        Display d = Display.getCurrent();
        while ( d.readAndDispatch() ) ;
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }
    public class Package_by_name_c implements ClassQueryInterface_c {
        public boolean evaluate(Object candidate) {
            Package_c selected = (Package_c) candidate;
            return (selected.getName().equals(m_name));
        }
        public Package_by_name_c(String name) {
            m_name = name;
        }
        private String m_name;
    }
    public class ImportedClass_by_name_c implements ClassQueryInterface_c {
    public boolean evaluate(Object candidate) {
        ImportedClass_c selected = (ImportedClass_c) candidate;
        return (selected.Get_name().equals(m_name));
    }
    public ImportedClass_by_name_c(String name) {
        m_name = name;
    }
    private String m_name;
    }
    public Shape_c getModelIClassShape(String name) {
    CanvasTestUtils ctu = new CanvasTestUtils();
    ImportedClass_c ic =
        ImportedClass_c.ImportedClassInstance(modelRoot, new ImportedClass_by_name_c(name));
    GraphicalElement_c ge =
        GraphicalElement_c.GraphicalElementInstance(graphicsModelRoot,
            ctu.new findGraphicalElementByOOAID(ic.getIobj_id(), 23));
    return Shape_c.getOneGD_SHPOnR2(ge);
    }
    public void openTestPKGDiagram(String title) {
        Package_c uut = Package_c.PackageInstance(modelRoot,
                new Package_by_name_c(title));
        assertNotNull(uut);
        CanvasTestUtils.openCanvasEditor(uut);
    }
    public void openTestISCDiagram(String title) {
        CanvasTestUtils ctu = new CanvasTestUtils();
        InstanceStateMachine_c uut = InstanceStateMachine_c.getOneSM_ISMOnR518(ModelClass_c.ModelClassInstance(modelRoot, ctu.new Class_by_name_c("Test Import Class")));
        CanvasTestUtils.openCanvasEditor(uut);
    }
    public void setGenerateResults() {
        try {
            generateResults = true;
            this.setUp();
.select any ss from instances of EP_PKG where (selected.Name == "O_IOBJ_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL != "T_IMPOTH")
.for each ic in ics
  .invoke result = processClass(ic, "IOBJ", "${ss.Name}")
  			this.doTest$r{result.name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_REL_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPREL")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSRELCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUPER_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUPER")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUPERCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUB_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUB")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUBCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_ASSR_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPASSR")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSASSRCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "Import Subsystem")
.select one class related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Name == "Test Import Class")
.select one isc related by class->SM_ISM[R518]->SM_SM[R517]
.select many states related by isc->SM_STATE[R501] where (selected.Name != "Test State OtherSide")
.for each state in states
			this.doTest$r{state.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "O_OBJ_Delete")
.select many mc_set related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Key_Lett != "T_OTH")
.for each mc in mc_set
  			this.doTest$r{mc.Name}();
.end for
        } catch (Exception e) {
            System.out.println(
                "Exception encountered by test result creator: " + e);
        }

	}

		public void testDeleteTestGenerics() {

.select any ss from instances of EP_PKG where (selected.Name == "O_IOBJ_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL != "T_IMPOTH")
.for each ic in ics
  .invoke result = processClass(ic, "IOBJ", "${ss.Name}")
  			this.doTest$r{result.name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_REL_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPREL")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSRELCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUPER_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUPER")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUPERCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUB_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUB")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUBCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_ASSR_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPASSR")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSASSRCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "Import Subsystem")
.select one class related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Name == "Test Import Class")
.select one isc related by class->SM_ISM[R518]->SM_SM[R517]
.select many states related by isc->SM_STATE[R501] where (selected.Name != "Test State OtherSide")
.for each state in states
			this.doTest$r{state.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "O_OBJ_Delete")
.select many mc_set related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Key_Lett != "T_OTH")
.for each mc in mc_set
  			this.doTest$r{mc.Name}();
.end for
	}
.//
.// Create O_IOBJ delete tests
.//
.assign count = 0
.assign test_count = 0
.select any ss from instances of EP_PKG where (selected.Name == "O_IOBJ_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL != "T_IMPOTH")
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Imported Object")
  ${test.body}
.end for
.//
.// Create R_REL delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_REL_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPREL")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSRELCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create R_SUPER delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_SUPER_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUPER")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUPERCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create R_SUB delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_SUB_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUB")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUBCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create R_ASSR delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_ASSR_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPASSR")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSASSRCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create SM_TXN delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "Import Subsystem")
.select one class related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Name == "Test Import Class")
.select one isc related by class->SM_ISM[R518]->SM_SM[R517]
.select many states related by isc->SM_STATE[R501] where (selected.Name != "Test State OtherSide")
.assign test_count = 0
.for each state in states
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(state, "${ss.Name}", count, test_count, "State", "Connector")
  ${test.body}
.end for
.//
.// Create O_OBJ link class delete tests
.//
.assign test_count = 0
.select any ss from instances of EP_PKG where (selected.Name == "O_OBJ_Delete")
.select many mc_set related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Key_Lett != "T_OTH")
.for each mc in mc_set
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(mc, "${ss.Name}", count, test_count, "OBJ", "Model Class")
  ${test.body}
.end for
}
.emit to file "src/org/xtuml/bp/core/test/DeleteTestGenerics.java"

.//=====================================================================
.//
.// File:      $RCSfile: gen_delete_test.arc,v $
.// Version:   $Revision: 1.24 $
.// Modified:  $Date: 2013/05/10 04:34:14 $
.//
.// (c) Copyright 2004-2014 by Mentor Graphics Corp. All rights reserved.
.//
.//=====================================================================
.// Licensed under the Apache License, Version 2.0 (the "License"); you may not
.// use this file except in compliance with the License.  You may obtain a copy
.// of the License at
.//
.//      http://www.apache.org/licenses/LICENSE-2.0
.//
.// Unless required by applicable law or agreed to in writing, software
.// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
.// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
.// License for the specific language governing permissions and limitations under
.// the License.
.//=====================================================================
.//
.//
.function processClass
  .param Inst_Ref ir
  .param String objtype
  .param String ss
    .assign attr_GroupTest = false
    .assign attr_First = false
    .assign attr_Second = false
    .assign attr_name = "Unassigned Imported Class"
    .if (objtype == "IOBJ")
      .select one obj related by ir->O_OBJ[R101];
      .if (not_empty obj)
        .assign attr_name = "${obj.Name}"
        .if (ss == "O_IOBJ_Delete")
          .invoke gt_result = processForGroupTest(obj)
          .assign attr_GroupTest = gt_result.isGroupTest
          .assign attr_First = gt_result.isFirst
          .assign attr_Second = gt_result.isSecond
        .end if
      .end if
    .elif (objtype == "OBJ")
      .assign attr_name = "${ir.Name}"
    .end if
.end function
.function processForGroupTest
  .param Inst_Ref obj
    .assign attr_isGroupTest = false
    .assign attr_isFirst = false
    .assign attr_isSecond = false
    .if (obj.Descrip == "GT:First")
      .assign attr_isGroupTest = true
      .assign attr_isFirst = true
    .elif (obj.Descrip == "GT:Second")
      .assign attr_isGroupTest = true
      .assign attr_isSecond = true
    .end if
.end function
.function genTestCode
  .param Inst_Ref ic
  .param String ss
  .param Integer count
  .param Integer test_count
  .param String objtype
  .param String testtype
    .assign test_name = ""
    .assign groupTest = false
    .assign isFirst = false
    .assign isSecond = false
    .assign ooa_type = 0
    .if (objtype == "State")
      .assign test_name = ic.Name
      .assign ooa_type = 8
    .else
      .invoke result = processClass(ic, "${objtype}", "${ss}")
      .assign test_name = result.name
      .assign groupTest = result.GroupTest
      .assign isFirst = result.First
      .assign isSecond = result.Second
      .assign ooa_type = 5
    .end if
<<<<<<< HEAD
    public void doTest$r{test_name}() {
        test_id = "test_${count}";
=======
  	public void doTest$r{test_name}() {
  		test_id = "test_${count}";
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
    .if (test_count == 1)
      .if (objtype == "State")
        openTestISCDiagram("${ss}");
      .else
        openTestSSDiagram("${ss}");
      .end if
    .end if
        GraphicalEditor ce = ((ModelEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getGraphicalEditor();
      .if (objtype == "IOBJ")
        Shape_c shp = getModelIClassShape("${test_name}");
      .elif (objtype == "OBJ")
        Shape_c shp = CanvasTestUtils.getModelClassShape(modelRoot, "${test_name}");
      .elif (objtype == "State")
        Shape_c shp = CanvasTestUtils.getModelStateShape(modelRoot, "${test_name}");
      .end if
        GraphicalElement_c ge = GraphicalElement_c.getOneGD_GEOnR2(shp);
        Cl_c.Clearselection();
    .if (groupTest)
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
      .if (isFirst)
        Selection.getInstance().addToSelection(ge.getRepresents());
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .elif (isSecond)
        Selection.getInstance().addToSelection(ge2.getRepresents());
        Selection.getInstance().addToSelection(ge.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .end if
    .elif (groupTest == false)
      .if (testtype == "Connector")
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge.getRepresents());
      .end if
    .end if
        DeleteAction da = new DeleteAction(CorePlugin.getImageDescriptor("delete_edit.gif"));
        da.run();

        validateOrGenerateResults(ce, generateResults);
    }
.end function
.//======================================================================
.//======================================================================
.function processClassGenerics
  .param Inst_Ref ir
  .param String objtype
  .param String ss
    .assign attr_GroupTest = false
    .assign attr_First = false
    .assign attr_Second = false
    .assign attr_name = "Unassigned Imported Class"
    .if (objtype == "IOBJ")
      .select one obj related by ir->O_OBJ[R101];
      .if (not_empty obj)
        .assign attr_name = "${obj.Name}"
        .if (ss == "O_IOBJ_Delete")
          .invoke gt_result = processForGroupTestGenerics(obj)
          .assign attr_GroupTest = gt_result.isGroupTest
          .assign attr_First = gt_result.isFirst
          .assign attr_Second = gt_result.isSecond
        .end if
      .end if
    .elif (objtype == "OBJ")
      .assign attr_name = "${ir.Name}"
    .end if
.end function
.function processForGroupTestGenerics
  .param Inst_Ref obj
    .assign attr_isGroupTest = false
    .assign attr_isFirst = false
    .assign attr_isSecond = false
    .if (obj.Descrip == "GT:First")
      .assign attr_isGroupTest = true
      .assign attr_isFirst = true
    .elif (obj.Descrip == "GT:Second")
      .assign attr_isGroupTest = true
      .assign attr_isSecond = true
    .end if
.end function
.function genTestCodeGenerics
  .param Inst_Ref ic
  .param String ss
  .param Integer count
  .param Integer test_count
  .param String objtype
  .param String testtype
    .assign test_name = ""
    .assign groupTest = false
    .assign isFirst = false
    .assign isSecond = false
    .assign ooa_type = 0
    .if (objtype == "State")
      .assign test_name = ic.Name
      .assign ooa_type = 8
    .else
      .invoke result = processClassGenerics(ic, "${objtype}", "${ss}")
      .assign test_name = result.name
      .assign groupTest = result.GroupTest
      .assign isFirst = result.First
      .assign isSecond = result.Second
      .assign ooa_type = 5
    .end if
<<<<<<< HEAD
    public void doTest$r{test_name}() {
        test_id = "test_${count}";
=======
  	public void doTest$r{test_name}() {
  		test_id = "test_${count}";
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
    .if (test_count == 1)
      .if (objtype == "State")
        openTestISCDiagram("${ss}");
      .else
        openTestPKGDiagram("${ss}");
      .end if
    .end if
        GraphicalEditor ce = ((ModelEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getGraphicalEditor();
      .if (objtype == "IOBJ")
        Shape_c shp = getModelIClassShape("${test_name}");
      .elif (objtype == "OBJ")
        Shape_c shp = CanvasTestUtils.getModelClassShape(modelRoot, "${test_name}");
      .elif (objtype == "State")
        Shape_c shp = CanvasTestUtils.getModelStateShape(modelRoot, "${test_name}");
      .end if
        GraphicalElement_c ge = GraphicalElement_c.getOneGD_GEOnR2(shp);
        Cl_c.Clearselection();
    .if (groupTest)
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
      .if (isFirst)
        Selection.getInstance().addToSelection(ge.getRepresents());
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .elif (isSecond)
        Selection.getInstance().addToSelection(ge2.getRepresents());
        Selection.getInstance().addToSelection(ge.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .end if
    .elif (groupTest == false)
      .if (testtype == "Connector")
        Connector_c con = Connector_c.getOneGD_CONOnR20(
            Graphedge_c.getOneDIM_EDOnR320(
                Graphconnector_c.getManyDIM_CONsOnR311(
                    Graphelement_c.getOneDIM_GEOnR23(ge))));
        if(con == null)
            con = Connector_c.getOneGD_CONOnR20(
                Graphedge_c.getOneDIM_EDOnR321(
                    Graphconnector_c.getManyDIM_CONsOnR311(
                        Graphelement_c.getOneDIM_GEOnR23(ge))));
        GraphicalElement_c ge2 = GraphicalElement_c.getOneGD_GEOnR2(con);
        Selection.getInstance().addToSelection(ge2.getRepresents());
      .else
        Selection.getInstance().addToSelection(ge.getRepresents());
      .end if
    .end if
        DeleteAction da = new DeleteAction(CorePlugin.getImageDescriptor("delete_edit.gif"));
        da.run();

        validateOrGenerateResults(ce, generateResults);
    }
.end function
//======================================================================
//
// File: DeleteTestGenerics.java
//
// WARNING:      Do not edit this generated file
// Generated by: ${info.arch_file_name}
// Version:      $$Revision: 1.24 $$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
//
package org.xtuml.bp.core.test;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.swt.widgets.Display;

import org.xtuml.bp.core.common.BridgePointPreferencesStore;
import org.xtuml.bp.core.common.ClassQueryInterface_c;
import org.xtuml.bp.core.common.IdAssigner;
import org.xtuml.bp.core.common.PersistableModelComponent;
import org.xtuml.bp.core.CorePlugin;
import org.xtuml.bp.core.DataTypePackage_c;

import org.xtuml.bp.core.ImportedClass_c;
import org.xtuml.bp.core.InstanceStateMachine_c;
import org.xtuml.bp.core.ModelClass_c;
import org.xtuml.bp.core.Ooaofooa;
import org.xtuml.bp.core.Package_c;
import org.xtuml.bp.core.SystemDatatypePackage_c;

import org.xtuml.bp.core.SystemModel_c;
import org.xtuml.bp.core.XtUMLNature;
import org.xtuml.bp.core.ui.DeleteAction;
import org.xtuml.bp.core.ui.Selection;
import org.xtuml.bp.core.ui.perspective.BridgePointPerspective;
import org.xtuml.bp.io.mdl.ImportModel;
import org.xtuml.bp.ui.graphics.editor.*;
import org.xtuml.bp.ui.canvas.CanvasPlugin;
import org.xtuml.bp.ui.canvas.Cl_c;
import org.xtuml.bp.ui.canvas.Connector_c;
import org.xtuml.bp.ui.canvas.Graphconnector_c;
import org.xtuml.bp.ui.canvas.Graphedge_c;
import org.xtuml.bp.ui.canvas.Graphelement_c;
import org.xtuml.bp.ui.canvas.GraphicalElement_c;
import org.xtuml.bp.ui.canvas.Ooaofgraphics;
import org.xtuml.bp.ui.canvas.Shape_c;
import org.xtuml.bp.ui.canvas.test.CanvasTest;
import org.xtuml.bp.test.common.CanvasTestUtils;

public class DeleteTestGenerics extends CanvasTest {

    String test_id = null;
    private static boolean generateResults = false;
    private static boolean initialized = false;
    static String workspace_path = "";

    public DeleteTestGenerics(String name) {
        super("Delete Test", name);
    }

    protected String getResultName() {
        return "DeleteTest" + "_" + test_id;
    }

    protected void setUp() throws Exception {
        super.setUp();

        IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore();
        store.setValue(BridgePointPreferencesStore.DISABLE_GRADIENTS, true);

      if (!initialized) {
            ensureAvailableAndLoaded("org.xtuml.bp.core.test",
                    "DeleteTestModel", false, false, "Package");
            initialized = true;
        }

        Display d = Display.getCurrent();
        while ( d.readAndDispatch() ) ;
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }
    public class Package_by_name_c implements ClassQueryInterface_c {
        public boolean evaluate(Object candidate) {
            Package_c selected = (Package_c) candidate;
            return (selected.getName().equals(m_name));
        }
        public Package_by_name_c(String name) {
            m_name = name;
        }
        private String m_name;
    }
    public class ImportedClass_by_name_c implements ClassQueryInterface_c {
    public boolean evaluate(Object candidate) {
        ImportedClass_c selected = (ImportedClass_c) candidate;
        return (selected.Get_name().equals(m_name));
    }
    public ImportedClass_by_name_c(String name) {
        m_name = name;
    }
    private String m_name;
    }
    public Shape_c getModelIClassShape(String name) {
    CanvasTestUtils ctu = new CanvasTestUtils();
    ImportedClass_c ic =
        ImportedClass_c.ImportedClassInstance(modelRoot, new ImportedClass_by_name_c(name));
    GraphicalElement_c ge =
        GraphicalElement_c.GraphicalElementInstance(graphicsModelRoot,
            ctu.new findGraphicalElementByOOAID(ic.getIobj_id(), 23));
    return Shape_c.getOneGD_SHPOnR2(ge);
    }
    public void openTestPKGDiagram(String title) {
        Package_c uut = Package_c.PackageInstance(modelRoot,
                new Package_by_name_c(title));
        assertNotNull(uut);
        CanvasTestUtils.openCanvasEditor(uut);
    }
    public void openTestISCDiagram(String title) {
        CanvasTestUtils ctu = new CanvasTestUtils();
        InstanceStateMachine_c uut = InstanceStateMachine_c.getOneSM_ISMOnR518(ModelClass_c.ModelClassInstance(modelRoot, ctu.new Class_by_name_c("Test Import Class")));
        CanvasTestUtils.openCanvasEditor(uut);
    }
    public void setGenerateResults() {
        try {
            generateResults = true;
            this.setUp();
.select any ss from instances of EP_PKG where (selected.Name == "O_IOBJ_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL != "T_IMPOTH")
.for each ic in ics
  .invoke result = processClass(ic, "IOBJ", "${ss.Name}")
<<<<<<< HEAD
            this.doTest$r{result.name}();
=======
  			this.doTest$r{result.name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_REL_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPREL")
.for each ic in ics
<<<<<<< HEAD
            this.doTest$r{ic.Obj_Name}();
=======
			this.doTest$r{ic.Obj_Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSRELCON")
.for each class in classes
<<<<<<< HEAD
            this.doTest$r{class.Name}();
=======
  			this.doTest$r{class.Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUPER_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUPER")
.for each ic in ics
<<<<<<< HEAD
            this.doTest$r{ic.Obj_Name}();
=======
			this.doTest$r{ic.Obj_Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUPERCON")
.for each class in classes
<<<<<<< HEAD
            this.doTest$r{class.Name}();
=======
  			this.doTest$r{class.Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUB_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUB")
.for each ic in ics
<<<<<<< HEAD
            this.doTest$r{ic.Obj_Name}();
=======
			this.doTest$r{ic.Obj_Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUBCON")
.for each class in classes
<<<<<<< HEAD
            this.doTest$r{class.Name}();
=======
  			this.doTest$r{class.Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_ASSR_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPASSR")
.for each ic in ics
<<<<<<< HEAD
            this.doTest$r{ic.Obj_Name}();
=======
			this.doTest$r{ic.Obj_Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSASSRCON")
.for each class in classes
<<<<<<< HEAD
            this.doTest$r{class.Name}();
=======
  			this.doTest$r{class.Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select any ss from instances of EP_PKG where (selected.Name == "Import Subsystem")
.select one class related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Name == "Test Import Class")
.select one isc related by class->SM_ISM[R518]->SM_SM[R517]
.select many states related by isc->SM_STATE[R501] where (selected.Name != "Test State OtherSide")
.for each state in states
<<<<<<< HEAD
            this.doTest$r{state.Name}();
=======
			this.doTest$r{state.Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
.select any ss from instances of EP_PKG where (selected.Name == "O_OBJ_Delete")
.select many mc_set related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Key_Lett != "T_OTH")
.for each mc in mc_set
<<<<<<< HEAD
            this.doTest$r{mc.Name}();
=======
  			this.doTest$r{mc.Name}();
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.end for
        } catch (Exception e) {
            System.out.println(
                "Exception encountered by test result creator: " + e);
        }

<<<<<<< HEAD
    }

        public void testDeleteTestGenerics() {

.select any ss from instances of EP_PKG where (selected.Name == "O_IOBJ_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL != "T_IMPOTH")
.for each ic in ics
  .invoke result = processClass(ic, "IOBJ", "${ss.Name}")
            this.doTest$r{result.name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_REL_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPREL")
.for each ic in ics
            this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSRELCON")
.for each class in classes
            this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUPER_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUPER")
.for each ic in ics
            this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUPERCON")
.for each class in classes
            this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUB_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUB")
.for each ic in ics
            this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUBCON")
.for each class in classes
            this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_ASSR_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPASSR")
.for each ic in ics
            this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSASSRCON")
.for each class in classes
            this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "Import Subsystem")
.select one class related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Name == "Test Import Class")
.select one isc related by class->SM_ISM[R518]->SM_SM[R517]
.select many states related by isc->SM_STATE[R501] where (selected.Name != "Test State OtherSide")
.for each state in states
            this.doTest$r{state.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "O_OBJ_Delete")
.select many mc_set related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Key_Lett != "T_OTH")
.for each mc in mc_set
            this.doTest$r{mc.Name}();
.end for
    }
=======
	}

		public void testDeleteTestGenerics() {

.select any ss from instances of EP_PKG where (selected.Name == "O_IOBJ_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL != "T_IMPOTH")
.for each ic in ics
  .invoke result = processClass(ic, "IOBJ", "${ss.Name}")
  			this.doTest$r{result.name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_REL_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPREL")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSRELCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUPER_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUPER")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUPERCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_SUB_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUB")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUBCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "R_ASSR_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPASSR")
.for each ic in ics
			this.doTest$r{ic.Obj_Name}();
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSASSRCON")
.for each class in classes
  			this.doTest$r{class.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "Import Subsystem")
.select one class related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Name == "Test Import Class")
.select one isc related by class->SM_ISM[R518]->SM_SM[R517]
.select many states related by isc->SM_STATE[R501] where (selected.Name != "Test State OtherSide")
.for each state in states
			this.doTest$r{state.Name}();
.end for
.select any ss from instances of EP_PKG where (selected.Name == "O_OBJ_Delete")
.select many mc_set related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Key_Lett != "T_OTH")
.for each mc in mc_set
  			this.doTest$r{mc.Name}();
.end for
	}
>>>>>>> refs/remotes/origin/7861_fix_mars_kb
.//
.// Create O_IOBJ delete tests
.//
.assign count = 0
.assign test_count = 0
.select any ss from instances of EP_PKG where (selected.Name == "O_IOBJ_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL != "T_IMPOTH")
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Imported Object")
  ${test.body}
.end for
.//
.// Create R_REL delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_REL_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPREL")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSRELCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create R_SUPER delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_SUPER_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUPER")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUPERCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create R_SUB delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_SUB_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPSUB")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSSUBCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create R_ASSR delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "R_ASSR_Delete")
.select many ics related by ss->PE_PE[R8000]->O_IOBJ[R8001] where (selected.Obj_KL == "T_IMPASSR")
.assign test_count = 0
.for each ic in ics
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(ic, "${ss.Name}", count, test_count, "IOBJ", "Connector")
  ${test.body}
.end for
.select many classes from instances of O_OBJ where (selected.KEY_LETT == "T_CLSASSRCON")
.for each class in classes
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(class, "${ss.Name}", count, test_count, "OBJ", "Connector")
  ${test.body}
.end for
.//
.// Create SM_TXN delete tests
.//
.select any ss from instances of EP_PKG where (selected.Name == "Import Subsystem")
.select one class related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Name == "Test Import Class")
.select one isc related by class->SM_ISM[R518]->SM_SM[R517]
.select many states related by isc->SM_STATE[R501] where (selected.Name != "Test State OtherSide")
.assign test_count = 0
.for each state in states
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(state, "${ss.Name}", count, test_count, "State", "Connector")
  ${test.body}
.end for
.//
.// Create O_OBJ link class delete tests
.//
.assign test_count = 0
.select any ss from instances of EP_PKG where (selected.Name == "O_OBJ_Delete")
.select many mc_set related by ss->PE_PE[R8000]->O_OBJ[R8001] where (selected.Key_Lett != "T_OTH")
.for each mc in mc_set
  .assign count = count + 1
  .assign test_count = test_count + 1
  .invoke test = genTestCodeGenerics(mc, "${ss.Name}", count, test_count, "OBJ", "Model Class")
  ${test.body}
.end for
}
.emit to file "src/org/xtuml/bp/core/test/DeleteTestGenerics.java"


Removed response cookie parsing. Other minor refactorings.

Response cookie parsing is unnecessary and the previous implementation
was buggy -- it did not support multiple set-cookie lines in the
response.

I removed the functions to give the user consistent expectations -- mkreq and related
utility functions do not assist with interpreting the server response
beyond separating header from body and breaking the header into its
component lines. Response interpretation is entirely left to the user.

Response parsing utilities may still be worthwhile to implement here. A TODO was included to note this.

Thoughts for parsing utilities
--each header line should be tokenized as nested association lists
--keys for status line should be hard-coded as they are not in the
response. all other keys should be read from the response.

; written by Mark Huetsch and Brian J Rubinton
; same license as Arc

(require "lib/re.arc")

(= protocol* "HTTP/1.0"
   useragent* (+ "User-Agent: Mozilla/5.0 "
                 "(Windows; U; Windows NT 5.1; uk; rv:1.9.1.2) "
                 "Gecko/20090729 "
                 "Firefox/3.5.2")
   content-type* "Content-Type: application/x-www-form-urlencoded")

; 1) prepare header lines and body
; 2) build request
; 3) perform-i-o (send request & receive response)
; 4) parse response
; 5) return header lines and body
; TODO fix vocab -- arglist is really querylist
(def mkreq (url (o arglist) (o method "GET") (o cookie))
  (withs (parsed-url (parse-url url)
          full-query (build-query parsed-url!query
                                  arglist)
          method     (upcase method)
          header     (req-header  parsed-url!path
                                  parsed-url!host
                                  full-query
                                  method
                                  cookie)
          body       (req-body full-query method)
          request    (+ header
                        (str-rn 2)
                        body)
          response   (perform-i-o parsed-url!resource
                                  parsed-url!host
                                  parsed-url!port
                                  request))
    response))

(def parse-url (url)
  (withs ((resource url) (split-at "://" (ensure-resource (strip-after "#" url)))
          (hp pq)        (split-at "/" url)
          (host port)    (split-at ":" hp)
          (path query)   (split-at "?" pq))
    (obj resource resource
         host     host
         port     (select-port port resource)
         path     path
         query    query)))

(def ensure-resource (url)
  (if (posmatch "://" url)
    url
    (+ "http://" url)))

(def strip-after (delim s)
  (car (split-at delim s)))

; Split string s at first instance of delimeter.
; Return split list.
(def split-at (delim s)
  (iflet i (posmatch delim s)
    (list (cut s 0 i) (cut s (+ i (len delim))))
    (list s)))

(def select-port (portstr resource)
  (if (nonblank portstr)
    (int portstr)
    (default-port resource)))

(def default-port (resource)
  (if (is resource "https")
    443
    80))

(def build-query (url-argstr arglist)
  (+ url-argstr
     (and (nonblank url-argstr)
          arglist
          '&)
     (to-query-str arglist)))

(def to-query-str (arglist)
  (if arglist
    (joinstr (map [joinstr _ "="] (pair (map [coerce _ 'string] arglist)))
             "&")))

(def req-header (path host query method cookie)
  (reduce +
    (intersperse (str-rn)
                 (flat:list
                   (first-req-line method path query)
                   (request-header host)
                   (entity-header  method query)
                   (cookie-header  cookie)))))

(def first-req-line (method path query)
  (+ method " " (build-uri path method query) " " protocol*))

(def build-uri (path method (o query ""))
  (+ "/" path (and (is method "GET")
                   (nonblank query)
                   (+ "?" query))))

(def request-header (host)
  (list (+ "Host: " host) useragent*))

(def entity-header (method query)
  (if (is method "POST")
    (list (+ "Content-Length: " (len (utf-8-bytes query)))
          content-type*)))

(def cookie-header (cookie)
  (if cookie (encode-cookie cookie)))

(def encode-cookie (o)
  (let joined-list (map [joinstr _ #\=] (tablist o))
    (+ "Cookie: "
       (if (len> joined-list 1)
         (reduce [+ _1 "; " _2] joined-list)
         (car joined-list))
       ";")))

(def req-body (query method)
  (if (and (is method "POST") (nonblank query))
    (+ query (str-rn))))

(def str-rn ((o l 1))
  (if (<= l 1)
    (string #\return #\newline)
    (string #\return #\newline (str-rn (- l 1)))))

; TODO refactor using a macro
(def perform-i-o (resource host port request)
  (let (i o) (get-i-o resource host port)
    (disp request o)
    (let response (read-response i)
      (close i o)
      response)))
;  (w/io (get-i-o resource host port)
;        request
;        read-response))

; TODO create unique vars for i o response
;(mac w/io (io request func)
;  `(let (i o) (do ,io)
;    (disp ,request o)
;    (let response (,func i)
;      (close i o)
;      response)))

(def get-i-o (resource host port)
  (if (is resource "https")
    (ssl-connect host port)
    (socket-connect host port)))

(def read-response ((o s (stdin)))
  (list (read-header s) (read-body s)))

; Read each line from port until a blank line is reached.
(def read-header ((o s (stdin)))
  (accum a
    (whiler line (readline s) blank
      (a line))))

; Read remaining lines from port.
(def read-body ((o s (stdin)))
  (tostring
    (whilet line (readline s)
      (pr line))))

; Convenience functions.
; These ignore the response header: (car (mkreq url))
(def get-url (url)
  (cdr (mkreq url)))

(def post-url (url args)
  (cdr (mkreq url args "POST")))

; TODO functions to parse/tokenize header lines

(def google (q)
  (get-url (+ "www.google.com/search?q=" (urlencode q))))

; written by Mark Huetsch and Brian J Rubinton
; same license as Arc

(require "lib/re.arc")

(= protocol* "HTTP/1.0"
   ; why this useragent?
   useragent* (+ "User-Agent: Mozilla/5.0 "
                 "(Windows; U; Windows NT 5.1; uk; rv:1.9.1.2) "
                 "Gecko/20090729 "
                 "Firefox/3.5.2")
   content-type* "Content-Type: application/x-www-form-urlencoded")

; todo add json
(def mkreq (url (o arglist) (o method "GET") (o cookie))
  (withs (parsed-url (parse-url url)
          full-query (build-query parsed-url!query
                                  arglist)
          method     (upcase method)
          header     (req-header  parsed-url!path
                                  parsed-url!host
                                  full-query
                                  method
                                  cookie)
          body       (req-body full-query method)
          request    (+ header
                        (string #\return #\newline #\return #\newline)
                        body)
          response   (sendreq parsed-url!resource
                              parsed-url!host
                              parsed-url!port
                              request))
    (list (car response)
          (cdr response)))) ; todo study the return value

(def parse-url (url)
  (withs ((resource url) (split-by "://" (ensure-resource (strip-after url "#")))
          (hp pq)        (split-by "/" url)
          (host port)    (split-by ":" hp)
          (path query)   (split-by "?" pq))
    (obj resource resource
         host     host
         port     (select-port port resource)
         path     path
         query    query)))

(def ensure-resource(url)
  (if (posmatch "://" url)
    url
    (+ "http://" url)))

(def strip-after(s delim)
  ((split-by delim s) 0))

(def split-by(delim s) ;isn't this available elsewhere?
  (iflet idx (posmatch delim s)
    (list (cut s 0 idx) (cut s (+ idx len.delim)))
    (list s nil)))

(def select-port (portstr resource)
  (if (nonblank portstr)
    (int portstr)
    (default-port resource)))

(def default-port(resource)
  (if (is resource "https")
    443
    80))

(def build-query (url-argstr arglist)
  (+ "" url-argstr
     (and (nonblank url-argstr)
          arglist
          '&)
     (to-query-str arglist)))

(def to-query-str (arglist)
  (if arglist
    (joinstr (map [joinstr _ "="] (pair (map [coerce _ 'string] arglist)))
             "&")))

(def req-header (path host query method cookie)
  (reduce +
    (intersperse (string #\return #\newline)
                 (flat:list
                   (first-req-line method path query)
                   (request-header host)
                   (entity-header  method query)
                   (cookie-header  cookie)))))

(def first-req-line (method path query)
  (+ method " " (build-uri path method query) " " protocol*))

(def build-uri (path method (o query ""))
  (+ "/" path (and
                    (is method "GET")
                    (nonblank query)
                    (+ "?" query))))

(def request-header (host)
  (list (+ "Host: " host) useragent*))

(def entity-header (method query)
  (if (is method "POST")
    (list (+ "Content-Length: " (len (utf-8-bytes query)))
          content-type*)))

(def cookie-header (cookie)
  (if cookie (encode-cookie cookie)))

; todo learn how these cookies work
(def encode-cookie (o)
  (let joined-list (map [joinstr _ #\=] (tablist o))
    (+ "Cookie: "
       (if (len> joined-list 1)
         (reduce [+ _1 "; " _2] joined-list)
         (car joined-list))
       ";")))

(def req-body (query method)
  (if (and (is method "POST") (nonblank query))
    (+ query (string #\return #\newline))))

; todo refactor.
(def sendreq (resource host port req)
  (let (i o) (get-i-o resource
                      host
                      port)
    (disp req o)
    (with (header (parse-server-headers (read-headers i))
           body   (tostring (whilet line (readline i) (prn line))))
      (close i o)
      (list header body))))

(def get-i-o (resource host port)
  (if (is "https" resource)
    (ssl-connect host port)
    (socket-connect host port)))

(def read-headers ((o s (stdin)))
  (accum a
    (whiler line (readline s) blank
      (a line))))

(def parse-server-headers (lines)
  (list (firstn 3 (only.tokens car.lines))
        (some [aand (begins-rest "Set-Cookie:" _) parse-server-cookies.it]
              cdr.lines)))

(def parse-server-cookies (s)
  (map [map trim _]
       (map [matchsplit "=" _]
            (tokens s #\;))))

(def get-url (url)
  ((mkreq url) 1))

(def post-url (url args)
  ((mkreq url args "POST") 1))

(def google (q)
  (get-url (+ "www.google.com/search?q=" (urlencode q))))

; just some preliminary hacking
(mac w/browser body
  `(withs (cookies* (table)
                    get-url
                    (fn (url) (let (parsed-header html) (get-or-post-url url '() "GET" cookies*)
                                (= cookies* (fill-table cookies* (flat (parsed-header 1))))
                                html))
                    post-url
                    (fn (url args) (let (parsed-header html) (get-or-post-url url args "POST" cookies*)
                                     (= cookies* (fill-table cookies* (flat (parsed-header 1))))
                                     html)))
     (do ,@body)))