public String relativePathToRoot(DefaultInputModule module) {
    Path rootBaseDir = root.getBaseDir();
    Path moduleBaseDir = module.getBaseDir();

    return PathResolver.relativize(rootBaseDir, moduleBaseDir).orElse(null);
  }
@Test
  public void testRelativePathToRoot() throws IOException {
    File rootBaseDir = temp.newFolder();
    File mod1BaseDir = new File(rootBaseDir, "mod1");
    File mod2BaseDir = new File(rootBaseDir, "mod2");
    FileUtils.forceMkdir(mod1BaseDir);
    FileUtils.forceMkdir(mod2BaseDir);
    DefaultInputModule root = new DefaultInputModule(ProjectDefinition.create().setKey("root")
      .setBaseDir(rootBaseDir).setWorkDir(rootBaseDir));
    DefaultInputModule mod1 = new DefaultInputModule(ProjectDefinition.create().setKey("mod1")
      .setBaseDir(mod1BaseDir).setWorkDir(temp.newFolder()));
    DefaultInputModule mod2 = new DefaultInputModule(ProjectDefinition.create().setKey("mod2")
      .setBaseDir(mod2BaseDir).setWorkDir(temp.newFolder()));
    DefaultInputModule mod3 = new DefaultInputModule(ProjectDefinition.create().setKey("mod2")
      .setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder()));

    Map<DefaultInputModule, DefaultInputModule> parents = new HashMap<>();

    parents.put(mod1, root);
    parents.put(mod2, mod1);
    parents.put(mod3, mod1);

    moduleHierarchy = new DefaultInputModuleHierarchy(root, parents);

    assertThat(moduleHierarchy.relativePathToRoot(root)).isEmpty();
    assertThat(moduleHierarchy.relativePathToRoot(mod1)).isEqualTo("mod1");
    assertThat(moduleHierarchy.relativePathToRoot(mod2)).isEqualTo("mod2");
    assertThat(moduleHierarchy.relativePathToRoot(mod3)).isNull();
  }