@Test
  @SuppressWarnings("unchecked")
  public void testWriteModule() throws Exception {
    TargetNode<?> guavaTargetNode =
        JavaLibraryBuilder.createBuilder(
                BuildTargetFactory.newInstance("//third_party/guava:guava"))
            .addSrc(Paths.get("third_party/guava/src/Collections.java"))
            .build();

    TargetNode<?> baseTargetNode =
        JavaLibraryBuilder.createBuilder(
                BuildTargetFactory.newInstance("//java/com/example/base:base"))
            .addDep(guavaTargetNode.getBuildTarget())
            .addSrc(Paths.get("java/com/example/base/Base.java"))
            .build();

    IjModuleGraph moduleGraph =
        IjModuleGraphTest.createModuleGraph(ImmutableSet.of(guavaTargetNode, baseTargetNode));
    IjModule baseModule = IjModuleGraphTest.getModuleForTarget(moduleGraph, baseTargetNode);

    IjProjectTemplateDataPreparer dataPreparer =
        new IjProjectTemplateDataPreparer(javaPackageFinder, moduleGraph, filesystem);

    ContentRoot contentRoot = dataPreparer.getContentRoot(baseModule);
    assertEquals("file://$MODULE_DIR$/../../java/com/example/base", contentRoot.getUrl());

    IjSourceFolder baseSourceFolder = contentRoot.getFolders().first();
    assertEquals("sourceFolder", baseSourceFolder.getType());
    assertFalse(baseSourceFolder.getIsTestSource());
    assertEquals("com.example.base", baseSourceFolder.getPackagePrefix());
    assertEquals("file://$MODULE_DIR$/../../java/com/example/base", baseSourceFolder.getUrl());

    assertThat(
        dataPreparer.getDependencies(baseModule),
        contains(
            allOf(
                hasProperty("type", equalTo(IjDependencyListBuilder.Type.MODULE)),
                hasProperty(
                    "data",
                    equalTo(
                        Optional.of(
                            DependencyEntryData.builder()
                                .setName("third_party_guava")
                                .setScope(IjDependencyListBuilder.Scope.COMPILE)
                                .setExported(false)
                                .build())))),
            allOf(hasProperty("type", equalTo(IjDependencyListBuilder.Type.SOURCE_FOLDER)))));
  }
 private IjSourceFolder createSourceFolder(IjFolder folder, Path moduleLocationBasePath) {
   return IjSourceFolder.builder()
       .setType(folder.getIjName())
       .setUrl(toModuleDirRelativeString(folder.getPath(), moduleLocationBasePath))
       .setIsTestSource(folder instanceof TestFolder)
       .setPackagePrefix(getPackagPrefix(folder))
       .build();
 }
    @Override
    public int compareTo(IjSourceFolder o) {
      if (this == o) {
        return 0;
      }

      return getUrl().compareTo(o.getUrl());
    }