Example #1
0
  private ContentEntry getContentRoot(String moduleName) {
    ContentEntry[] ee = getContentRoots(moduleName);
    List<String> roots = new ArrayList<String>();
    for (ContentEntry e : ee) {
      roots.add(e.getUrl());
    }

    String message = "Several content roots found: [" + StringUtil.join(roots, ", ") + "]";
    assertEquals(message, 1, ee.length);

    return ee[0];
  }
Example #2
0
  protected void assertContentRoots(String moduleName, String... expectedRoots) {
    List<String> actual = new ArrayList<String>();
    for (ContentEntry e : getContentRoots(moduleName)) {
      actual.add(e.getUrl());
    }

    for (int i = 0; i < expectedRoots.length; i++) {
      expectedRoots[i] = VfsUtil.pathToUrl(expectedRoots[i]);
    }

    assertUnorderedPathsAreEqual(actual, Arrays.asList(expectedRoots));
  }
Example #3
0
 protected void assertGeneratedSources(String moduleName, String... expectedSources) {
   ContentEntry contentRoot = getContentRoot(moduleName);
   List<ContentFolder> folders = new ArrayList<ContentFolder>();
   for (SourceFolder folder : contentRoot.getSourceFolders(JavaSourceRootType.SOURCE)) {
     JavaSourceRootProperties properties =
         folder.getJpsElement().getProperties(JavaSourceRootType.SOURCE);
     assertNotNull(properties);
     if (properties.isForGeneratedSources()) {
       folders.add(folder);
     }
   }
   doAssertContentFolders(contentRoot, folders, expectedSources);
 }
Example #4
0
  private static void doAssertContentFolders(
      ContentEntry e, final List<? extends ContentFolder> folders, String... expected) {
    List<String> actual = new ArrayList<String>();
    for (ContentFolder f : folders) {
      String rootUrl = e.getUrl();
      String folderUrl = f.getUrl();

      if (folderUrl.startsWith(rootUrl)) {
        int length = rootUrl.length() + 1;
        folderUrl = folderUrl.substring(Math.min(length, folderUrl.length()));
      }

      actual.add(folderUrl);
    }

    assertOrderedElementsAreEqual(actual, Arrays.asList(expected));
  }
Example #5
0
 private ContentEntry getContentRoot(String moduleName, String path) {
   for (ContentEntry e : getContentRoots(moduleName)) {
     if (e.getUrl().equals(VfsUtil.pathToUrl(path))) return e;
   }
   throw new AssertionError("content root not found");
 }
Example #6
0
 private void doAssertContentFolders(
     String moduleName, @NotNull JpsModuleSourceRootType<?> rootType, String... expected) {
   ContentEntry contentRoot = getContentRoot(moduleName);
   doAssertContentFolders(contentRoot, contentRoot.getSourceFolders(rootType), expected);
 }
Example #7
0
 protected void assertContentRootExcludes(
     String moduleName, String contentRoot, String... expectedExcudes) {
   ContentEntry root = getContentRoot(moduleName, contentRoot);
   doAssertContentFolders(root, Arrays.asList(root.getExcludeFolders()), expectedExcudes);
 }