package de.retest.recheck.configuration;

import static org.assertj.core.api.Assertions.assertThat;

import java.nio.file.Path;
import java.nio.file.Paths;

import org.junit.jupiter.api.Test;

class ProjectRootFinderTest {

	@Test
	void project_root_should_be_found() throws Exception {
		final Path expected = Paths.get( "" ).toAbsolutePath();
		final Path actual = ProjectRootFinderUtil.getProjectRoot().get();

		assertThat( expected ).isEqualTo( actual );
	}

	@Test
	void project_root_should_be_found_from_subpath() throws Exception {
		final Path expected = Paths.get( "" ).toAbsolutePath();
		final Path pathInTarget = Paths.get( "target/test-classes" ).toAbsolutePath();

		final Path actual = ProjectRootFinderUtil.getProjectRoot( pathInTarget ).get();

		assertThat( expected ).isEqualTo( actual );
	}

	@Test
	void project_root_should_be_empty_on_root_base() throws Exception {
		assertThat( ProjectRootFinderUtil.getProjectRoot( Paths.get( "/" ) ) ).isNotPresent();
	}

	@Test
	void project_root_should_be_empty_on_non_existing_base() throws Exception {
		assertThat( ProjectRootFinderUtil.getProjectRoot( Paths.get( "/bla/blub/42" ) ) ).isNotPresent();
	}

	@Test
	void project_root_should_be_empty_on_null_base() throws Exception {
		assertThat( ProjectRootFinderUtil.getProjectRoot( null ) ).isNotPresent();
	}

}

@@ -258,16 +258,35 @@
 be_found
+_from_absolute_path
 () throw
@@ -416,16 +416,50 @@
 ectRoot(
+ Paths.get( %22%22 ).toAbsolutePath() 
 ).get();
@@ -557,16 +557,25 @@
 nd_from_
+absolute_
 subpath(
@@ -860,32 +860,632 @@
 ( actual );%0A%09%7D%0A%0A
+%09@Test%0A%09void project_root_should_be_found_from_relative_path() throws Exception %7B%0A%09%09final Path expected = Paths.get( %22%22 ).toAbsolutePath();%0A%09%09final Path actual = ProjectRootFinderUtil.getProjectRoot().get();%0A%0A%09%09assertThat( expected ).isEqualTo( actual );%0A%09%7D%0A%0A%09@Test%0A%09void project_root_should_be_found_from_relative_subpath() throws Exception %7B%0A%09%09final Path expected = Paths.get( %22%22 ).toAbsolutePath();%0A%09%09final Path pathInTarget = Paths.get( %22target/test-classes%22 );%0A%0A%09%09final Path actual = ProjectRootFinderUtil.getProjectRoot( pathInTarget ).get();%0A%0A%09%09assertThat( expected ).isEqualTo( actual );%0A%09%7D%0A%0A
 %09@Test%0A%09void pro

Add test for relative path