@Test
  public void repeatsAreRemoved() {
    List<PsiElement> defines = new ArrayList<PsiElement>();
    defines.add(createPsiElement("'dojo/c'"));
    defines.add(createPsiElement("'dojo/z'"));
    defines.add(createPsiElement("'dojo/c'"));
    List<PsiElement> parameters = new ArrayList<PsiElement>();
    parameters.add(createPsiElement("c"));
    parameters.add(createPsiElement("a"));
    parameters.add(createPsiElement("c"));

    SortingResult results = organizer.sortDefinesAndParameters(defines, parameters);

    SortedPsiElementAdapter[] resultingDefines = results.getDefines();
    assertTrue(
        resultingDefines[0].isInactive()
            || resultingDefines[1].isInactive()
            || resultingDefines[2].isInactive());

    SortedPsiElementAdapter[] resultingParameters = results.getParameters();
    assertTrue(
        resultingParameters[0].isInactive()
            || resultingParameters[1].isInactive()
            || resultingParameters[2].isInactive());
  }
  @Test
  public void testDoubleQuotes() {
    List<PsiElement> defines = new ArrayList<PsiElement>();
    defines.add(createPsiElement("\"dojo/c\""));
    defines.add(createPsiElement("\"dojo/a!\""));
    List<PsiElement> parameters = new ArrayList<PsiElement>();
    parameters.add(createPsiElement("c"));

    SortingResult results = organizer.sortDefinesAndParameters(defines, parameters);

    assertEquals("\"dojo/c\"", results.getDefines()[0].getElement().getText());
  }
  @Test
  public void quotesAreCounted() {
    List<PsiElement> defines = new ArrayList<PsiElement>();
    defines.add(createPsiElement("'dojo/c'"));
    defines.add(createPsiElement("'dojo/z'"));
    defines.add(createPsiElement("\"dojo/a\""));
    List<PsiElement> parameters = new ArrayList<PsiElement>();
    parameters.add(createPsiElement("c"));
    parameters.add(createPsiElement("z"));
    parameters.add(createPsiElement("a"));

    SortingResult results = organizer.sortDefinesAndParameters(defines, parameters);

    assertEquals(2, results.getSingleQuotes());
    assertEquals(1, results.getDoubleQuotes());
  }
  @Test
  public void sortingOfSimpleCase() {
    List<PsiElement> defines = new ArrayList<PsiElement>();
    defines.add(createPsiElement("dojo/z"));
    defines.add(createPsiElement("dojo/a"));
    List<PsiElement> parameters = new ArrayList<PsiElement>();
    parameters.add(createPsiElement("z"));
    parameters.add(createPsiElement("a"));

    SortingResult results = organizer.sortDefinesAndParameters(defines, parameters);

    assertEquals(2, results.getDefines().length);
    assertEquals(2, results.getParameters().length);

    assertEquals("dojo/a", results.getDefines()[0].getElement().getText());
    assertEquals("a", results.getParameters()[0].getElement().getText());
  }
  @Test
  public void itemsLoadedButNotReferencedAreNotSorted() {
    List<PsiElement> defines = new ArrayList<PsiElement>();
    defines.add(createPsiElement("'dojo/c'"));
    defines.add(createPsiElement("'../a'"));
    defines.add(createPsiElement("'dojo/z'"));
    defines.add(createPsiElement("'dojo/b'"));
    List<PsiElement> parameters = new ArrayList<PsiElement>();
    parameters.add(createPsiElement("c"));
    parameters.add(createPsiElement("a"));
    parameters.add(createPsiElement("z"));

    SortingResult results = organizer.sortDefinesAndParameters(defines, parameters);

    assertEquals("'../a'", results.getDefines()[0].getElement().getText());
    assertEquals("a", results.getParameters()[0].getElement().getText());

    assertEquals("'dojo/b'", results.getDefines()[3].getElement().getText());
  }
  @Test
  /** when we load plugins, do not sort them! */
  public void pluginsAreAccountedFor() {
    List<PsiElement> defines = new ArrayList<PsiElement>();
    defines.add(createPsiElement("'dojo/c'"));
    defines.add(createPsiElement("'../a'"));
    defines.add(createPsiElement("'dojo/z'"));
    defines.add(createPsiElement("'dojo/a!'"));
    List<PsiElement> parameters = new ArrayList<PsiElement>();
    parameters.add(createPsiElement("c"));
    parameters.add(createPsiElement("a"));
    parameters.add(createPsiElement("z"));

    SortingResult results = organizer.sortDefinesAndParameters(defines, parameters);

    assertEquals("'../a'", results.getDefines()[0].getElement().getText());
    assertEquals("a", results.getParameters()[0].getElement().getText());

    assertEquals("'dojo/a!'", results.getDefines()[3].getElement().getText());
  }