@Test
  public void testTargetRetentionQuickFixes() {
    /* import the project */
    String projectName = "httpAnnot2";
    importWSTestProject(projectName);

    /* assert that there are two JAX-RS errors */
    assertCountOfProblemsExists(ProblemType.ERROR, projectName, null, JAX_RS_PROBLEM, 2);

    /* open MyAnnot.java */
    openMyAnnotJavaFile(projectName);
    TextEditor editor = setCursorPositionToLineInTextEditor("MyAnnot");

    /* check that there are quick fixes for both required annotations */
    AbstractWait.sleep(TimePeriod.NORMAL);
    editor
        .openQuickFixContentAssistant()
        .chooseProposal("Add @Target annotation on type 'MyAnnot'");
    AbstractWait.sleep(TimePeriod.getCustom(1)); // makes a delay between applying quickfixes

    /* there is need to wait a while until validation starts to work */
    editor
        .openQuickFixContentAssistant()
        .chooseProposal("Add @Retention annotation on type 'MyAnnot'");

    /* save edited file */
    new TextEditor().save();
    AbstractWait.sleep(TimePeriod.getCustom(5));

    /* assert that there are no JAX-RS errors */
    assertCountOfValidationProblemsExists(ProblemType.ERROR, projectName, null, JAX_RS_PROBLEM, 0);
  }
  @Test
  public void testJPADetailView() {

    log.step("Open entity");
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    try {
      pe.getProject(PRJ)
          .getProjectItem("Java Resources", "src/main/java", "org.gen", "Actor.java")
          .open();
    } catch (RedDeerException e) {
      fail("Entities not generated, possible cause https://issues.jboss.org/browse/JBIDE-19175");
    }
    TextEditor textEditor = new TextEditor("Actor.java");
    textEditor.setCursorPosition(20, 1);

    log.step("Open JPA view and check content");
    JPADetailsView jpaDetailsView = new JPADetailsView();
    jpaDetailsView.open();

    try {
      new DefaultStyledText("Type 'Actor' is mapped as entity.");
    } catch (RedDeerException e) {
      fail(
          "JPA details should be available - known issue - https://issues.jboss.org/browse/JBIDE-17940");
    }
  }
 @Override
 public void tearDown() throws Exception {
   if (textEditor != null) {
     textEditor.setText(originalEditorText);
     textEditor.save();
     textEditor.close();
   }
   super.tearDown();
 }
  private void createParamConverter() {
    NewJavaClassWizardDialog newJavaClassDialog = new NewJavaClassWizardDialog();
    newJavaClassDialog.open();
    NewJavaClassWizardPage newJavaClassPage = newJavaClassDialog.getFirstPage();
    newJavaClassPage.setPackage("org.rest.test");
    newJavaClassPage.setName("Converter");
    newJavaClassDialog.finish();

    TextEditor editor = new TextEditor();
    editor.activate();
    editor.setText(PARAM_CONVERTER_PROVIDER_CLASS_TEXT);
    editor.save();
  }
  public static void modifyAndRepublishApplication(String applicationName) {
    TreeViewerHandler treeViewerHandler = TreeViewerHandler.getInstance();
    ProjectExplorer explorer = new ProjectExplorer();
    explorer.getProject(applicationName).getProjectItem("diy", "index.html").open();

    TextEditor editor = new TextEditor("index.html");
    editor.setText(ID407CreateApplicationFromExistingAndChangeRemoteNameTest.HTML_TEXT);
    editor.save();
    editor.close();

    ServersView servers = new ServersView();
    servers.open();
    treeViewerHandler.getTreeItem(new DefaultTree(), applicationName + " at OpenShift").select();

    new ContextMenu(OpenShiftLabel.ContextMenu.PUBLISH).select();

    try {
      new WaitUntil(new ShellWithTextIsAvailable("Identify Yourself"), TimePeriod.NORMAL);
      new DefaultShell("Identify Yourself").setFocus();
      new PushButton("OK").click();
    } catch (WaitTimeoutExpiredException ex) {
    }

    new WaitUntil(
        new ShellWithTextIsAvailable(OpenShiftLabel.Shell.PUBLISH_CHANGES), TimePeriod.LONG);

    new DefaultShell(OpenShiftLabel.Shell.PUBLISH_CHANGES);
    new DefaultStyledText(0).setText("Commit message");

    new WaitUntil(
        new ButtonWithTextIsEnabled(new PushButton(OpenShiftLabel.Button.COMMIT_PUBLISH)),
        TimePeriod.NORMAL);

    new PushButton(OpenShiftLabel.Button.COMMIT_PUBLISH).click();

    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);

    AbstractWait.sleep(TimePeriod.NORMAL);

    try {
      new WaitUntil(
          new ApplicationIsDeployedSuccessfully(
              Datastore.USERNAME, Datastore.DOMAIN, applicationName, "OpSh"),
          TimePeriod.VERY_LONG);
      // PASS
    } catch (WaitTimeoutExpiredException ex) {
      fail(
          "Application has not been deployed successfully. Browser does not "
              + "contain text of existing project which has been deployed.");
    }
  }
  @Test
  public void testHTTPMethodWithoutParameters() {
    /* import the project */
    String projectName = "httpAnnot1";
    importWSTestProject(projectName);

    /* assert that there is one Java problem */
    assertCountOfProblemsExists(ProblemType.ERROR, projectName, null, null, 1);

    /* open MyAnnot.java */
    openMyAnnotJavaFile(projectName);
    TextEditor editor = setCursorPositionToLineInTextEditor("@HttpMethod");

    /* check that there are quick fixes for both required annotations */
    editor.openQuickFixContentAssistant().chooseProposal("Add missing attributes");
    new TextEditor().save();

    /* assert that there is one JAX-RS errors - empty value */
    assertCountOfProblemsExists(ProblemType.ERROR, projectName, null, JAX_RS_PROBLEM, 1);
  }
  private void generateJPAHibernateAnnotationsContextMenu() {
    PackageExplorer pe = new PackageExplorer();
    pe.selectProjects(prj);

    TreeItem item = new DefaultTreeItem(prj, "src", pckg, "Dog.java");
    item.select();

    Menu menu = new ContextMenu("Source", "Generate Hibernate/JPA annotations");
    menu.select();

    new DefaultShell("Hibernate: add JPA annotations");
    new PushButton("Next >").click();
    new PushButton("Finish").click();

    new WorkbenchShell();
    new DefaultTreeItem(prj, "src", pckg, "Dog.java");
    item.doubleClick();

    TextEditor editor = new TextEditor("Dog.java");
    StringHelper sh = new StringHelper(editor.getText());
    sh.getPositionAfter("@Entity");
  }
 @Test
 public void testToggleComment() throws Throwable {
   // Test open page
   openPage();
   textEditor = new TextEditor(TEST_PAGE);
   originalEditorText = DEFAULT_TEST_PAGE_TEXT;
   textEditor.setText(DEFAULT_TEST_PAGE_TEXT);
   textEditor.save();
   // Test toggle comment from Source menu
   textEditor.setCursorPosition(16, 20);
   new ShellMenu("Source", "Toggle Comment").select();
   textEditor.save();
   new WaitWhile(new JobIsRunning());
   Browser browser = new InternalBrowser();
   assertVisualEditorContainsManyComments(browser, 2, TEST_PAGE);
   final String commentValue = "<h:commandButton action=\"hello\" value=\"Say Hello!\" />";
   assertVisualEditorContainsCommentWithValue(browser, commentValue);
   // Test untoggle comment from Source menu
   new ShellMenu("Source", "Toggle Comment").select();
   textEditor.save();
   new WaitWhile(new JobIsRunning());
   assertVisualEditorContainsManyComments(browser, 1, TEST_PAGE);
   // Test toggle comment with CTRL+SHIFT+C hot keys
   textEditor.activate();
   textEditor.setCursorPosition(16, 20);
   pressToggleCommentHotKeys();
   textEditor.save();
   new WaitWhile(new JobIsRunning());
   assertVisualEditorContainsManyComments(browser, 2, TEST_PAGE);
   assertVisualEditorContainsCommentWithValue(browser, commentValue);
   // Test untoggle comment with CTRL+SHIFT hot keys
   textEditor.setCursorPosition(16, 20);
   pressToggleCommentHotKeys();
   textEditor.save();
   new WaitWhile(new JobIsRunning());
   assertVisualEditorContainsManyComments(browser, 1, TEST_PAGE);
 }
  /** Tests Multiple Selection */
  @Test
  public void testMultipleSeletion() {

    jspEditor.activate();
    jspEditor.setText(MultiSelectionTest.PAGE_TEXT);
    jspEditor.save();
    jspEditor.selectText(MultiSelectionTest.OUTPUT_TEXT_1_TEXT);

    assertSelectedNodeHasText(webBrowser, MultiSelectionTest.OUTPUT_TEXT_1_TEXT);

    jspEditor.selectText(MultiSelectionTest.OUTPUT_TEXT_0_TEXT);

    assertSelectedNodeHasText(webBrowser, MultiSelectionTest.OUTPUT_TEXT_0_TEXT);

    jspEditor.selectText(
        "<h:outputText value=\"!@#_OUTPUT-TEXT_0_#@!\"/><h:outputText value=\"!@#_OUTPUT-TEXT_1_#@!\"/>");

    assertTrue(
        "Multiple selection doesn't contain proper nodes.",
        webBrowser.selectionContainsNodes(
            false, MultiSelectionTest.OUTPUT_TEXT_0_TEXT, MultiSelectionTest.OUTPUT_TEXT_1_TEXT));
  }
 @Override
 public void tearDown() throws Exception {
   jspEditor.close();
   super.tearDown();
 }