package de.retest.recheck;

import de.retest.recheck.persistence.FileNamer;

/**
 * Determines the paths under which Golden Master and test report files should be persisted. The default implementation
 * derives test suite and test case name from the test class and test method, working for both JUnit and TestNG.
 */
public interface FileNamerStrategy {

	/**
	 * Creates a file namer for the given base names. For Golden Master files, these typically follow the format
	 * <code>${TEST_CLASS_NAME}/${TEST_METHOD_NAME}.${STEP_NAME}</code>, whereas test report files only use
	 * <code>${TEST_CLASS_NAME}</code>.
	 *
	 * @param baseNames
	 *            the base names to be used
	 * @return a file namer using the given base names
	 */
	FileNamer createFileNamer( String... baseNames );

	/**
	 * Determines the current test class name.
	 *
	 * @return name of the current test class
	 */
	default String getTestClassName() {
		return TestCaseFinder.getInstance().findTestCaseClassNameInStack()
				.orElseThrow( () -> new IllegalStateException( "Couldn't identify test class in call stack. \n"
						+ "This is needed to dynamically name the Golden Master files. \n "
						+ "Please instantiate RecheckImpl with RecheckOptions, and provide a different FileNamerStrategy." ) );
	}

	/**
	 * Determines the current test method name.
	 *
	 * @return name of the current test method
	 */
	default String getTestMethodName() {
		return TestCaseFinder.getInstance().findTestCaseMethodNameInStack()
				.orElseThrow( () -> new IllegalStateException( "Couldn't identify test method in call stack. \n"
						+ "This is needed to dynamically name the Golden Master files. \n"
						+ "Please call `startTest(\"name\")`, giving an explicit name, "
						+ "or instantiate RecheckImpl with RecheckOptions, and provide a different FileNamerStrategy." ) );
	}

}

@@ -948,32 +948,40 @@
 er.getInstance()
+ //%0A%09%09%09%09
 .findTestCaseCla
@@ -987,32 +987,35 @@
 assNameInStack()
+ //
 %0A%09%09%09%09.orElseThro
@@ -1086,33 +1086,32 @@
 s in call stack.
- 
 %5Cn%22%0A%09%09%09%09%09%09+ %22Thi
@@ -1166,17 +1166,16 @@
 r files.
- 
 %5Cn %22%0A%09%09%09
@@ -1463,16 +1463,24 @@
 stance()
+ //%0A%09%09%09%09
 .findTes
@@ -1503,16 +1503,19 @@
 nStack()
+ //
 %0A%09%09%09%09.or
@@ -1603,17 +1603,16 @@
 l stack.
- 
 %5Cn%22%0A%09%09%09%09
@@ -1675,17 +1675,16 @@
 r files.
- 
 %5Cn%22%0A%09%09%09%09

Improve formatting