Skip to content

Commit f64a930

Browse files
Merge pull request #23 from iamakshayshar/feature/version-5.1
Fixed #22
2 parents 20074c8 + 293d0a0 commit f64a930

File tree

3 files changed

+44
-41
lines changed

3 files changed

+44
-41
lines changed

src/com/soapuiextentter/listener/ExtenterProjectRunListener.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ public class ExtenterProjectRunListener implements ProjectRunListener {
2929

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

4142
String reportName = context.getProject().getName();
4243
Projservice.startReporting(reportPath, reportName, klovConfig);
43-
Projservice.addEnvDetails(properties);
44+
45+
if (!properties.isEmpty() || properties.size() != 0) {
46+
Projservice.addEnvDetails(properties);
47+
}
48+
4449
} catch (Exception t) {
4550
SoapUI.log("SOAPUI Extentter plugin cannot be initialized. " + t.getMessage());
4651
}
@@ -49,9 +54,8 @@ public void beforeRun(ProjectRunner runner, ProjectRunContext context) {
4954
private HashMap<String, String> getKlovConfiguration(List<TestProperty> properties) {
5055
HashMap<String, String> klovMap = new HashMap<String, String>();
5156
try {
52-
int propSize = properties.size();
53-
if (propSize != 0) {
54-
for (int propInterator = 0; propInterator < propSize; propInterator++) {
57+
if (!properties.isEmpty() || properties.size() != 0) {
58+
for (int propInterator = 0; propInterator < properties.size(); propInterator++) {
5559
if (properties.get(propInterator).getName().equalsIgnoreCase("MongoDBIP")) {
5660
if (properties.get(propInterator).getValue() != null && InetAddress
5761
.getByName(properties.get(propInterator).getValue()).isReachable(timeout)) {

src/com/soapuiextentter/reporter/Report.java

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,20 @@ public Report(String reportPath, String reportName, HashMap<String, String> klov
5757
reports.setSystemInfo("Executor", System.getProperty("user.name"));
5858
reports.setSystemInfo("SoapUI Version", SoapUI.SOAPUI_VERSION);
5959

60-
if (!klovConfig.get("MongoDBIP").isEmpty() && !klovConfig.get("MongoDBPort").isEmpty()
61-
&& !klovConfig.get("KlovServerUrl").isEmpty()) {
62-
ExtentKlovReporter klov = new ExtentKlovReporter(reportName);
63-
klov.initMongoDbConnection(klovConfig.get("MongoDBIP"),
64-
Integer.parseInt(klovConfig.get("MongoDBPort")));
65-
klov.setProjectName(reportName);
66-
klov.setReportName("2.0");
67-
klov.initKlovServerConnection(klovConfig.get("KlovServerUrl"));
68-
reports.attachReporter(spark, klov);
60+
if (klovConfig.size() != 0) {
61+
if (!klovConfig.get("MongoDBIP").isEmpty() && !klovConfig.get("MongoDBPort").isEmpty()
62+
&& !klovConfig.get("KlovServerUrl").isEmpty()) {
63+
ExtentKlovReporter klov = new ExtentKlovReporter(reportName);
64+
klov.initMongoDbConnection(klovConfig.get("MongoDBIP"),
65+
Integer.parseInt(klovConfig.get("MongoDBPort")));
66+
klov.setProjectName(reportName);
67+
klov.setReportName("2.0");
68+
klov.initKlovServerConnection(klovConfig.get("KlovServerUrl"));
69+
reports.attachReporter(spark, klov);
70+
} else {
71+
SoapUI.log("Klov Configuration missing or Wrong");
72+
reports.attachReporter(spark);
73+
}
6974
} else {
7075
reports.attachReporter(spark);
7176
}
@@ -411,19 +416,15 @@ public void addEnvironmentDetails(List<TestProperty> properties) {
411416
flag = envLogCheck(properties);
412417
if (flag) {
413418
int propSize = properties.size();
414-
if (propSize != 0) {
415-
for (int propInterator = 0; propInterator < propSize; propInterator++) {
416-
if (properties.get(propInterator).getName().contains("Password")
417-
|| properties.get(propInterator).getName().contains("Pass")) {
418-
reports.setSystemInfo(properties.get(propInterator).getName(), "*******");
419-
} else {
420-
reports.setSystemInfo(properties.get(propInterator).getName(),
421-
properties.get(propInterator).getValue());
422-
}
419+
for (int propInterator = 0; propInterator < propSize; propInterator++) {
420+
if (properties.get(propInterator).getName().contains("Password")
421+
|| properties.get(propInterator).getName().contains("Pass")) {
422+
reports.setSystemInfo(properties.get(propInterator).getName(), "*******");
423+
} else {
424+
reports.setSystemInfo(properties.get(propInterator).getName(),
425+
properties.get(propInterator).getValue());
423426
}
424427
}
425-
} else {
426-
reports.setSystemInfo("AddDataToReport", "False");
427428
}
428429
} catch (Exception e) {
429430
String exceptionMessage = " Exception occurred for Report method - addEnvironmentDetails as ";
@@ -432,31 +433,29 @@ public void addEnvironmentDetails(List<TestProperty> properties) {
432433
}
433434

434435
private boolean envLogCheck(List<TestProperty> properties) {
435-
boolean propValue = true;
436+
boolean logValues = true;
436437
try {
437438
int propSize = properties.size();
438-
if (propSize != 0) {
439-
for (int propInterator = 0; propInterator < propSize; propInterator++) {
440-
if (properties.get(propInterator).getName().equalsIgnoreCase("AddDataToReport")) {
441-
if (properties.get(propInterator).getValue().equalsIgnoreCase("True")) {
442-
return propValue;
443-
} else if (properties.get(propInterator).getValue().equalsIgnoreCase("False")) {
444-
return false;
445-
} else {
446-
SoapUI.log(
447-
"Invalid value specified for 'AddDataToReport' in project properties. Please check and correct.");
448-
return propValue;
449-
}
439+
for (int propInterator = 0; propInterator < propSize; propInterator++) {
440+
if (properties.get(propInterator).getName().equalsIgnoreCase("AddDataToReport")) {
441+
if (properties.get(propInterator).getValue().equalsIgnoreCase("True")) {
442+
return logValues;
443+
} else if (properties.get(propInterator).getValue().equalsIgnoreCase("False")) {
444+
return false;
450445
} else {
451-
propValue = true;
446+
SoapUI.log(
447+
"Invalid value specified for 'AddDataToReport' in project properties. Please check and correct.");
448+
return logValues;
452449
}
450+
} else {
451+
logValues = true;
453452
}
454453
}
455454
} catch (Exception e) {
456455
String exceptionMessage = " Exception occurred for Report method - addEnvironmentDetails as ";
457456
SoapUI.log(exceptionMessage + e.toString());
458457
}
459-
return propValue;
458+
return logValues;
460459
}
461460

462461
private String getEndpoint(String endPoint) {

src/com/soapuiextentter/service/SoapUIServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import com.eviware.soapui.model.testsuite.TestStep;
1111
import com.eviware.soapui.model.testsuite.TestStepResult;
1212
import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus;
13-
import com.soapuiextentter.reporter.Report;
1413
import com.eviware.soapui.model.testsuite.TestSuiteRunner;
14+
import com.soapuiextentter.reporter.Report;
1515

1616
/*
1717
* Author : Akshay Sharma

0 commit comments

Comments
 (0)