private void populateTransformerInstances(ModelClass_c testObj, boolean instanceBased) { for (int i = 0; i < funcs.length; ++i) { Operation_c[] testObjTrans = Operation_c.getManyO_TFRsOnR115(testObj); Operation_c testTrans = null; for (int tfrInstCount = 0; tfrInstCount < testObjTrans.length; tfrInstCount++) { Operation_c selected = testObjTrans[tfrInstCount]; if (selected.getName().equals(funcs[i])) { testTrans = testObjTrans[tfrInstCount]; break; } } if (testTrans != null) { if (instanceBased) { if (m_testIBTfr[i] == null) m_testIBTfr[i] = testTrans; } else { if (m_testCBTfr[i] == null) m_testCBTfr[i] = testTrans; } } else fail( "Missing operation " + testObj.getKey_lett() + "::" + funcs[i]); // $NON-NLS-1$//$NON-NLS-2$ } }
private void populateArrayStateActionInstances() { class Object_test1_c implements ClassQueryInterface_c { Object_test1_c(String p) { m_p = p; } private String m_p; public boolean evaluate(Object inst) { ModelClass_c selected = (ModelClass_c) inst; return selected.getName().equals(m_p); } } ModelClass_c obj = ModelClass_c.ModelClassInstance(modelRoot, new Object_test1_c("ArrayOne")); // $NON-NLS-1$ InstanceStateMachine_c ism = InstanceStateMachine_c.getOneSM_ISMOnR518(obj); StateMachine_c sm_i = StateMachine_c.getOneSM_SMOnR517(ism); StateMachineState_c[] states = StateMachineState_c.getManySM_STATEsOnR501(sm_i); Action_c i_acts[] = Action_c.getManySM_ACTsOnR514( ActionHome_c.getManySM_AHsOnR513(MooreActionHome_c.getManySM_MOAHsOnR511(states))); for (int i = 0; i < i_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(i_acts[i]); MooreActionHome_c moah = MooreActionHome_c.getOneSM_MOAHOnR513(ah); StateMachineState_c st = StateMachineState_c.getOneSM_STATEOnR511(moah); if (st.getName().equals("StateOne")) // $NON-NLS-1$ m_arrayStateAction[State_StateOne] = i_acts[i]; else if (st.getName().equals("StateTwo")) // $NON-NLS-1$ m_arrayStateAction[State_StateTwo] = i_acts[i]; else if (st.getName().equals("StateThree")) // $NON-NLS-1$ m_arrayStateAction[State_StateThree] = i_acts[i]; } }
public void testRenameClassNoName() { createElement("Newclass", testPackage); ModelClass_c[] objs = ModelClass_c.getManyO_OBJsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPackage)); ModelClass_c obj = objs[objs.length - 1]; UITestingUtilities.addElementToGraphicalSelection(obj); doRenameTest(Messages.resources_nameEmpty, ""); }
public void testClassRenameWithInvalidCharacter() { createElement("Newclass", testPackage); ModelClass_c[] objs = ModelClass_c.getManyO_OBJsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPackage)); ModelClass_c obj = objs[objs.length - 1]; UITestingUtilities.addElementToGraphicalSelection(obj); doRenameTest(INVALID_CHAR_ERROR, "*"); }
public void testOperationWithSpaces() { createElement("Newclass", testPackage); ModelClass_c[] classes = ModelClass_c.getManyO_OBJsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPackage)); ModelClass_c clazz = classes[classes.length - 1]; UITestingUtilities.addElementToGraphicalSelection(clazz); doNewCMETest("Operation", CorePlugin.INVALID_NAME_SPACES); }
/* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); if (!firstSetup) { String modelName = "testOAL1"; TestingUtilities.importTestingProjectIntoWorkspace("testOAL1"); project = ResourcesPlugin.getWorkspace().getRoot().getProject("testOAL1"); m_sys = getSystemModel(project.getName()); String modelRootId = Ooaofooa.createModelRootId(project, modelName, true); modelRoot = Ooaofooa.getInstance(modelRootId, true); } firstSetup = true; populateFunctionInstances(); populateBridgeInstances(); class Object_test1_c implements ClassQueryInterface_c { Object_test1_c(String id) { m_id = id; } private String m_id; public boolean evaluate(Object inst) { ModelClass_c selected = (ModelClass_c) inst; return selected.getKey_lett().equals(m_id); } } ModelClass_c diskObj = ModelClass_c.ModelClassInstance(modelRoot, new Object_test1_c("D_D")); // $NON-NLS-1$ ModelClass_c libObj = ModelClass_c.ModelClassInstance(modelRoot, new Object_test1_c("D_H")); // $NON-NLS-1$ populateTransformerInstances(diskObj, false); populateTransformerInstances(libObj, true); populateStateActionInstances(); populateMDAInstances(); }
public void testRenameClassExistingFolder() throws CoreException { // create existing folder first ResourcesPlugin.getWorkspace() .getRoot() .getFolder(new Path(testPackage.getFile().getParent().getFullPath() + "/" + getName())) .create(true, true, new NullProgressMonitor()); BaseTest.dispatchEvents(0); createElement("Newclass", testPackage); ModelClass_c[] objs = ModelClass_c.getManyO_OBJsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPackage)); ModelClass_c obj = objs[objs.length - 1]; UITestingUtilities.addElementToGraphicalSelection(obj); doRenameTest(EXISTING_FOLDER_ERROR, getName()); }
protected void setUp() throws Exception { super.setUp(); String componentPackageName = "Arrays"; PersistableModelComponent domainComponentPackage = ensureAvailableAndLoaded( projectName, componentPackageName, false, false, "Component Package"); arrayModelRoot = (Ooaofooa) domainComponentPackage.getRootModelElement().getModelRoot(); IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore(); store.setValue(BridgePointPreferencesStore.ALLOW_IMPLICIT_COMPONENT_ADDRESSING, true); class ComponentNameTest implements ClassQueryInterface_c { public boolean evaluate(Object candidate) { Component_c selected = (Component_c) candidate; return selected.getName().equals("SingleDimensionFixedArrays"); } } Component_c comp = Component_c.ComponentInstance(arrayModelRoot, new ComponentNameTest()); populateFunctionInstances(); populateBridgeInstances(); class Object_test1_c implements ClassQueryInterface_c { Object_test1_c(String id) { m_id = id; } private String m_id; public boolean evaluate(Object inst) { ModelClass_c selected = (ModelClass_c) inst; return selected.getKey_lett().equals(m_id); } } ModelClass_c testObj = ModelClass_c.ModelClassInstance(arrayModelRoot, new Object_test1_c("A_T")); // $NON-NLS-1$ populateTransformerInstances(testObj, false); populateInterfaceOperationInstances(comp, "Port1", true); populateInterfaceOperationInstances(comp, "Port2", false); populateArrayStateActionInstances(); }
/* * Recursively traverse bottom-up building the "-" separated list of names * of the parent elements. */ public static String getContainerList(NonRootModelElement elem, int ooaType) { String rVal = ""; Object parent = null; ModelInspector inspector = new ModelInspector(); IModelClassInspector classInspector = null; if (ooaType == Ooatype_c.DataTypePackage) { classInspector = inspector.getInspector(DataTypePackage_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.ExternalEntityPackage) { classInspector = inspector.getInspector(ExternalEntityPackage_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.FunctionPackage) { classInspector = inspector.getInspector(FunctionPackage_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.Subsystem) { Subsystem_c subsystemParent = Subsystem_c.getOneS_SSOnR41(SubsystemInSubsystem_c.getOneS_SISOnR42((Subsystem_c) elem)); if (subsystemParent != null) { parent = subsystemParent; } else { classInspector = inspector.getInspector(Subsystem_c.class); parent = classInspector.getParent(elem); } } else if (ooaType == Ooatype_c.Sequence) { classInspector = inspector.getInspector(Sequence_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.Communication) { classInspector = inspector.getInspector(Communication_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.UseCaseDiagram) { classInspector = inspector.getInspector(UseCaseDiagram_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.Activity) { classInspector = inspector.getInspector(Activity_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.StateMachine) { ModelClass_c obj = null; Class eClass = elem.getClass(); if (eClass == ClassStateMachine_c.class) { obj = ModelClass_c.getOneO_OBJOnR519((ClassStateMachine_c) elem); } if (obj == null) { obj = ModelClass_c.getOneO_OBJOnR518((InstanceStateMachine_c) elem); } if (obj != null) { classInspector = inspector.getInspector(ModelClass_c.class); parent = classInspector.getParent(obj); } } else if (ooaType == Ooatype_c.Domain) { classInspector = inspector.getInspector(Domain_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.Component) { classInspector = inspector.getInspector(Component_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.ComponentPackage) { classInspector = inspector.getInspector(ComponentPackage_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.InterfacePackage) { classInspector = inspector.getInspector(InterfacePackage_c.class); parent = classInspector.getParent(elem); } else if (ooaType == Ooatype_c.Package) { classInspector = inspector.getInspector(Package_c.class); parent = classInspector.getParent(elem); } if (parent != null) { NonRootModelElement parentElem = (NonRootModelElement) parent; Class parentClass = parent.getClass(); if (parentClass == DataTypePackage_c.class) { rVal = getContainerList(parentElem, Ooatype_c.DataTypePackage) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == ExternalEntityPackage_c.class) { rVal = getContainerList(parentElem, Ooatype_c.ExternalEntityPackage) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == FunctionPackage_c.class) { rVal = getContainerList(parentElem, Ooatype_c.FunctionPackage) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == Subsystem_c.class) { rVal = getContainerList(parentElem, Ooatype_c.Subsystem) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == Sequence_c.class) { rVal = getContainerList(parentElem, Ooatype_c.Sequence) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == Communication_c.class) { rVal = getContainerList(parentElem, Ooatype_c.Communication) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == UseCaseDiagram_c.class) { rVal = getContainerList(parentElem, Ooatype_c.UseCaseDiagram) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == Activity_c.class) { rVal = getContainerList(parentElem, Ooatype_c.Activity) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == Domain_c.class) { rVal = getContainerList(parentElem, Ooatype_c.Domain) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == Component_c.class) { rVal = getContainerList(parentElem, Ooatype_c.Component) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == ComponentPackage_c.class) { rVal = getContainerList(parentElem, Ooatype_c.ComponentPackage) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == InterfacePackage_c.class) { rVal = getContainerList(parentElem, Ooatype_c.InterfacePackage) + parentElem.getName() + "-"; //$NON-NLS-1$ } else if (parentClass == Package_c.class) { rVal = getContainerList(parentElem, Ooatype_c.Package) + parentElem.getName() + "-"; //$NON-NLS-1$ } else { rVal = parentElem.getName() + "-"; } } return rVal; }
public boolean evaluate(Object inst) { ModelClass_c selected = (ModelClass_c) inst; return selected.getName().equals(m_p); }
public boolean evaluate(Object inst) { ModelClass_c selected = (ModelClass_c) inst; return selected.getKey_lett().equals(m_id); }
private void populateStateActionInstances() { class Object_test1_c implements ClassQueryInterface_c { Object_test1_c(String p) { m_p = p; } private String m_p; public boolean evaluate(Object inst) { ModelClass_c selected = (ModelClass_c) inst; return selected.getName().equals(m_p); } } ModelClass_c obj = ModelClass_c.ModelClassInstance(modelRoot, new Object_test1_c("Test")); // $NON-NLS-1$ InstanceStateMachine_c ism = InstanceStateMachine_c.getOneSM_ISMOnR518(obj); StateMachine_c sm_i = StateMachine_c.getOneSM_SMOnR517(ism); StateMachineState_c[] states = StateMachineState_c.getManySM_STATEsOnR501(sm_i); Action_c i_acts[] = Action_c.getManySM_ACTsOnR514( ActionHome_c.getManySM_AHsOnR513(MooreActionHome_c.getManySM_MOAHsOnR511(states))); for (int i = 0; i < i_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(i_acts[i]); MooreActionHome_c moah = MooreActionHome_c.getOneSM_MOAHOnR513(ah); StateMachineState_c st = StateMachineState_c.getOneSM_STATEOnR511(moah); if (st.getName().equals("none")) // $NON-NLS-1$ m_testAction[STATE_ISM_NONE] = i_acts[i]; else if (st.getName().equals("one")) // $NON-NLS-1$ m_testAction[STATE_ISM_ONE] = i_acts[i]; else if (st.getName().equals("two")) // $NON-NLS-1$ m_testAction[STATE_ISM_TWO] = i_acts[i]; else if (st.getName().equals("three")) // $NON-NLS-1$ m_testAction[STATE_ISM_THREE] = i_acts[i]; else if (st.getName().equals("SDTTest")) // $NON-NLS-1$ m_testAction[STATE_ISM_SDTTest] = i_acts[i]; else if (st.getName().equals("SDTMultLvlTest")) // $NON-NLS-1$ m_testAction[STATE_ISM_SDTMultLvlTest] = i_acts[i]; } NewStateTransition_c[] trans = NewStateTransition_c.getManySM_NSTXNsOnR507(Transition_c.getManySM_TXNsOnR505(sm_i)); Action_c[] t_acts = Action_c.getManySM_ACTsOnR514( ActionHome_c.getManySM_AHsOnR513( TransitionActionHome_c.getManySM_TAHsOnR530( Transition_c.getManySM_TXNsOnR507(trans)))); for (int i = 0; i < t_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(t_acts[i]); TransitionActionHome_c tah = TransitionActionHome_c.getOneSM_TAHOnR513(ah); Transition_c tran = Transition_c.getOneSM_TXNOnR530(tah); if (tran.Get_name().contains("none")) // $NON-NLS-1$ m_testAction[TRANS_ISM_NONE] = t_acts[i]; else if (tran.getName().contains("one")) // $NON-NLS-1$ m_testAction[TRANS_ISM_ONE] = t_acts[i]; else if (tran.getName().contains("two")) // $NON-NLS-1$ m_testAction[TRANS_ISM_TWO] = t_acts[i]; else if (tran.getName().contains("three")) // $NON-NLS-1$ m_testAction[TRANS_ISM_THREE] = t_acts[i]; else if (tran.getName().contains("SDTTest")) // $NON-NLS-1$ m_testAction[TRANS_ISM_SDTTest] = t_acts[i]; else if (tran.getName().contains("SDTMultLvlTest")) // $NON-NLS-1$ m_testAction[TRANS_ISM_SDTMultLvlTest] = t_acts[i]; } CreationTransition_c[] crtrs = CreationTransition_c.getManySM_CRTXNsOnR507(Transition_c.getManySM_TXNsOnR505(sm_i)); Action_c[] crt_acts = Action_c.getManySM_ACTsOnR514( ActionHome_c.getManySM_AHsOnR513( TransitionActionHome_c.getManySM_TAHsOnR530( Transition_c.getManySM_TXNsOnR507(crtrs)))); for (int i = 0; i < crt_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(crt_acts[i]); TransitionActionHome_c tah = TransitionActionHome_c.getOneSM_TAHOnR513(ah); Transition_c tran = Transition_c.getOneSM_TXNOnR530(tah); if (tran.Get_name().contains("none")) // $NON-NLS-1$ m_testAction[TRANS_CREATION_ISM_NONE] = crt_acts[i]; else if (tran.getName().contains("one")) // $NON-NLS-1$ m_testAction[TRANS_CREATION_ISM_ONE] = crt_acts[i]; else if (tran.getName().contains("two")) // $NON-NLS-1$ m_testAction[TRANS_CREATION_ISM_TWO] = crt_acts[i]; else if (tran.getName().contains("three")) // $NON-NLS-1$ m_testAction[TRANS_CREATION_ISM_THREE] = crt_acts[i]; else if (tran.getName().contains("SDTTest")) // $NON-NLS-1$ m_testAction[TRANS_CREATION_ISM_SDTTest] = crt_acts[i]; else if (tran.getName().contains("SDTMultLvlTest")) // $NON-NLS-1$ m_testAction[TRANS_CREATION_ISM_SDTMultLvlTest] = crt_acts[i]; } ClassStateMachine_c asm = ClassStateMachine_c.getOneSM_ASMOnR519(obj); StateMachine_c sm_a = StateMachine_c.getOneSM_SMOnR517(asm); states = StateMachineState_c.getManySM_STATEsOnR501(sm_a); Action_c a_acts[] = Action_c.getManySM_ACTsOnR514( ActionHome_c.getManySM_AHsOnR513(MooreActionHome_c.getManySM_MOAHsOnR511(states))); for (int i = 0; i < a_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(a_acts[i]); MooreActionHome_c moah = MooreActionHome_c.getOneSM_MOAHOnR513(ah); if (moah != null) { StateMachineState_c st = StateMachineState_c.getOneSM_STATEOnR511(moah); if (st.getName().equals("one")) // $NON-NLS-1$ m_testAction[STATE_ASM_ONE] = a_acts[i]; else if (st.getName().equals("two")) // $NON-NLS-1$ m_testAction[STATE_ASM_TWO] = a_acts[i]; else if (st.getName().equals("three")) // $NON-NLS-1$ m_testAction[STATE_ASM_THREE] = a_acts[i]; else if (st.getName().equals("SDTTest")) // $NON-NLS-1$ m_testAction[STATE_ASM_SDTTest] = a_acts[i]; else if (st.getName().equals("SDTMultLvlTest")) // $NON-NLS-1$ m_testAction[STATE_ASM_SDTMultLvlTest] = a_acts[i]; } } trans = NewStateTransition_c.getManySM_NSTXNsOnR507(Transition_c.getManySM_TXNsOnR505(sm_a)); t_acts = Action_c.getManySM_ACTsOnR514( ActionHome_c.getManySM_AHsOnR513( TransitionActionHome_c.getManySM_TAHsOnR530( Transition_c.getManySM_TXNsOnR507(trans)))); for (int i = 0; i < t_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(t_acts[i]); TransitionActionHome_c tah = TransitionActionHome_c.getOneSM_TAHOnR513(ah); Transition_c tran = Transition_c.getOneSM_TXNOnR530(tah); if (tran.Get_name().contains("none")) // $NON-NLS-1$ m_testAction[TRANS_CSM_NONE] = t_acts[i]; else if (tran.getName().contains("one")) // $NON-NLS-1$ m_testAction[TRANS_CSM_ONE] = t_acts[i]; else if (tran.getName().contains("two")) // $NON-NLS-1$ m_testAction[TRANS_CSM_TWO] = t_acts[i]; else if (tran.getName().contains("three")) // $NON-NLS-1$ m_testAction[TRANS_CSM_THREE] = t_acts[i]; else if (tran.getName().contains("SDTTest")) // $NON-NLS-1$ m_testAction[TRANS_CSM_SDTTest] = t_acts[i]; else if (tran.getName().contains("SDTMultLvlTest")) // $NON-NLS-1$ m_testAction[TRANS_CSM_SDTMultLvlTest] = t_acts[i]; } obj = ModelClass_c.ModelClassInstance(modelRoot, new Object_test1_c("Test Poly")); // $NON-NLS-1$ ism = InstanceStateMachine_c.getOneSM_ISMOnR518(obj); sm_i = StateMachine_c.getOneSM_SMOnR517(ism); i_acts = Action_c.getManySM_ACTsOnR515(sm_i); for (int i = 0; i < i_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(i_acts[i]); MooreActionHome_c moah = MooreActionHome_c.getOneSM_MOAHOnR513(ah); if (moah != null) { StateMachineState_c st = StateMachineState_c.getOneSM_STATEOnR511(moah); if (st.getName().equals("PolyTwo")) // $NON-NLS-1$ m_testAction[STATE_ISM_POLYTWO] = i_acts[i]; else if (st.getName().equals("PolyOrphaned")) // $NON-NLS-1$ m_testAction[STATE_ISM_POLYORPHANED] = i_acts[i]; } } trans = NewStateTransition_c.getManySM_NSTXNsOnR507(Transition_c.getManySM_TXNsOnR505(sm_i)); t_acts = Action_c.getManySM_ACTsOnR514( ActionHome_c.getManySM_AHsOnR513( TransitionActionHome_c.getManySM_TAHsOnR530( Transition_c.getManySM_TXNsOnR507(trans)))); for (int i = 0; i < t_acts.length; ++i) { ActionHome_c ah = ActionHome_c.getOneSM_AHOnR514(t_acts[i]); TransitionActionHome_c tah = TransitionActionHome_c.getOneSM_TAHOnR513(ah); Transition_c tran = Transition_c.getOneSM_TXNOnR530(tah); StateMachineState_c toState = StateMachineState_c.getOneSM_STATEOnR503( StateEventMatrixEntry_c.getManySM_SEMEsOnR504( NewStateTransition_c.getManySM_NSTXNsOnR507(tran))); if (toState.getName().equals("PolyTwo")) // $NON-NLS-1$ m_testAction[TRANS_ISM_POLYTWO] = t_acts[i]; else if (toState.getName().equals("PolyOrphaned")) // $NON-NLS-1$ m_testAction[TRANS_ISM_POLYORPHANED] = t_acts[i]; } }