// Path: src/main/java/org/terasology/launcher/util/JavaHeapSize.java
// public enum JavaHeapSize {
// 
//     NOT_USED("", "heapsize_notUsed"),
//     MB_256("256m", "heapsize_mb_256"),
//     MB_512("512m", "heapsize_mb_512"),
//     MB_768("768m", "heapsize_mb_768"),
//     GB_1("1g", "heapsize_gb_1"),
//     GB_1_5("1536m", "heapsize_gb_1_5"),
//     GB_2("2g", "heapsize_gb_2"),
//     GB_2_5("2560m", "heapsize_gb_2_5"),
//     GB_3("3g", "heapsize_gb_3"),
//     GB_4("4g", "heapsize_gb_4"),
//     GB_5("5g", "heapsize_gb_5"),
//     GB_6("6g", "heapsize_gb_6"),
//     GB_7("7g", "heapsize_gb_7"),
//     GB_8("8g", "heapsize_gb_8"),
//     GB_9("9g", "heapsize_gb_9"),
//     GB_10("10g", "heapsize_gb_10"),
//     GB_11("11g", "heapsize_gb_11"),
//     GB_12("12g", "heapsize_gb_12"),
//     GB_13("13g", "heapsize_gb_13"),
//     GB_14("14g", "heapsize_gb_14"),
//     GB_15("15g", "heapsize_gb_15"),
//     GB_16("16g", "heapsize_gb_16");
// 
//     private final String sizeParameter;
//     private final String labelKey;
// 
//     JavaHeapSize(String sizeParameter, String labelKey) {
//         this.sizeParameter = sizeParameter;
//         this.labelKey = labelKey;
//     }
// 
//     public final boolean isUsed() {
//         return this != NOT_USED;
//     }
// 
//     public final String getSizeParameter() {
//         return sizeParameter;
//     }
// 
//     @Override
//     public final String toString() {
//         return BundleUtils.getLabel(labelKey);
//     }
// }
// 
// Path: src/test/java/org/terasology/launcher/Matchers.java
// public static <T> Matcher<Iterable<? super T>> hasItemsFrom(Collection<T> items) {
//     /* org.hamcrest.Matchers.hasItems(T...) takes variable arguments, so if
//      * we want to match against a list, we reimplement it.
//      */
//     return new AllOf<>(items.stream().map(
//             IsIterableContaining::hasItem
//     ).collect(Collectors.toUnmodifiableList()));
// }


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.event.Level;
import org.terasology.launcher.util.JavaHeapSize;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.terasology.launcher.Matchers.hasItemsFrom;
        GameStarter starter = newStarter();
        assertNotNull(starter);
    }

    @Test
    public void testJre() throws IOException {
        GameStarter task = newStarter();
        // This is the sort of test where the code under test and the expectation are just copies
        // of the same source. But since there's a plan to separate the launcher runtime from the
        // game runtime, the runtime location seemed like a good thing to specify in its own test.
        assertTrue(task.getRuntimePath().startsWith(Path.of(System.getProperty("java.home"))));
    }

    static Stream<Arguments> provideJarPaths() {
        return Stream.of(
                Arguments.of(Path.of("libs", "Terasology.jar")),
                Arguments.of(Path.of("Terasology-5.2.0-SNAPSHOT", "lib", "Terasology.jar"))
        );
    }

    @ParameterizedTest
    @MethodSource("provideJarPaths")
    public void testBuildProcess(Path jarRelativePath) throws IOException {
        GameStarter starter = newStarter(jarRelativePath);
        ProcessBuilder processBuilder = starter.processBuilder;
        final Path gameJar = gamePath.resolve(jarRelativePath);

        assertNotNull(processBuilder.directory());
        assertEquals(gamePath, processBuilder.directory().toPath());
        assertThat(processBuilder.command(), hasItem(gameJar.toString()));
// Path: src/main/java/org/terasology/launcher/util/JavaHeapSize.java
// public enum JavaHeapSize {
// 
//     NOT_USED("", "heapsize_notUsed"),
//     MB_256("256m", "heapsize_mb_256"),
//     MB_512("512m", "heapsize_mb_512"),
//     MB_768("768m", "heapsize_mb_768"),
//     GB_1("1g", "heapsize_gb_1"),
//     GB_1_5("1536m", "heapsize_gb_1_5"),
//     GB_2("2g", "heapsize_gb_2"),
//     GB_2_5("2560m", "heapsize_gb_2_5"),
//     GB_3("3g", "heapsize_gb_3"),
//     GB_4("4g", "heapsize_gb_4"),
//     GB_5("5g", "heapsize_gb_5"),
//     GB_6("6g", "heapsize_gb_6"),
//     GB_7("7g", "heapsize_gb_7"),
//     GB_8("8g", "heapsize_gb_8"),
//     GB_9("9g", "heapsize_gb_9"),
//     GB_10("10g", "heapsize_gb_10"),
//     GB_11("11g", "heapsize_gb_11"),
//     GB_12("12g", "heapsize_gb_12"),
//     GB_13("13g", "heapsize_gb_13"),
//     GB_14("14g", "heapsize_gb_14"),
//     GB_15("15g", "heapsize_gb_15"),
//     GB_16("16g", "heapsize_gb_16");
// 
//     private final String sizeParameter;
//     private final String labelKey;
// 
//     JavaHeapSize(String sizeParameter, String labelKey) {
//         this.sizeParameter = sizeParameter;
//         this.labelKey = labelKey;
//     }
// 
//     public final boolean isUsed() {
//         return this != NOT_USED;
//     }
// 
//     public final String getSizeParameter() {
//         return sizeParameter;
//     }
// 
//     @Override
//     public final String toString() {
//         return BundleUtils.getLabel(labelKey);
//     }
// }
// 
// Path: src/test/java/org/terasology/launcher/Matchers.java
// public static <T> Matcher<Iterable<? super T>> hasItemsFrom(Collection<T> items) {
//     /* org.hamcrest.Matchers.hasItems(T...) takes variable arguments, so if
//      * we want to match against a list, we reimplement it.
//      */
//     return new AllOf<>(items.stream().map(
//             IsIterableContaining::hasItem
//     ).collect(Collectors.toUnmodifiableList()));
// }


// Path: src/test/java/org/terasology/launcher/game/TestGameStarter.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.event.Level;
import org.terasology.launcher.util.JavaHeapSize;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.terasology.launcher.Matchers.hasItemsFrom;

        GameStarter starter = newStarter();
        assertNotNull(starter);
    }

    @Test
    public void testJre() throws IOException {
        GameStarter task = newStarter();
        // This is the sort of test where the code under test and the expectation are just copies
        // of the same source. But since there's a plan to separate the launcher runtime from the
        // game runtime, the runtime location seemed like a good thing to specify in its own test.
        assertTrue(task.getRuntimePath().startsWith(Path.of(System.getProperty("java.home"))));
    }

    static Stream<Arguments> provideJarPaths() {
        return Stream.of(
                Arguments.of(Path.of("libs", "Terasology.jar")),
                Arguments.of(Path.of("Terasology-5.2.0-SNAPSHOT", "lib", "Terasology.jar"))
        );
    }

    @ParameterizedTest
    @MethodSource("provideJarPaths")
    public void testBuildProcess(Path jarRelativePath) throws IOException {
        GameStarter starter = newStarter(jarRelativePath);
        ProcessBuilder processBuilder = starter.processBuilder;
        final Path gameJar = gamePath.resolve(jarRelativePath);

        assertNotNull(processBuilder.directory());
        assertEquals(gamePath, processBuilder.directory().toPath());
        assertThat(processBuilder.command(), hasItem(gameJar.toString()));
        assertThat(processBuilder.command(), hasItemsFrom(gameParams));