Esempio n. 1
0
  private NonRootModelElement getDestination(NonRootModelElement rto) {
    if (rto instanceof InterfaceReference_c && getMethodName().contains("C1")) {
      // need the package for the parent component
      return rto.getFirstParentComponent().getFirstParentPackage();
    }
    if (rto instanceof Port_c && getMethodName().contains("C1")) {
      // need the package for the parent component
      return rto.getFirstParentComponent().getFirstParentPackage();
    }
    if (getMethodName().contains("C1")) {
      return rto.getFirstParentPackage();
    } else if (getMethodName().contains("C2")) {
      return Package_c.getOneEP_PKGOnR1401(inscopeOtherProject);
    } else if (getMethodName().contains("C3")) {
      return Package_c.getOneEP_PKGOnR1401(
          m_sys,
          new ClassQueryInterface_c() {

            @Override
            public boolean evaluate(Object candidate) {
              Package_c pkg = (Package_c) candidate;
              PackageableElement_c pe = PackageableElement_c.getOnePE_PEOnR8001(pkg);
              if (pe.getVisibility() == Visibility_c.Private) {
                return true;
              }
              return false;
            }
          });
    } else {
      return Package_c.getOneEP_PKGOnR1401(outOfScopeOtherProject);
    }
  }
 public void testRenamePackageExistingFolder() 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("Newpackage", testPackage);
   Package_c[] pkgs =
       Package_c.getManyEP_PKGsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPackage));
   Package_c pkg = pkgs[pkgs.length - 1];
   UITestingUtilities.addElementToGraphicalSelection(pkg);
   doRenameTest(EXISTING_FOLDER_ERROR, getName());
 }
  public void doTestParseErrorPreferencesComponent() throws BackingStoreException, CoreException {
    project = getProjectHandle(projectName);
    Package_c testPkg =
        Package_c.getOneEP_PKGOnR1401(
            m_sys,
            new ClassQueryInterface_c() {

              @Override
              public boolean evaluate(Object candidate) {
                return ((Package_c) candidate).getName().equals("Component-Test");
              }
            });
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences.ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE,
        true);
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences
            .ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE_REALIZED,
        false);
    IMarker[] errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 0, errors.length);
    ExternalEntity_c ee =
        ExternalEntity_c.getOneS_EEOnR8001(
            PackageableElement_c.getManyPE_PEsOnR8000(
                Package_c.getManyEP_PKGsOnR8001(
                    PackageableElement_c.getManyPE_PEsOnR8003(
                        Component_c.getManyC_CsOnR8001(
                            PackageableElement_c.getManyPE_PEsOnR8000(testPkg))))));
    Bridge_c bridge = Bridge_c.getOneS_BRGOnR19(ee);
    bridge.setAction_semantics_internal("// test comment");
    errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 1, errors.length);
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences
            .ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE_REALIZED,
        true);
    errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 5, errors.length);
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences
            .ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE_REALIZED,
        false);
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences.ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE,
        false);
    errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 1, errors.length);
  }
  public void doTestParseErrorPreferencesPackage() throws BackingStoreException, CoreException {
    Package_c testPkg =
        Package_c.getOneEP_PKGOnR1401(
            m_sys,
            new ClassQueryInterface_c() {

              @Override
              public boolean evaluate(Object candidate) {
                return ((Package_c) candidate).getName().equals("Package-Test");
              }
            });
    IMarker[] errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 5, errors.length);
    ExternalEntity_c ee =
        ExternalEntity_c.getOneS_EEOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPkg));
    ee.setIsrealized(true);
    errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 4, errors.length);
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences
            .ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE_REALIZED,
        true);
    errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 5, errors.length);
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences
            .ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE_REALIZED,
        false);
    setProjectPreference(
        BridgePointProjectActionLanguagePreferences.ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE,
        false);
    errors = parseModel(testPkg);
    assertEquals("Incorrect number of parse errors were found.", 0, errors.length);
  }
 public void testRenamePackageNoName() {
   createElement("Newpackage", testPackage);
   Package_c[] pkgs =
       Package_c.getManyEP_PKGsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPackage));
   Package_c pkg = pkgs[pkgs.length - 1];
   UITestingUtilities.addElementToGraphicalSelection(pkg);
   doRenameTest(Messages.resources_nameEmpty, "");
 }
 public void testPackageRenameWithInvalidCharacter() {
   createElement("Newpackage", testPackage);
   Package_c[] pkgs =
       Package_c.getManyEP_PKGsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(testPackage));
   Package_c pkg = pkgs[pkgs.length - 1];
   UITestingUtilities.addElementToGraphicalSelection(pkg);
   doRenameTest(INVALID_CHAR_ERROR, "*");
 }
 public void testNewInterfaceEditorExistingFolder() 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);
   doGraphicalCreationTest("Components::Interface", EXISTING_FOLDER_ERROR, getName());
 }
 @Override
 public void initialSetup() throws CoreException {
   // create test system
   project = TestingUtilities.createProject("CanvasInitialNameTests");
   m_sys = getSystemModel(project.getName());
   m_sys.Newpackage();
   Package_c[] testPackages = Package_c.getManyEP_PKGsOnR1401(m_sys);
   testPackage = testPackages[testPackages.length - 1];
   CanvasTestUtilities.openDiagramEditor(testPackage);
   editor = (GraphicalEditor) UITestingUtilities.getActiveEditor();
 }
  /** Returns a communication with the given name */
  private Package_c getPackage(final String name) {
    Package_c communication =
        Package_c.PackageInstance(
            modelRoot,
            new ClassQueryInterface_c() {

              public boolean evaluate(Object candidate) {
                Package_c selected = (Package_c) candidate;
                return selected.getName().equals(name);
              }
            });
    return communication;
  }
 public void testNewInterfaceCMEExistingFolder() 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);
   String expectedError = EXISTING_FOLDER_ERROR;
   if (!Platform.getOS().contains("win")) {
     expectedError = expectedError.replace("\r", "");
   }
   doNewCMETest("Components::Interface", expectedError, getName());
 }
 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());
 }