@Test
  public void testSearchBeanWithStereotypeAndNamedParam() {

    String namedParam = "someBean";

    NewStereotypeCreationWizard nb = new NewStereotypeCreationWizard();
    nb.open();
    nb.setName(stereotypeName);
    nb.setPackage(getPackageName());
    nb.setInherited(false);
    nb.setNamed(true);
    nb.setAlternative(false);
    nb.setGenerateComments(false);
    nb.setRegisterInBeans(false);
    nb.finish();

    wizard.createCDIComponentWithContent(
        CDIWizardType.BEAN, beanName, getPackageName(), null, BEAN_STEREOTYPE_NAMED_PATH);

    namedDialog = openSearchNamedDialog();
    namedDialog.setNamedPrefix(beanName);
    assertTrue(namedDialog.matchingItems().size() == 0);
    namedDialog.setNamedPrefix(namedParam);
    assertTrue(namedDialog.matchingItems().size() == 1);
    namedDialog.ok();
    assertTrue(new DefaultEditor().getTitle().equals(beanName + ".java"));
    assertTrue(new TextEditor().getSelectedText().equals(beanName));
  }
  @Test
  public void testSearchNamedParameterBean() {

    String namedParam = "someBean";

    NewBeanCreationWizard nb = new NewBeanCreationWizard();
    nb.open();
    nb.setName(beanName);
    nb.setPackage(getPackageName());
    nb.setPublic(true);
    nb.setAbstract(false);
    nb.setFinal(false);
    nb.setGenerateComments(false);
    nb.setAlternative(false);
    nb.setRegisterInBeans(false);
    nb.setNamed(true);
    nb.setBeanName(namedParam);
    nb.finish();

    namedDialog = openSearchNamedDialog();
    namedDialog.setNamedPrefix(namedParam);
    assertEquals(1, namedDialog.matchingItems().size());
    namedDialog.ok();
    assertTrue(new DefaultEditor().getTitle().equals(beanName + ".java"));
    assertTrue(new TextEditor().getSelectedText().equals(beanName));
  }
  @Test
  public void testSearchTwoSameNamedBean() {

    String beanName2 = "Bean2";
    String namedParam = "someBean";

    NewBeanCreationWizard nb = new NewBeanCreationWizard();
    nb.open();
    nb.setName(beanName);
    nb.setPackage(getPackageName());
    nb.setPublic(true);
    nb.setAbstract(false);
    nb.setFinal(false);
    nb.setGenerateComments(false);
    nb.setAlternative(false);
    nb.setRegisterInBeans(false);
    nb.setNamed(true);
    nb.setBeanName(namedParam);
    nb.finish();

    nb.open();
    nb.setName(beanName2);
    nb.setPackage(getPackageName());
    nb.setPublic(true);
    nb.setAbstract(false);
    nb.setFinal(false);
    nb.setGenerateComments(false);
    nb.setAlternative(false);
    nb.setRegisterInBeans(false);
    nb.setNamed(true);
    nb.setBeanName(namedParam);
    nb.finish();

    namedDialog = openSearchNamedDialog();
    namedDialog.setNamedPrefix(namedParam);
    List<String> matchingItems = namedDialog.matchingItems();
    assertTrue(matchingItems.size() == 2);
    for (String matchingItem : matchingItems) {
      if (matchingItem.contains(beanName)) {
        namedDialog.setMatchingItems(matchingItem);
        break;
      }
    }
    namedDialog.ok();
    assertTrue(new DefaultEditor().getTitle().equals(beanName + ".java"));
    assertTrue(new TextEditor().getSelectedText().equals(beanName));
  }
  @Test
  public void testSearchBeansWithSamePrefixNamedParam() {

    String[] beansNames = {"SomeBean", "SomeBean1", "SomeBean2", "SomeBean22", "SomeOtherBean"};

    Map<String, Integer> prefixesWithCount = new LinkedHashMap<String, Integer>();
    prefixesWithCount.put(beansNames[0], 4);
    prefixesWithCount.put(beansNames[1], 1);
    prefixesWithCount.put(beansNames[2], 2);
    prefixesWithCount.put(beansNames[3], 1);
    prefixesWithCount.put("Some", 5);

    for (String beanName : beansNames) {
      NewBeanCreationWizard nb = new NewBeanCreationWizard();
      nb.open();
      nb.setName(beanName);
      nb.setPackage(getPackageName());
      nb.setPublic(true);
      nb.setAbstract(false);
      nb.setFinal(false);
      nb.setGenerateComments(false);
      nb.setAlternative(false);
      nb.setRegisterInBeans(false);
      nb.setNamed(true);
      nb.finish();
    }

    for (String prefix : prefixesWithCount.keySet()) {
      namedDialog = openSearchNamedDialog();
      namedDialog.setNamedPrefix(prefix);
      assertTrue(
          "Prefix "
              + prefix
              + " has "
              + namedDialog.matchingItems().size()
              + " matching items but expected is "
              + prefixesWithCount.get(prefix),
          namedDialog.matchingItems().size() == prefixesWithCount.get(prefix));
      namedDialog.cancel();
    }
  }