Exemplo n.º 1
0
 protected void initTests(final Bundle bundle) throws CoreException, IOException {
   bot = new SWTWorkbenchBot();
   ProjectUtils.removeAllProjectFromTheWorkspace();
   IProject testProject = ProjectUtils.createProject(PROJECT_NAME);
   modelFile =
       PapyrusProjectUtils.copyPapyrusModel(testProject, bundle, SOURCE_PATH, FILE_ROOT_NAME);
   AbstractControlModeTest.bundle = bundle;
 }
  public static void initTests(
      final Bundle bundle, final String projectName, final String papyrusModelPath)
      throws CoreException, IOException, BundleException {
    ProjectUtils.removeAllProjectFromTheWorkspace();
    IProject testProject = ProjectUtils.createProject(projectName);
    final IFile file =
        PapyrusProjectUtils.copyPapyrusModel(testProject, bundle, SOURCE_PATH, FILE_ROOT_NAME);
    RunnableWithResult<?> runnableWithResult =
        new RunnableWithResult.Impl<Object>() {

          @Override
          public void run() {
            try {
              papyrusEditor = EditorUtils.openPapyrusEditor(file);
            } catch (PartInitException e) {
              setStatus(new Status(IStatus.ERROR, bundle.getSymbolicName(), e.getMessage()));
            }
            try {
              TableCreationInSysMLModelTest.view = ModelExplorerUtils.openModelExplorerView();
            } catch (PartInitException e) {
              setStatus(new Status(IStatus.ERROR, bundle.getSymbolicName(), e.getMessage()));
            }
            EObject root =
                ModelExplorerUtils.getRootInModelExplorer(TableCreationInSysMLModelTest.view);
            TableCreationInSysMLModelTest.rootModel = (Model) root;
            class_ =
                (Class) TableCreationInSysMLModelTest.rootModel.getMember("Class1"); // $NON-NLS-1$
            requirement1 =
                (Class)
                    TableCreationInSysMLModelTest.rootModel.getMember(
                        "Requirement1"); //$NON-NLS-1$
            requirement2 =
                (Class)
                    TableCreationInSysMLModelTest.rootModel.getMember(
                        "Requirement2"); //$NON-NLS-1$
            if (requirement1 != null) {
              nestedRequirement1 =
                  (Class) requirement1.getMember("NestedRequirement1"); // $NON-NLS-1$
              nestedRequirement2 =
                  (Class) requirement1.getMember("NestedRequirement2"); // $NON-NLS-1$
              setStatus(Status.OK_STATUS);

            } else {
              setStatus(
                  new Status(
                      IStatus.ERROR,
                      bundle.getSymbolicName(),
                      "Requirement1 not found")); //$NON-NLS-1$
            }
          }
        };
    Display.getDefault().syncExec(runnableWithResult);

    Assert.assertEquals(
        runnableWithResult.getStatus().getMessage(),
        IStatus.OK,
        runnableWithResult.getStatus().getSeverity());
    Assert.assertNotNull(class_);
    Assert.assertNotNull(requirement1);
    Assert.assertNotNull(requirement2);
    Assert.assertNotNull(TableCreationInSysMLModelTest.rootModel);
  }