public void testExternalEntityPackageConversion() { Package_c domPkg = Package_c.getOneEP_PKGOnR1401( m_sys, new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Package_c) candidate).getName().equals("domain"); } }); assertNotNull("Could not locate test package", domPkg); Package_c seqPackage = Package_c.getOneEP_PKGOnR8001( PackageableElement_c.getManyPE_PEsOnR8000(domPkg), new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Package_c) candidate).getName().equals("External Entities"); } }); assertNotNull("Could not locate converted external entity package.", seqPackage); performDiagramTest(seqPackage, 4); performPETest(seqPackage, 4); }
public void testFormalizedComponentClassOperationDTAssignement() throws CoreException { Component_c component = Component_c.ComponentInstance( modelRoot, new ClassQueryInterface_c() { public boolean evaluate(Object candidate) { return ((Component_c) candidate).getName().equals("IF Scope Test Component"); } }); assertNotNull(component); if (!component.Isformal()) formalizeComponent(component); Operation_c op = Operation_c.OperationInstance(modelRoot); OperationO_TFRPropertySource ps = new OperationO_TFRPropertySource(op); ps.getPropertyDescriptors(); ps.setPropertyValue("DataType", "component_ref"); DataType_c dt = DataType_c.getOneS_DTOnR116(op); SystemModel_c testSys = null; if (testGlobals) { testSys = SystemModel_c.getOneS_SYSOnR9100( GlobalElementInSystem_c.getOneG_EISOnR9100( PackageableElement_c.getOnePE_PEOnR8001(dt))); } else { testSys = SystemModel_c.getOneS_SYSOnR4402(SystemDatatypeInPackage_c.getOneSLD_SDINPOnR4401(dt)); } assertTrue("The chosen dt was not a system level one as expected.", testSys != null); }
public void testSubsystemConversion() { Package_c pkg = Package_c.getOneEP_PKGOnR1401( m_sys, new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Package_c) candidate).getName().equals("domain"); } }); assertNotNull("Could not locate host package.", pkg); Package_c ss = Package_c.getOneEP_PKGOnR8001( PackageableElement_c.getManyPE_PEsOnR8000(pkg), new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Package_c) candidate).getName().equals("subsystem"); } }); assertNotNull("Could not locate converted subsystem.", ss); performDiagramTest(ss, 9); performPETest(ss, 11); }
public void testDomainAsComponentConversion() { Package_c pkg = Package_c.getOneEP_PKGOnR1401( m_sys, new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Package_c) candidate).getName().equals("ComponentPackage"); } }); assertNotNull("Could not locate host package.", pkg); Component_c comp = Component_c.getOneC_COnR8001( PackageableElement_c.getManyPE_PEsOnR8000(pkg), new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Component_c) candidate).getName().equals("component"); } }); assertNotNull("Could not locate converted component.", comp); performDiagramTest(comp, 6); performPETest(comp, 4); }
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 testGlobalMigrationOperationParameterDomain() throws Exception { Ooaofooa testRoot = Ooaofooa.getInstance("/model_upgrade/models/model_upgrade/domain/domain.xtuml"); OperationParameter_c param = OperationParameter_c.OperationParameterInstance(testRoot); assertNotNull("Unable to locate test element", param); DataType_c dt = DataType_c.getOneS_DTOnR118(param); assertNotNull("Unable to locate test element", dt); GlobalElementInSystem_c gis = GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt)); assertNotNull("OperationParameter was not migrated to use globals.", gis); assertTrue( "Incorrect data type associated with OperationParameter after global migration", dt.getName().equals("inst_ref<Timer>")); }
public void testGlobalMigrationSymbolicConstantDomain() throws Exception { Ooaofooa testRoot = Ooaofooa.getInstance("/model_upgrade/models/model_upgrade/domain/domain.xtuml"); SymbolicConstant_c param = SymbolicConstant_c.SymbolicConstantInstance(testRoot); assertNotNull("Unable to locate test element", param); DataType_c dt = DataType_c.getOneS_DTOnR1500(param); assertNotNull("Unable to locate test element", dt); GlobalElementInSystem_c gis = GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt)); assertNotNull("SymbolicConstant was not migrated to use globals.", gis); assertTrue( "Incorrect data type associated with SymbolicConstant after global migration", dt.getName().equals("string")); }
public void testGlobalMigrationInterfaceOperation() throws Exception { Ooaofooa testRoot = Ooaofooa.getInstance( "/model_upgrade/models/model_upgrade/InterfacePackage/InterfacePackage.xtuml"); InterfaceOperation_c param = InterfaceOperation_c.InterfaceOperationInstance(testRoot); assertNotNull("Unable to locate test element", param); DataType_c dt = DataType_c.getOneS_DTOnR4008(param); assertNotNull("Unable to locate test element", dt); GlobalElementInSystem_c gis = GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt)); assertNotNull("InterfaceOperation was not migrated to use globals.", gis); assertTrue( "Incorrect data type associated with InterfaceOperation after global migration", dt.getName().equals("real")); }
public void testGlobalMigrationUserDataTypeComponent() throws Exception { Ooaofooa testRoot = Ooaofooa.getInstance( "/model_upgrade/models/model_upgrade/ComponentPackage/ComponentPackage.xtuml"); UserDataType_c param = UserDataType_c.UserDataTypeInstance(testRoot); assertNotNull("Unable to locate test element", param); DataType_c dt = DataType_c.getOneS_DTOnR18(param); assertNotNull("Unable to locate test element", dt); GlobalElementInSystem_c gis = GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt)); assertNotNull("UserDataType was not migrated to use globals.", gis); assertTrue( "Incorrect data type associated with UserDataType after global migration", dt.getName().equals("boolean")); }
public void testCanRenameAndCanDeleteReferentialAttribute() { class findModelClassUsingName implements ClassQueryInterface_c { findModelClassUsingName(String aname) { name = aname; } private String name; public boolean evaluate(Object candidate) { ModelClass_c selected = (ModelClass_c) candidate; return selected.getName().equals(name); } } class findPackageUsingName implements ClassQueryInterface_c { findPackageUsingName(String aname) { name = aname; } private String name; public boolean evaluate(Object candidate) { Package_c selected = (Package_c) candidate; return selected.getName().equals(name); } } testClass = ModelClass_c.getOneO_OBJOnR8001( PackageableElement_c.getManyPE_PEsOnR8000( Package_c.PackageInstance( modelRoot, new findPackageUsingName("CanRenameCanDelete Data"))), new findModelClassUsingName("Class D")); // $NON-NLS-1$ //$NON-NLS-2$ Attribute_c attr = Attribute_c.getOneO_ATTROnR102(testClass, new findAttributeUsingName("id")); // $NON-NLS-1$ assertFalse(attr.Canrename()); assertFalse(attr.Candelete()); Attribute_c attr_ren = Attribute_c.getOneO_ATTROnR102( testClass, new findAttributeUsingName("renamedRefId")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertTrue(attr_ren.Canrename()); assertFalse(attr_ren.Candelete()); }
public void testGlobalMigrationStateMachineEventDataItemComponent() throws Exception { Ooaofooa testRoot = Ooaofooa.getInstance( "/model_upgrade/models/model_upgrade/ComponentPackage/ComponentPackage.xtuml"); StateMachineEventDataItem_c param = StateMachineEventDataItem_c.StateMachineEventDataItemInstance(testRoot); assertNotNull("Unable to locate test element", param); DataType_c dt = DataType_c.getOneS_DTOnR524(param); assertNotNull("Unable to locate test element", dt); GlobalElementInSystem_c gis = GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt)); assertNotNull("StateMachineEventDataItem was not migrated to use globals.", gis); assertTrue( "Incorrect data type associated with StateMachineEventDataItem after global migration", dt.getName().equals("timestamp")); }
/** @see ITreeContentProvider#getParent(Object) Returns the parent of this node */ public Object getParent(Object arg) { Activity_c result150 = Activity_c.getOneA_AOnR1101( ActivityNode_c.getOneA_NOnR1105( ActionNode_c.getOneA_ACTOnR1107( AcceptEvent_c.getOneA_AEOnR1112((AcceptEventAction_c) arg)))); if (result150 != null) { return result150; } Package_c result151 = Package_c.getOneEP_PKGOnR8000( PackageableElement_c.getOnePE_PEOnR8001( ActivityNode_c.getOneA_NOnR1105( ActionNode_c.getOneA_ACTOnR1107( AcceptEvent_c.getOneA_AEOnR1112((AcceptEventAction_c) arg))))); if (result151 != null) { return result151; } return null; }
public void testGlobalMigrationBridgeParameterDomain() throws Exception { Ooaofooa testRoot = Ooaofooa.getInstance("/model_upgrade/models/model_upgrade/domain/domain.xtuml"); BridgeParameter_c param = BridgeParameter_c.BridgeParameterInstance( testRoot, new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((BridgeParameter_c) candidate).getName().equals("message"); } }); assertNotNull("Unable to locate test element", param); DataType_c dt = DataType_c.getOneS_DTOnR22(param); assertNotNull("Unable to locate test element", dt); GlobalElementInSystem_c gis = GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt)); assertNotNull("BridgeParameter was not migrated to use globals.", gis); assertTrue( "Incorrect data type associated with BridgeParameter after global migration", dt.getName().equals("string")); }
public void testGlobalMigrationAttributeComponent() throws Exception { Ooaofooa testRoot = Ooaofooa.getInstance( "/model_upgrade/models/model_upgrade/ComponentPackage/ComponentPackage.xtuml"); Attribute_c param = Attribute_c.AttributeInstance( testRoot, new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Attribute_c) candidate).getName().equals("attribute"); } }); assertNotNull("Unable to locate test element", param); DataType_c dt = DataType_c.getOneS_DTOnR114(param); assertNotNull("Unable to locate test element", dt); GlobalElementInSystem_c gis = GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt)); assertNotNull("Attribute was not migrated to use globals.", gis); assertTrue( "Incorrect data type associated with Attribute after global migration", dt.getName().equals("boolean")); }
public void testCanRenameAndCanDeleteUserDatatype() { class findUserDatatype implements ClassQueryInterface_c { findUserDatatype(String aname) { name = aname; } private String name; public boolean evaluate(Object candidate) { UserDataType_c selected = (UserDataType_c) candidate; return selected.Get_name().equals(name); } } UserDataType_c udt1 = UserDataType_c.getOneS_UDTOnR17( DataType_c.getManyS_DTsOnR8001( PackageableElement_c.getManyPE_PEsOnR8000(Package_c.getManyEP_PKGsOnR1405(m_sys))), new findUserDatatype("test")); // $NON-NLS-1$ assertTrue(udt1.Canrename()); assertTrue(udt1.Candelete()); }
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); }
public boolean performFinish() { TransactionUtil.TransactionGroup transactionGroup = null; ModelRoot modelRoot = v_asyncMessage.getModelRoot(); try { transactionGroup = TransactionUtil.startTransactionsOnSelectedModelRoots( "Instance Event Formalize"); //$NON-NLS-1$ Message_c v_message = Message_c.getOneMSG_MOnR1018(v_asyncMessage); InteractionParticipant_c v_participant = InteractionParticipant_c.getOneSQ_POnR1007(v_message); Lifespan_c v_ls = Lifespan_c.getOneSQ_LSOnR930(v_participant); ClassInstanceParticipant_c v_cip = ClassInstanceParticipant_c.getOneSQ_CIPOnR930( InteractionParticipant_c.getOneSQ_POnR940(v_ls)); ModelClass_c v_cipclass = (ModelClass_c) modelRoot.getInstanceList(ModelClass_c.class).getGlobal(null, Gd_c.Null_unique_id()); if (((v_cip != null))) { v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip); } else { v_cip = ClassInstanceParticipant_c.getOneSQ_CIPOnR930( InteractionParticipant_c.getOneSQ_POnR1007(v_message)); if (((v_cip != null))) { Communication_c v_communication = Communication_c.getOneCOMM_COMMOnR1126( ParticipantInCommunication_c.getOneCOMM_PICOnR1126( InteractionParticipant_c.getOneSQ_POnR930(v_cip))); if (((v_communication != null))) { v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip); } } } if (((v_cipclass != null))) { StateMachineEvent_c v_evt = StateMachineEvent_c.getOneSM_EVTOnR1009( EventMessage_c.getOneMSG_EOnR1019(v_asyncMessage)); java.util.UUID v_existingId = Gd_c.Null_unique_id(); if (((v_evt != null))) { v_existingId = v_evt.getSmevt_id(); } StateMachine_c v_stateMachine = StateMachine_c.getOneSM_SMOnR517(InstanceStateMachine_c.getOneSM_ISMOnR518(v_cipclass)); StateMachine_c[] v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR8001( PackageableElement_c.getManyPE_PEsOnR8000( Package_c.getManyEP_PKGsOnR1405( SystemModel_c.getManyS_SYSsOnR1405( Package_c.getManyEP_PKGsOnR8000( PackageableElement_c.getManyPE_PEsOnR8001( v_cipclass)))))))); if (((v_machines.length == 0))) { v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR2( Subsystem_c.getManyS_SSsOnR1( Domain_c.getManyS_DOMsOnR1( Subsystem_c.getManyS_SSsOnR2(v_cipclass)))))); } if (((v_Message != null))) { if (v_asyncMessage != null) { v_asyncMessage.Formalizewithevent(v_Message.getSmevt_id()); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } } // catch all exceptions and cancel the transaction } catch (Exception e) { if (transactionGroup != null) TransactionUtil.cancelTransactions(transactionGroup, e); CorePlugin.logError("Transaction: Instance Event Formalize failed", e); // $NON-NLS-1$ // return true so that the wizard will // close return true; } if (transactionGroup != null) TransactionUtil.endTransactions(transactionGroup); if (m_viewer != null) { if (m_viewer instanceof StructuredViewer) { ((StructuredViewer) m_viewer).refresh(v_asyncMessage); } else { m_viewer.refresh(); } } return true; }
private void performPETest(Component_c comp, int expectedPECount) { PackageableElement_c[] pes = PackageableElement_c.getManyPE_PEsOnR8003(comp); assertEquals("Did not find expected PE count.", expectedPECount, pes.length); }
public void onPageEntry() { Ooaofooa modelRoot = Selection.getModelRoot( (StructuredSelection) ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).getSelection()); // cache for previous user selections StateMachineEvent_c v_Message = ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).v_Message; // cache for context AsynchronousMessage_c v_asyncMessage = ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).v_asyncMessage; ClassInstanceParticipant_c v_cip = ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).v_cip; if (((v_asyncMessage != null))) { if (((v_cip != null))) { Message_c v_message = Message_c.getOneMSG_MOnR1018(v_asyncMessage); InteractionParticipant_c v_participant = InteractionParticipant_c.getOneSQ_POnR930(v_cip); ModelClass_c v_mclass = ModelClass_c.getOneO_OBJOnR934(v_cip); if (((v_mclass != null))) { StateMachineEvent_c v_evt = StateMachineEvent_c.getOneSM_EVTOnR1009( EventMessage_c.getOneMSG_EOnR1019(v_asyncMessage)); java.util.UUID v_existingId = Gd_c.Null_unique_id(); if (((v_evt != null))) { v_existingId = v_evt.getSmevt_id(); } StateMachine_c v_stateMachine = StateMachine_c.getOneSM_SMOnR517(InstanceStateMachine_c.getOneSM_ISMOnR518(v_mclass)); StateMachine_c[] v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR8001( PackageableElement_c.getManyPE_PEsOnR8000( Package_c.getManyEP_PKGsOnR1405( SystemModel_c.getManyS_SYSsOnR1405( Package_c.getManyEP_PKGsOnR8000( PackageableElement_c.getManyPE_PEsOnR8001( v_mclass)))))))); if (((v_machines.length == 0))) { v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR2( Subsystem_c.getManyS_SSsOnR1( Domain_c.getManyS_DOMsOnR1( Subsystem_c.getManyS_SSsOnR2(v_mclass)))))); } if (((v_Message != null))) {} } } } }