/*
 * 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;

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 org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceLock;
import org.junit.jupiter.api.parallel.Resources;
import test.base.SwallowSystem;

class BachTests {

  @Test
  @ResourceLock(Resources.SYSTEM_PROPERTIES)
  void defaults() {
    var bach = new Bach();
    assertEquals("Bach.java " + Bach.VERSION, bach.toString());
    assertNotNull(bach.getHttpClient());
  }

  @Test
  @SwallowSystem
  @ResourceLock(Resources.SYSTEM_PROPERTIES)
  void callMainMethodWithoutArguments(SwallowSystem.Streams streams) {
    Bach.main();
    assertTrue(streams.errors().isEmpty());
    assertTrue(streams.lines().contains("Bach.java " + Bach.VERSION));
  }
}

@@ -715,16 +715,81 @@
 Equals;%0A
+import static org.junit.jupiter.api.Assertions.assertLinesMatch;%0A
 import s
@@ -902,16 +902,109 @@
 tTrue;%0A%0A
+import de.sormuras.bach.util.Logbook;%0Aimport java.util.List;%0Aimport java.util.regex.Pattern;%0A
 import o
@@ -1195,53 +1195,8 @@
 est%0A
-  @ResourceLock(Resources.SYSTEM_PROPERTIES)%0A
   vo
@@ -1246,385 +1246,1364 @@
     
-assertEquals(%22Bach.java %22 + Bach.VERSION, bach.toString());%0A    assertNotNull(bach.getHttpClient());%0A  %7D%0A%0A  @Test%0A  @SwallowSystem%0A  @ResourceLock(Resources.SYSTEM_PROPERTIES)%0A  void callMainMethodWithoutArguments(SwallowSystem.Streams streams) %7B%0A    Bach.main();%0A    assertTrue(streams.errors().isEmpty());%0A    assertTrue(streams.lines().contains(%22Bach.java %22 + Bach.VERSION))
+var expectedStringRepresentation = %22Bach.java %22 + Bach.VERSION;%0A    assertEquals(expectedStringRepresentation, bach.toString());%0A    assertNotNull(bach.getLogger());%0A    assertNotNull(bach.getHttpClient());%0A%0A    var logbook = ((Logbook) bach.getLogger());%0A    var initialMessage = %22Initialized %22 + expectedStringRepresentation;%0A    assertLinesMatch(List.of(initialMessage), logbook.messages());%0A    assertLinesMatch(List.of(%22TRACE%7C%22 + initialMessage), logbook.lines(this::toLine));%0A  %7D%0A%0A  @Test%0A  @SwallowSystem%0A  @ResourceLock(Resources.SYSTEM_PROPERTIES)%0A  void callMainMethodWithoutArguments(SwallowSystem.Streams streams) %7B%0A    Bach.main();%0A    assertTrue(streams.errors().isEmpty());%0A    assertTrue(streams.lines().contains(%22Bach.java %22 + Bach.VERSION));%0A  %7D%0A%0A  @Test%0A  void executeTool() %7B%0A    var bach = new Bach();%0A    var task = Task.runTool(%22javac%22, %22--version%22);%0A    bach.execute(task);%0A    var logbook = ((Logbook) bach.getLogger());%0A    assertLinesMatch(%0A        List.of(%0A            %22%3E%3E INIT %3E%3E%22,%0A            %22TRACE%7C* javac --version%22,%0A            %22DEBUG%7Cjavac --version%22,%0A            Pattern.quote(%22DEBUG%7Cjavac %22) + %22.+%22),%0A        logbook.lines(this::toLine));%0A  %7D%0A%0A  String toLine(Logbook.Entry entry) %7B%0A    var thrown = entry.thrown() == null ? %22%22 : %22 -%3E %22 + entry.thrown();%0A    return entry.level().name() + '%7C' + entry.message() + thrown
 ;%0A  

Update test