package test.integration;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertLinesMatch;

import com.github.sormuras.bach.module.ModuleInfoFinder;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class ModuleInfoFinderTests {
  @Test
  void parseProjectBach() {
    var bachMainRequires =
        """
        java.net.http
        jdk.compiler
        jdk.jartool
        jdk.javadoc
        jdk.jdeps
        jdk.jlink
        """;

    var mains = ModuleInfoFinder.of(Path.of("."), List.of("./*/main/java"));
    Assertions.assertEquals(Set.of("com.github.sormuras.bach"), mains.declared());
    assertLinesMatch(bachMainRequires.lines(), mains.required().stream());

    var bachTestRequires =
        """
        com.github.sormuras.bach
        """
            + bachMainRequires
            + """
        org.junit.jupiter
        test.base
        """;

    var tests = ModuleInfoFinder.of(Path.of("."), List.of("./*/test/java", "./*/test/java-module"));

    assertEquals(Set.of("com.github.sormuras.bach", "test.base", "test.modules"), tests.declared());
    assertLinesMatch(bachTestRequires.lines(), tests.required().stream());

    var preview = ModuleInfoFinder.of(Path.of(""), List.of("./*/test-preview/java"));
    assertEquals(Set.of(), preview.declared());
  }
}

@@ -280,49 +280,8 @@
 et;%0A
-import org.junit.jupiter.api.Assertions;%0A
 impo
@@ -631,27 +631,16 @@
 ));%0A    
-Assertions.
 assertEq
@@ -765,32 +765,197 @@
 red().stream());
+%0A    var bach = mains.find(%22com.github.sormuras.bach%22).orElseThrow().descriptor();%0A    assertEquals(%22com.github.sormuras.bach.Main%22, bach.mainClass().orElseThrow());
 %0A%0A    var bachTe

Check that main class is present