diff --git a/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ZeroCodeCsvReportBuilder.java b/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ZeroCodeCsvReportBuilder.java
index 9346fa9c6..67f12d6a1 100644
--- a/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ZeroCodeCsvReportBuilder.java
+++ b/core/src/main/java/org/jsmart/zerocode/core/domain/builders/ZeroCodeCsvReportBuilder.java
@@ -10,9 +10,11 @@ public class ZeroCodeCsvReportBuilder {
private String correlationId;
private String result;
private String method;
+ private String url;
String requestTimeStamp;
String responseTimeStamp;
private Double responseDelayMilliSec;
+ private String host;
public static ZeroCodeCsvReportBuilder newInstance() {
return new ZeroCodeCsvReportBuilder();
@@ -20,7 +22,7 @@ public static ZeroCodeCsvReportBuilder newInstance() {
public ZeroCodeCsvReport build() {
ZeroCodeCsvReport built = new ZeroCodeCsvReport(scenarioName,scenarioLoop,stepName, stepLoop,
- correlationId, result, method, requestTimeStamp, responseTimeStamp, responseDelayMilliSec);
+ correlationId, result, method, host, url, requestTimeStamp, responseTimeStamp, responseDelayMilliSec);
return built;
}
@@ -39,6 +41,16 @@ public ZeroCodeCsvReportBuilder stepName(String stepName) {
return this;
}
+ public ZeroCodeCsvReportBuilder url(String url) {
+ this.url = url;
+ return this;
+ }
+
+ public ZeroCodeCsvReportBuilder host(String host) {
+ this.host = host;
+ return this;
+ }
+
public ZeroCodeCsvReportBuilder stepLoop(Integer stepLoop) {
this.stepLoop = stepLoop;
return this;
diff --git a/core/src/main/java/org/jsmart/zerocode/core/domain/reports/csv/ZeroCodeCsvReport.java b/core/src/main/java/org/jsmart/zerocode/core/domain/reports/csv/ZeroCodeCsvReport.java
index 9d694164b..418f845ce 100644
--- a/core/src/main/java/org/jsmart/zerocode/core/domain/reports/csv/ZeroCodeCsvReport.java
+++ b/core/src/main/java/org/jsmart/zerocode/core/domain/reports/csv/ZeroCodeCsvReport.java
@@ -8,12 +8,14 @@ public class ZeroCodeCsvReport {
private String correlationId;
private String result;
private String method;
+ private String host;
+ private String url;
String requestTimeStamp;
String responseTimeStamp;
private Double responseDelayMilliSec;
public ZeroCodeCsvReport(String scenarioName, Integer scenarioLoop, String stepName, Integer stepLoop,
- String correlationId, String result, String method, String requestTimeStamp,
+ String correlationId, String result, String method, String host, String url, String requestTimeStamp,
String responseTimeStamp, Double responseDelayMilliSec) {
this.scenarioName = scenarioName;
this.scenarioLoop = scenarioLoop;
@@ -22,6 +24,8 @@ public ZeroCodeCsvReport(String scenarioName, Integer scenarioLoop, String stepN
this.correlationId = correlationId;
this.result = result;
this.method=method;
+ this.host=host;
+ this.url=url;
this.requestTimeStamp = requestTimeStamp;
this.responseTimeStamp = responseTimeStamp;
this.responseDelayMilliSec = responseDelayMilliSec;
@@ -55,6 +59,14 @@ public String getMethod() {
return method;
}
+ public String getHost() {
+ return host;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
public Double getResponseDelayMilliSec() {
return responseDelayMilliSec;
}
@@ -77,6 +89,8 @@ public String toString() {
", correlationId='" + correlationId + '\'' +
", result='" + result + '\'' +
", method='" + method + '\'' +
+ ", host='" + host + '\'' +
+ ", url='" + url + '\'' +
", requestTimeStamp=" + requestTimeStamp +
", responseTimeStamp=" + responseTimeStamp +
", responseDelayMilliSec=" + responseDelayMilliSec +
diff --git a/core/src/main/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImpl.java b/core/src/main/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImpl.java
index dc3e6cc92..9f16fb259 100644
--- a/core/src/main/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImpl.java
+++ b/core/src/main/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImpl.java
@@ -26,6 +26,8 @@
import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
@@ -49,6 +51,8 @@
import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.TARGET_FULL_REPORT_DIR;
import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.TARGET_REPORT_DIR;
import static org.jsmart.zerocode.core.constants.ZeroCodeReportConstants.TEST_STEP_CORRELATION_ID;
+import static org.jsmart.zerocode.core.utils.ApiType.*;
+import static org.jsmart.zerocode.core.utils.ApiTypeUtils.apiType;
public class ZeroCodeReportGeneratorImpl implements ZeroCodeReportGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(ZeroCodeReportGeneratorImpl.class);
@@ -106,16 +110,16 @@ public void generateExtentReport() {
test.getModel().setEndTime(utilDateOf(thisStep.getResponseTimeStamp()));
final Status testStatus = thisStep.getResult().equals(RESULT_PASS) ? Status.PASS : Status.FAIL;
-
+
ExtentTest step = test.createNode(thisStep.getName(), TEST_STEP_CORRELATION_ID + " " + thisStep.getCorrelationId());
-
- if(testStatus.equals(Status.PASS)) {
- step.pass(thisStep.getResult());
- }else {
- step.info(MarkupHelper.createCodeBlock(thisStep.getOperation() + "\t" + thisStep.getUrl()));
- step.info(MarkupHelper.createCodeBlock(thisStep.getRequest(), CodeLanguage.JSON));
+
+ if (testStatus.equals(Status.PASS)) {
+ step.pass(thisStep.getResult());
+ } else {
+ step.info(MarkupHelper.createCodeBlock(thisStep.getOperation() + "\t" + thisStep.getUrl()));
+ step.info(MarkupHelper.createCodeBlock(thisStep.getRequest(), CodeLanguage.JSON));
step.info(MarkupHelper.createCodeBlock(thisStep.getResponse(), CodeLanguage.JSON));
- step.fail(MarkupHelper.createCodeBlock("Reason:\n" + thisStep.getAssertions()));
+ step.fail(MarkupHelper.createCodeBlock("Reason:\n" + thisStep.getAssertions()));
}
extentReports.flush();
});
@@ -133,13 +137,13 @@ public void linkToSpikeChartIfEnabled() {
// (might be disabled by current runner)
// Then it's good to link it to that spike report.
// ------------------------------------------------
- if(spikeChartReportEnabled || spikeChartFileName != null){
+ if (spikeChartReportEnabled || spikeChartFileName != null) {
final String reportName = getReportName();
String linkCodeToTargetSpikeChartHtml =
String.format(" %s ",
- spikeChartFileName,
- LINK_LABEL_NAME);
+ spikeChartFileName,
+ LINK_LABEL_NAME);
ExtentReportsFactory.reportName(reportName + linkCodeToTargetSpikeChartHtml);
}
@@ -148,33 +152,33 @@ public void linkToSpikeChartIfEnabled() {
protected String optionalAuthor(String scenarioName) {
String authorName = substringBetween(scenarioName, AUTHOR_MARKER, AUTHOR_MARKER);
- if(authorName == null){
+ if (authorName == null) {
authorName = substringBetween(scenarioName, AUTHOR_MARKER, ",");
}
- if(authorName == null){
+ if (authorName == null) {
authorName = substringBetween(scenarioName, AUTHOR_MARKER, " ");
}
- if(authorName == null){
+ if (authorName == null) {
authorName = scenarioName.substring(scenarioName.lastIndexOf(AUTHOR_MARKER) + AUTHOR_MARKER.length());
}
- if(scenarioName.lastIndexOf(AUTHOR_MARKER) == -1 || StringUtils.isEmpty(authorName)){
+ if (scenarioName.lastIndexOf(AUTHOR_MARKER) == -1 || StringUtils.isEmpty(authorName)) {
authorName = ANONYMOUS_AUTHOR;
}
return authorName;
}
-
+
protected String onlyScenarioName(String scenarioName) {
-
- int index = scenarioName.indexOf(AUTHOR_MARKER);
- if(index == -1) {
- return scenarioName;
- }else {
- return scenarioName.substring(0, index -1);
- }
+
+ int index = scenarioName.indexOf(AUTHOR_MARKER);
+ if (index == -1) {
+ return scenarioName;
+ } else {
+ return scenarioName.substring(0, index - 1);
+ }
}
@Override
@@ -198,7 +202,7 @@ public void generateHighChartReport() {
/*
* Generate: Spike Chart using HighChart
*/
- if(spikeChartReportEnabled){
+ if (spikeChartReportEnabled) {
HighChartColumnHtml highChartColumnHtml = convertCsvRowsToHighChartData(zeroCodeCsvFlattenedRows);
generateHighChartReport(highChartColumnHtml);
}
@@ -255,6 +259,9 @@ public void generateCsvReport(List zeroCodeCsvReportRows) {
.addColumn("responseTimeStamp")
.addColumn("result")
.addColumn("method")
+ .addColumn("host")
+ //If(host enabled)
+ .addColumn("url")
.build();
CsvMapper csvMapper = new CsvMapper();
@@ -295,6 +302,29 @@ public List buildCsvRows() {
csvFileBuilder.correlationId(thisStep.getCorrelationId());
csvFileBuilder.result(thisStep.getResult());
csvFileBuilder.method(thisStep.getOperation());
+ /**
+ * @implNote Conditional Host and Url fields added as per API Type
+ **/
+ String host = "";
+ String urlPath = "";
+ if (apiType(thisStep.getUrl(), thisStep.getOperation()).equals(REST_CALL)) {
+ try {
+ URL u = new URL(thisStep.getUrl());
+ String url = u.toString();
+ host = url.substring(0, url.indexOf(u.getPath()));
+ urlPath = u.getPath();
+ csvFileBuilder.host(host);
+ csvFileBuilder.url(urlPath);
+ } catch (MalformedURLException e) {
+ LOGGER.error("####MalformedURLException: " + e.getMessage() + " In Test: " + thisResult.getScenarioName()+ ",URL: "+thisStep.getUrl());
+ }
+ } else if (apiType(thisStep.getUrl(), thisStep.getOperation()).equals(JAVA_CALL)) {
+ csvFileBuilder.host("NATIVE");
+ csvFileBuilder.url(thisStep.getUrl());
+ } else if (apiType(thisStep.getUrl(), thisStep.getOperation()).equals(KAFKA_CALL)) {
+ csvFileBuilder.host("KAFKA");
+ csvFileBuilder.url(thisStep.getUrl());
+ }
csvFileBuilder.requestTimeStamp(thisStep.getRequestTimeStamp().toString());
csvFileBuilder.responseTimeStamp(thisStep.getResponseTimeStamp().toString());
csvFileBuilder.responseDelayMilliSec(thisStep.getResponseDelay());
@@ -342,7 +372,7 @@ public static List getAllEndPointFilesFrom(String folderName) {
return name.endsWith(".json");
});
- if(files == null || files.length == 0){
+ if (files == null || files.length == 0) {
LOGGER.error("\n\t\t\t************\nNow files were found in folder:{}, hence could not proceed. " +
"\n(If this was intentional, then you can safely ignore this error)" +
diff --git a/core/src/test/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImplTest.java b/core/src/test/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImplTest.java
index b05c464fc..1c62c835b 100644
--- a/core/src/test/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImplTest.java
+++ b/core/src/test/java/org/jsmart/zerocode/core/report/ZeroCodeReportGeneratorImplTest.java
@@ -76,4 +76,6 @@ public void testAuthorJiraStyle() throws Exception {
}
+
+
}
\ No newline at end of file