Skip to content

Commit

Permalink
Merge pull request #23 from iamakshayshar/feature/version-5.1
Browse files Browse the repository at this point in the history
Fixed #22
  • Loading branch information
iamakshayshar authored Nov 4, 2023
2 parents 20074c8 + 293d0a0 commit f64a930
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.
14 changes: 9 additions & 5 deletions src/com/soapuiextentter/listener/ExtenterProjectRunListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public class ExtenterProjectRunListener implements ProjectRunListener {

public void beforeRun(ProjectRunner runner, ProjectRunContext context) {
// SoapUI.log("Inside BeforeRun in ProjectRunListener - 1");
HashMap<String, String> klovConfig = new HashMap<String, String>();
try {
List<TestProperty> properties = context.getProject().getPropertyList();
HashMap<String, String> klovConfig = getKlovConfiguration(properties);
klovConfig = getKlovConfiguration(properties);
Projservice = new SoapUIServiceImpl();
String projectXmlPath = context.getProject().getPath();
int index = projectXmlPath.lastIndexOf(File.separator);
Expand All @@ -40,7 +41,11 @@ public void beforeRun(ProjectRunner runner, ProjectRunContext context) {

String reportName = context.getProject().getName();
Projservice.startReporting(reportPath, reportName, klovConfig);
Projservice.addEnvDetails(properties);

if (!properties.isEmpty() || properties.size() != 0) {
Projservice.addEnvDetails(properties);
}

} catch (Exception t) {
SoapUI.log("SOAPUI Extentter plugin cannot be initialized. " + t.getMessage());
}
Expand All @@ -49,9 +54,8 @@ public void beforeRun(ProjectRunner runner, ProjectRunContext context) {
private HashMap<String, String> getKlovConfiguration(List<TestProperty> properties) {
HashMap<String, String> klovMap = new HashMap<String, String>();
try {
int propSize = properties.size();
if (propSize != 0) {
for (int propInterator = 0; propInterator < propSize; propInterator++) {
if (!properties.isEmpty() || properties.size() != 0) {
for (int propInterator = 0; propInterator < properties.size(); propInterator++) {
if (properties.get(propInterator).getName().equalsIgnoreCase("MongoDBIP")) {
if (properties.get(propInterator).getValue() != null && InetAddress
.getByName(properties.get(propInterator).getValue()).isReachable(timeout)) {
Expand Down
69 changes: 34 additions & 35 deletions src/com/soapuiextentter/reporter/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,20 @@ public Report(String reportPath, String reportName, HashMap<String, String> klov
reports.setSystemInfo("Executor", System.getProperty("user.name"));
reports.setSystemInfo("SoapUI Version", SoapUI.SOAPUI_VERSION);

if (!klovConfig.get("MongoDBIP").isEmpty() && !klovConfig.get("MongoDBPort").isEmpty()
&& !klovConfig.get("KlovServerUrl").isEmpty()) {
ExtentKlovReporter klov = new ExtentKlovReporter(reportName);
klov.initMongoDbConnection(klovConfig.get("MongoDBIP"),
Integer.parseInt(klovConfig.get("MongoDBPort")));
klov.setProjectName(reportName);
klov.setReportName("2.0");
klov.initKlovServerConnection(klovConfig.get("KlovServerUrl"));
reports.attachReporter(spark, klov);
if (klovConfig.size() != 0) {
if (!klovConfig.get("MongoDBIP").isEmpty() && !klovConfig.get("MongoDBPort").isEmpty()
&& !klovConfig.get("KlovServerUrl").isEmpty()) {
ExtentKlovReporter klov = new ExtentKlovReporter(reportName);
klov.initMongoDbConnection(klovConfig.get("MongoDBIP"),
Integer.parseInt(klovConfig.get("MongoDBPort")));
klov.setProjectName(reportName);
klov.setReportName("2.0");
klov.initKlovServerConnection(klovConfig.get("KlovServerUrl"));
reports.attachReporter(spark, klov);
} else {
SoapUI.log("Klov Configuration missing or Wrong");
reports.attachReporter(spark);
}
} else {
reports.attachReporter(spark);
}
Expand Down Expand Up @@ -411,19 +416,15 @@ public void addEnvironmentDetails(List<TestProperty> properties) {
flag = envLogCheck(properties);
if (flag) {
int propSize = properties.size();
if (propSize != 0) {
for (int propInterator = 0; propInterator < propSize; propInterator++) {
if (properties.get(propInterator).getName().contains("Password")
|| properties.get(propInterator).getName().contains("Pass")) {
reports.setSystemInfo(properties.get(propInterator).getName(), "*******");
} else {
reports.setSystemInfo(properties.get(propInterator).getName(),
properties.get(propInterator).getValue());
}
for (int propInterator = 0; propInterator < propSize; propInterator++) {
if (properties.get(propInterator).getName().contains("Password")
|| properties.get(propInterator).getName().contains("Pass")) {
reports.setSystemInfo(properties.get(propInterator).getName(), "*******");
} else {
reports.setSystemInfo(properties.get(propInterator).getName(),
properties.get(propInterator).getValue());
}
}
} else {
reports.setSystemInfo("AddDataToReport", "False");
}
} catch (Exception e) {
String exceptionMessage = " Exception occurred for Report method - addEnvironmentDetails as ";
Expand All @@ -432,31 +433,29 @@ public void addEnvironmentDetails(List<TestProperty> properties) {
}

private boolean envLogCheck(List<TestProperty> properties) {
boolean propValue = true;
boolean logValues = true;
try {
int propSize = properties.size();
if (propSize != 0) {
for (int propInterator = 0; propInterator < propSize; propInterator++) {
if (properties.get(propInterator).getName().equalsIgnoreCase("AddDataToReport")) {
if (properties.get(propInterator).getValue().equalsIgnoreCase("True")) {
return propValue;
} else if (properties.get(propInterator).getValue().equalsIgnoreCase("False")) {
return false;
} else {
SoapUI.log(
"Invalid value specified for 'AddDataToReport' in project properties. Please check and correct.");
return propValue;
}
for (int propInterator = 0; propInterator < propSize; propInterator++) {
if (properties.get(propInterator).getName().equalsIgnoreCase("AddDataToReport")) {
if (properties.get(propInterator).getValue().equalsIgnoreCase("True")) {
return logValues;
} else if (properties.get(propInterator).getValue().equalsIgnoreCase("False")) {
return false;
} else {
propValue = true;
SoapUI.log(
"Invalid value specified for 'AddDataToReport' in project properties. Please check and correct.");
return logValues;
}
} else {
logValues = true;
}
}
} catch (Exception e) {
String exceptionMessage = " Exception occurred for Report method - addEnvironmentDetails as ";
SoapUI.log(exceptionMessage + e.toString());
}
return propValue;
return logValues;
}

private String getEndpoint(String endPoint) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/soapuiextentter/service/SoapUIServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus;
import com.soapuiextentter.reporter.Report;
import com.eviware.soapui.model.testsuite.TestSuiteRunner;
import com.soapuiextentter.reporter.Report;

/*
* Author : Akshay Sharma
Expand Down

0 comments on commit f64a930

Please sign in to comment.