public void testSendInterfaceOperationWithReturnOutOfLongDele() {
    ModelRoot[] roots = Ooaofooa.getInstancesUnderSystem(projectName);
    Function_c testFunc = null;
    for (int i = 0; i < roots.length; i++) {
      testFunc = Function_c.FunctionInstance(roots[i], new Function_by_name_c("LongDelegation"));
      if (testFunc != null) {
        break;
      }
    }
    assertNotNull(testFunc);

    Selection.getInstance().setSelection(new StructuredSelection(m_sys));
    runVerifier();

    BPDebugUtils.executeElement(testFunc);

    DebugUITestUtilities.waitForExecution();

    DebugUITestUtilities.waitForBPThreads(m_sys);
    DebugUITestUtilities.waitForExecution();

    String expectedConsoleText =
        "User invoked function: LongDelegation"
            + "\r\nLogSuccess:  TestDriverComponent has consumed the messsage as expected"
            + "\r\nLogSuccess:  Correct return value from delegated message\r\n";
    String actualConsoleText = DebugUITestUtilities.getConsoleText("null");
    assertEquals(expectedConsoleText, actualConsoleText);
  }
 private void setAndConfirmBreakpoint(NonRootModelElement st) {
   Selection.getInstance().setSelection(new StructuredSelection(st));
   ActivityEditor editor = DebugUITestUtilities.openActivityEditorForSelectedElement();
   editor.setFocus();
   DebugUITestUtilities.setBreakpointAtLine(editor, 2);
   IBreakpointManager bpm = DebugPlugin.getDefault().getBreakpointManager();
   IBreakpoint[] bps = bpm.getBreakpoints();
   assertTrue("Breakpoint not set", bps.length == 1);
 }
  public void testSendInterfaceSignalOverDele() {
    ModelRoot root = Ooaofooa.getInstance("/Delegation/models/Delegation/System/System.xtuml");
    Function_c testFunc = Function_c.FunctionInstance(root, new Function_by_name_c("sendSignal"));
    assertNotNull(testFunc);

    Selection.getInstance().setSelection(new StructuredSelection(m_sys));
    runVerifier();

    BPDebugUtils.executeElement(testFunc);

    DebugUITestUtilities.waitForExecution();

    DebugUITestUtilities.waitForBPThreads(m_sys);
    DebugUITestUtilities.waitForExecution();

    String expectedConsoleText =
        "User invoked function: sendSignal\r\nLogSuccess:  LevelOneDelegationComponent has consumed the messsage as expected\r\nLogSuccess:  LevelTwoDelegationComponent has consumed the messsage as expected\r\n";
    String actualConsoleText = DebugUITestUtilities.getConsoleText("null");
    assertEquals(expectedConsoleText, actualConsoleText);
  }
  public void testSendInterfaceOperationWithReturnOverLongDele() {
    ModelRoot root = Ooaofooa.getInstance("/Delegation/models/Delegation/System/System.xtuml");
    Function_c testFunc =
        Function_c.FunctionInstance(root, new Function_by_name_c("longdelegationWithReturn"));
    assertNotNull(testFunc);

    Selection.getInstance().setSelection(new StructuredSelection(m_sys));
    runVerifier();

    BPDebugUtils.executeElement(testFunc);

    DebugUITestUtilities.waitForExecution();

    DebugUITestUtilities.waitForBPThreads(m_sys);
    DebugUITestUtilities.waitForExecution();

    String expectedConsoleText =
        "User invoked function: longdelegationWithReturn"
            + "\r\nLogSuccess:  FourOfFourDelegation has consumed the messsage as expected"
            + "\r\nLogSuccess:  Correct return value from delegated message\r\n";
    String actualConsoleText = DebugUITestUtilities.getConsoleText("null");
    assertEquals(expectedConsoleText, actualConsoleText);
  }
  private void runVerifier() {
    Package_c[] pkgs = Package_c.getManyEP_PKGsOnR1401(m_sys);
    NonRootModelElement[] selectedElement = null;
    NonRootModelElement[] compRefs = null;
    NonRootModelElement[] components = null;
    for (Package_c pkg : pkgs) {
      if (pkg.getName().equalsIgnoreCase("system")) {
        components = Component_c.getManyC_CsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(pkg));
        assertNotNull(components);
        compRefs =
            ComponentReference_c.getManyCL_ICsOnR8001(
                PackageableElement_c.getManyPE_PEsOnR8000(pkg));
        assertNotNull(compRefs);
        selectedElement = new NonRootModelElement[components.length + compRefs.length];
        System.arraycopy(components, 0, selectedElement, 0, components.length);
        System.arraycopy(compRefs, 0, selectedElement, components.length, compRefs.length);
      }
    }
    openPerspectiveAndView(
        "com.mentor.nucleus.bp.debug.ui.DebugPerspective",
        BridgePointPerspective.ID_MGC_BP_EXPLORER);
    Selection.getInstance().setSelection(new StructuredSelection(components));
    Menu menu = m_bp_tree.getControl().getMenu();
    assertTrue(
        "The Launch Verifier action was not present for a component.",
        UITestingUtilities.checkItemStatusInContextMenu(menu, "Launch Verifier", "", false));
    MenuItem launchVerifierItem = DebugUITestUtilities.getLaunchVerifierItem(menu);
    assertNotNull(launchVerifierItem);
    ComponentInstance_c[] engines =
        ComponentInstance_c.ComponentInstanceInstances(components[0].getModelRoot());
    assertTrue(
        "Unexpected test state, there should be no Component Instances.", engines.length == 0);
    TestUtil.debugToDialog(200);
    launchVerifierItem.notifyListeners(SWT.Selection, null);
    TestingUtilities.processDisplayEvents();

    menu = m_bp_tree.getControl().getMenu();
    assertFalse(
        "The Launch Verifier action was present for an unassigned imported component.",
        UITestingUtilities.menuItemExists(menu, "", "Launch Verifier"));
  }
 public void tearDown() throws Exception {
   DebugUITestUtilities.stopSession(m_sys, projectName);
 }
  private void checkTransitionActionBreakPoint(final String transName, String expResultFile) {
    Package_c cp =
        Package_c.getOneEP_PKGOnR1405(
            m_sys,
            new ClassQueryInterface_c() {

              @Override
              public boolean evaluate(Object candidate) {
                return ((Package_c) candidate).getName().equals("Components");
              }
            });
    assertNotNull(cp);

    Component_c component =
        Component_c.getOneC_COnR8001(
            PackageableElement_c.getManyPE_PEsOnR8000(cp),
            new ClassQueryInterface_c() {

              @Override
              public boolean evaluate(Object candidate) {
                return ((Component_c) candidate).getName().equals("TransitionActionTestGlobals");
              }
            });
    assertNotNull(component);

    // launch the component
    DebugUITestUtilities.setLogActivityAndLaunchForElement(
        component, m_bp_tree.getControl().getMenu(), m_sys.getName());
    // select the transition to be tested
    Transition_c trans =
        Transition_c.TransitionInstance(
            component.getModelRoot(),
            new ClassQueryInterface_c() {
              public boolean evaluate(Object candidate) {
                return ((Transition_c) candidate).Get_name().contains(transName);
              }
            });
    assertNotNull(trans);
    Selection.getInstance().clear();
    Selection.getInstance().addToSelection(trans);
    // set a breakpoint at line 2
    ActivityEditor editor = DebugUITestUtilities.openActivityEditorForSelectedElement();

    DebugUITestUtilities.setBreakpointAtLine(editor, 2);

    Function_c setup =
        Function_c.getOneS_SYNCOnR8001(
            PackageableElement_c.getManyPE_PEsOnR8000(
                Package_c.getManyEP_PKGsOnR8001(
                    PackageableElement_c.getManyPE_PEsOnR8003(component))),
            new ClassQueryInterface_c() {

              public boolean evaluate(Object candidate) {
                return ((Function_c) candidate).getName().equals("setup");
              }
            });
    assertNotNull(setup);

    openPerspectiveAndView(
        "com.mentor.nucleus.bp.debug.ui.DebugPerspective",
        BridgePointPerspective.ID_MGC_BP_EXPLORER);

    BPDebugUtils.executeElement(setup);

    DebugUITestUtilities.waitForExecution();

    Function_c test =
        Function_c.getOneS_SYNCOnR8001(
            PackageableElement_c.getManyPE_PEsOnR8000(
                Package_c.getManyEP_PKGsOnR8001(
                    PackageableElement_c.getManyPE_PEsOnR8003(component))),
            new ClassQueryInterface_c() {

              public boolean evaluate(Object candidate) {
                return ((Function_c) candidate).getName().equals("test");
              }
            });
    assertNotNull(test);

    BPDebugUtils.executeElement(test);

    DebugUITestUtilities.waitForExecution();

    ComponentInstance_c engine = ComponentInstance_c.getOneI_EXEOnR2955(component);
    assertNotNull(engine);

    // wait for the execution to complete
    DebugUITestUtilities.waitForBPThreads(m_sys);

    // compare the trace
    File expectedResults =
        new File(m_workspace_path + "expected_results/verifier/" + expResultFile);
    String expected_results = TestUtil.getTextFileContents(expectedResults);
    // get the text representation of the debug tree
    String actual_results = DebugUITestUtilities.getConsoleText(expected_results);
    assertEquals(expected_results, actual_results);
  }