@@ -0,0 +1,2639 @@
+/*%0A * Bach - Java Shell Builder%0A * Copyright (C) 2020 Christian Stein%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     https://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage de.sormuras.bach.internal;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertLinesMatch;%0A%0Aimport de.sormuras.bach.api.Locator;%0Aimport java.net.http.HttpClient;%0Aimport java.nio.file.Path;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Set;%0Aimport java.util.function.BiConsumer;%0Aimport org.junit.jupiter.api.Test;%0Aimport org.junit.jupiter.api.io.TempDir;%0Aimport test.base.Tree;%0A%0Aclass ModuleResolverTests %7B%0A%0A  static class Downloader implements BiConsumer%3CSet%3CString%3E, Path%3E %7B%0A%0A    final Locator locator = Locator.dynamicCentral(Map.of());%0A    final Resources resources = new Resources(null, HttpClient.newHttpClient());%0A%0A    @Override%0A    public void accept(Set%3CString%3E modules, Path lib) %7B%0A      System.out.println(modules);%0A      for (var module : modules) %7B%0A        var uri = locator.locate(module);%0A        if (uri.isEmpty()) continue;%0A        var version = locator.version(module).map(v -%3E %22-%22 + v).orElse(%22%22);%0A        try %7B%0A          resources.copy(uri.get(), lib.resolve(module + version + %22.jar%22));%0A        %7D catch (Exception e) %7B%0A          System.err.println(e.getMessage());%0A        %7D%0A      %7D%0A    %7D%0A  %7D%0A%0A  @Test%0A  void resolveJUnitJupiter(@TempDir Path temp) throws Exception %7B%0A    var downloader = new Downloader();%0A    var resolver = new ModuleResolver(temp, Set.of(), downloader);%0A    resolver.resolve(Set.of(%22org.junit.jupiter%22));%0A%0A    var files = new ArrayList%3CString%3E();%0A    Tree.walk(temp, files::add);%0A    try %7B%0A      assertLinesMatch(%0A          List.of(%0A              %22org.apiguardian.api.jar%22,%0A              %22org.junit.jupiter.api.jar%22,%0A              %22org.junit.jupiter.engine.jar%22,%0A              %22org.junit.jupiter.jar%22,%0A              %22org.junit.jupiter.params.jar%22,%0A              %22org.junit.platform.commons.jar%22,%0A              %22org.junit.platform.engine.jar%22,%0A              %22org.opentest4j.jar%22),%0A          files);%0A    %7D catch (Throwable throwable) %7B%0A      files.forEach(System.err::println);%0A      throw throwable;%0A    %7D%0A  %7D%0A%7D%0A

Add module resolver test