/*
 * The MIT License
 *
 * Copyright 2021 Intuit Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.intuit.karate.report;

import com.intuit.karate.Results;
import com.intuit.karate.Suite;
import com.intuit.karate.core.FeatureResult;
import com.intuit.karate.core.TagResults;
import com.intuit.karate.core.TimelineResults;

/**
 *
 * @author pthomas3
 */
public interface SuiteReports {

    Report featureReport(Suite suite, FeatureResult featureResult);

    Report tagsReport(Suite suite, TagResults tagResults);

    Report timelineReport(Suite suite, TimelineResults timelineResults);

    Report summaryReport(Suite suite, Results results);

    public static final SuiteReports DEFAULT = new SuiteReports() {

        @Override
        public Report featureReport(Suite suite, FeatureResult fr) {
            return Report.template("karate-feature.html")
                    .reportDir(suite.reportDir)
                    .reportFileName(fr.getFeature().getPackageQualifiedName() + ".html")
                    .variable("results", fr.toKarateJson())
                    .build();
        }

        @Override
        public Report tagsReport(Suite suite, TagResults tr) {
            return Report.template("karate-tags.html")
                    .reportDir(suite.reportDir)
                    .variable("results", tr.toKarateJson())
                    .build();
        }

        @Override
        public Report timelineReport(Suite suite, TimelineResults tr) {
            return Report.template("karate-timeline.html")
                    .reportDir(suite.reportDir)
                    .variable("results", tr.toKarateJson())
                    .build();
        }

        @Override
        public Report summaryReport(Suite suite, Results results) {
            return Report.template("karate-summary.html")
                    .reportDir(suite.reportDir)
                    .variable("results", results.toKarateJson())
                    .build();
        }

    };

}

@@ -1427,24 +1427,32 @@
 orts %7B%0A%0A    
+default 
 Report featu
@@ -1492,352 +1492,8 @@
 lt f
-eatureResult);%0A%0A    Report tagsReport(Suite suite, TagResults tagResults);%0A%0A    Report timelineReport(Suite suite, TimelineResults timelineResults);%0A%0A    Report summaryReport(Suite suite, Results results);%0A%0A    public static final SuiteReports DEFAULT = new SuiteReports() %7B%0A%0A        @Override%0A        public Report featureReport(Suite suite, F
 eatu
@@ -1504,19 +1504,12 @@
 sult
- fr
 ) %7B%0A
-    
     
@@ -1550,36 +1550,32 @@
 -feature.html%22)%0A
-    
                 
@@ -1614,28 +1614,24 @@
             
-    
 .reportFileN
@@ -1635,17 +1635,28 @@
 leName(f
-r
+eatureResult
 .getFeat
@@ -1706,36 +1706,32 @@
                 
-    
 .variable(%22resul
@@ -1736,17 +1736,28 @@
 ults%22, f
-r
+eatureResult
 .toKarat
@@ -1773,36 +1773,32 @@
                 
-    
 .build();%0A      
@@ -1799,47 +1799,22 @@
     
-  
-  
 %7D%0A%0A    
-    @Override%0A        public
+default
  Rep
@@ -1849,33 +1849,37 @@
 TagResults t
-r) %7B%0A    
+agResults) %7B%0A
         retu
@@ -1909,36 +1909,32 @@
 ate-tags.html%22)%0A
-    
                 
@@ -1969,36 +1969,32 @@
                 
-    
 .variable(%22resul
@@ -1991,33 +1991,41 @@
 ble(%22results%22, t
-r
+agResults
 .toKarateJson())
@@ -2033,36 +2033,32 @@
                 
-    
 .build();%0A      
@@ -2059,47 +2059,22 @@
     
-   
- 
 %7D%0A%0A    
-    @Override%0A        public
+default
  Rep
@@ -2126,17 +2126,26 @@
 ts t
-r) %7B%0A    
+imelineResults) %7B%0A
     
@@ -2203,36 +2203,32 @@
                 
-    
 .reportDir(suite
@@ -2247,36 +2247,32 @@
                 
- 
-   
 .variable(%22resul
@@ -2277,17 +2277,30 @@
 ults%22, t
-r
+imelineResults
 .toKarat
@@ -2316,36 +2316,32 @@
                 
-   
- 
 .build();%0A      
@@ -2326,36 +2326,32 @@
       .build();%0A
-    
     %7D%0A%0A        @
@@ -2349,36 +2349,15 @@
     
-    @Override%0A        public
+default
  Rep
@@ -2402,28 +2402,24 @@
  results) %7B%0A
-    
         retu
@@ -2468,36 +2468,32 @@
                 
-    
 .reportDir(suite
@@ -2512,36 +2512,32 @@
                 
- 
-   
 .variable(%22resul
@@ -2573,36 +2573,32 @@
                 
-    
 .build();%0A      
@@ -2595,22 +2595,106 @@
 ();%0A    
+%7D%0A%0A
     
-%7D%0A
+public static final SuiteReports DEFAULT = new SuiteReports() %7B%0A        // defaults
 %0A    %7D;%0A

make it easier for users to inject custom reports