/*
 * Bach - Java Shell Builder
 * Copyright (C) 2020 Christian Stein
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.sormuras.bach.api;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;

class ProjectTests {

  final Project project =
      Project.builder()
          .name("name")
          .version("99")
          .paths("")
          .units(List.of())
          .realms(List.of())
          .tuner(new Tuner())
          .build();

  @Test
  void name() {
    assertEquals("name", project.name());
  }

  @Test
  void version() {
    assertEquals("99", project.version().toString());
  }

  @Test
  void toNameAndVersion() {
    assertEquals("name 99", project.toNameAndVersion());
  }

  @Test
  void paths() {
    var realm = new Realm("realm", 0, Map.of(), List.of());
    var paths = project.paths();
    assertEquals(Path.of(""), paths.base());
    assertEquals(Path.of(".bach"), paths.out());
    assertEquals(Path.of("lib"), paths.lib());
    assertEquals(Path.of(".bach/first/more"), paths.out("first", "more"));
    assertEquals(Path.of(".bach/classes/realm"), paths.classes(realm));
    assertEquals(Path.of(".bach/modules/realm"), paths.modules(realm));
    assertEquals(Path.of(".bach/sources/realm"), paths.sources(realm));
    assertEquals(Path.of(".bach/documentation/javadoc"), paths.javadoc());
  }

  @Test
  void units() {
    assertTrue(project.structure().units().isEmpty());
  }

  @Test
  void realms() {
    assertTrue(project.structure().realms().isEmpty());
  }

  @Test
  void tuner() {
    var tuner = project.tuner();
    assertNotNull(tuner);
    assertSame(Tuner.class, tuner.getClass());
  }
}

@@ -900,16 +900,58 @@
 tTrue;%0A%0A
+import java.lang.module.ModuleDescriptor;%0A
 import j
@@ -1547,32 +1547,858 @@
 ersion());%0A  %7D%0A%0A
+  @Test%0A  void toJarName() %7B%0A    var unit =%0A        new Unit(%0A            Path.of(%22module-info.java%22),%0A            ModuleDescriptor.newModule(%22unit%22).build(),%0A            Path.of(%22.%22),%0A            List.of(Source.of(Path.of(%22%22))),%0A            List.of());%0A    assertEquals(%22unit-99.jar%22, project.toJarName(unit, %22%22));%0A    assertEquals(%22unit-99-classifier.jar%22, project.toJarName(unit, %22classifier%22));%0A  %7D%0A%0A  @Test%0A  void toModularJar() %7B%0A    var realm = new Realm(%22realm%22, 0, Map.of(), List.of());%0A    var unit =%0A        new Unit(%0A            Path.of(%22module-info.java%22),%0A            ModuleDescriptor.newModule(%22unit%22).build(),%0A            Path.of(%22.%22),%0A            List.of(Source.of(Path.of(%22%22))),%0A            List.of());%0A    assertEquals(Path.of(%22.bach/modules/realm%22, %22unit-99.jar%22), project.toModularJar(realm, unit));%0A  %7D%0A%0A
   @Test%0A  void p

Test JAR-related helpers