package de.retest.recheck;

import java.io.File;

import de.retest.recheck.persistence.FileNamer;

public class GradleConformFileNamerStrategy implements FileNamerStrategy {

    public static final String DEFAULT_RETEST_WORKSPACE_PATH = "src/test/resources/retest/";
    public static final String DEFAULT_RETEST_TESTREPORTS_PATH = "build/test-results/test";

    @Override
    public FileNamer createFileNamer( final String... baseNames ) {
        return new FileNamer() {

            @Override
            public File getFile( final String extension ) {
                final String baseName = String.join( "/", baseNames );
                return new File( DEFAULT_RETEST_WORKSPACE_PATH + File.separator
                        + baseName + extension );
            }

            @Override
            public File getResultFile( final String extension ) {
                final String baseName = String.join( "/", baseNames );
                return new File( DEFAULT_RETEST_TESTREPORTS_PATH + File.separator
                        + baseName + extension );
            }
        };
    }

    @Override
    public String getTestClassName() {
        final StackTraceElement testMethodStack = TestCaseFinder.findTestCaseMethodInStack();
        if ( testMethodStack != null ) {
            return testMethodStack.getClassName();
        }
        throw new RuntimeException( "Couldn't identify test method in call stack. Use explicit namer!" );
    }

    @Override
    public String getTestMethodName() {
        final StackTraceElement testMethodStack = TestCaseFinder.findTestCaseMethodInStack();
        if ( testMethodStack != null ) {
            return testMethodStack.getMethodName();
        }
        throw new RuntimeException( "Couldn't identify test method in call stack. Use explicit namer!" );
    }
}

@@ -168,20 +168,17 @@
 tegy %7B%0A%0A
-    
+%09
 public s
@@ -258,20 +258,17 @@
 test/%22;%0A
-    
+%09
 public s
@@ -348,20 +348,17 @@
 test%22;%0A%0A
-    
+%09
 @Overrid
@@ -355,28 +355,25 @@
 %0A%09@Override%0A
-    
+%09
 public FileN
@@ -424,24 +424,18 @@
 mes ) %7B%0A
-        
+%09%09
 return n
@@ -456,42 +456,24 @@
  %7B%0A%0A
-            @Override%0A            
+%09%09%09@Override%0A%09%09%09
 publ
@@ -516,32 +516,20 @@
 ion ) %7B%0A
-                
+%09%09%09%09
 final St
@@ -575,32 +575,20 @@
 ames );%0A
-                
+%09%09%09%09
 return n
@@ -646,32 +646,8 @@
 ator
-%0A                       
  + b
@@ -673,57 +673,30 @@
  );%0A
-            %7D%0A%0A            @Override%0A            
+%09%09%09%7D%0A%0A%09%09%09@Override%0A%09%09%09
 publ
@@ -745,32 +745,20 @@
 ion ) %7B%0A
-                
+%09%09%09%09
 final St
@@ -804,32 +804,20 @@
 ames );%0A
-                
+%09%09%09%09
 return n
@@ -877,32 +877,8 @@
 ator
-%0A                       
  + b
@@ -904,44 +904,23 @@
  );%0A
-            %7D%0A        %7D;%0A    %7D%0A%0A    
+%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A%0A%09
 @Ove
@@ -917,36 +917,33 @@
 %0A%09%7D%0A%0A%09@Override%0A
-    
+%09
 public String ge
@@ -957,32 +957,26 @@
 assName() %7B%0A
-        
+%09%09
 final StackT
@@ -1045,32 +1045,26 @@
 dInStack();%0A
-        
+%09%09
 if ( testMet
@@ -1080,36 +1080,27 @@
 != null ) %7B%0A
-            
+%09%09%09
 return testM
@@ -1126,34 +1126,22 @@
 Name();%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 throw ne
@@ -1234,19 +1234,13 @@
  );%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 @Ove
@@ -1245,20 +1245,17 @@
 verride%0A
-    
+%09
 public S
@@ -1282,24 +1282,18 @@
 ame() %7B%0A
-        
+%09%09
 final St
@@ -1370,24 +1370,18 @@
 tack();%0A
-        
+%09%09
 if ( tes
@@ -1409,20 +1409,11 @@
 ) %7B%0A
-            
+%09%09%09
 retu
@@ -1452,26 +1452,14 @@
 ();%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 thro
@@ -1556,12 +1556,9 @@
  );%0A
-    
+%09
 %7D%0A%7D%0A

Apply formatter