Skip to content

Commit c3e999c

Browse files
committed
fixes #235
1 parent 096858a commit c3e999c

4 files changed

Lines changed: 26 additions & 25 deletions

File tree

reporters/klov/src/main/java/com/aventstack/extentreports/reporter/HttpMediaManagerImplKlov.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public void storeMedia(Media m) throws IOException {
4646
if (m instanceof ScreenCapture && ((ScreenCapture) m).getBase64() != null) {
4747
return;
4848
}
49-
File f = new File(m.getResolvedPath());
49+
File f = new File(m.getPath());
50+
if (m.getResolvedPath() != null)
51+
f = new File(m.getResolvedPath());
5052
if (!f.exists()) {
5153
throw new IOException("The system cannot find the file specified " + m.getPath());
5254
}
@@ -69,13 +71,12 @@ public void storeMedia(Media m) throws IOException {
6971
ContentType.TEXT_PLAIN));
7072
builder.addPart("testId",
7173
new StringBody(m.getInfoMap().get(ExtentKlovReporter.TEST_ID_KEY).toString(), ContentType.TEXT_PLAIN));
72-
builder.addPart("f", new FileBody(new File(m.getResolvedPath())));
74+
builder.addPart("f", new FileBody(f));
7375
post.setEntity(builder.build());
7476

75-
String logId = m.getInfoMap().get(ExtentKlovReporter.LOG_ID_KEY) == null
76-
? null
77-
: m.getInfoMap().get(ExtentKlovReporter.LOG_ID_KEY).toString();
78-
builder.addPart("logId", new StringBody(logId, ContentType.TEXT_PLAIN));
77+
Object logId = m.getInfoMap().get(ExtentKlovReporter.LOG_ID_KEY);
78+
if (logId != null)
79+
builder.addPart("logId", new StringBody(logId.toString(), ContentType.TEXT_PLAIN));
7980

8081
HttpClient client = null;
8182
if (host.toLowerCase().startsWith("https")) {

src/main/java/com/aventstack/extentreports/ExtentTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public ExtentTest generateLog(Status status, Markup markup) {
357357
* @return An {@link ExtentTest} object
358358
*/
359359
public ExtentTest log(Status status, String details, Throwable t, Media media) {
360-
Assert.notNull(status, "Status must not be null");
360+
Assert.notNull(status, "Status must not be null");
361361
Log log = Log.builder()
362362
.status(status)
363363
.details(details == null ? "" : details)
@@ -366,7 +366,7 @@ public ExtentTest log(Status status, String details, Throwable t, Media media) {
366366
log.setException(exceptionInfo);
367367
log.addMedia(media);
368368
if (exceptionInfo != null)
369-
model.getExceptions().add(exceptionInfo);
369+
model.getExceptions().add(exceptionInfo);
370370
model.addLog(log);
371371
extent.onLogCreated(log, model);
372372
return this;
@@ -1067,7 +1067,7 @@ public Status getStatus() {
10671067
}
10681068

10691069
public ExtentTest addScreenCaptureFromPath(String path, String title) {
1070-
Assert.notEmpty(path, "ScreenCapture path must not be null or empty");
1070+
Assert.notEmpty(path, "ScreenCapture path must not be null or empty");
10711071
Media m = ScreenCapture.builder().path(path).title(title).build();
10721072
model.addMedia(m);
10731073
extent.onMediaAdded(m, model);
@@ -1079,7 +1079,7 @@ public ExtentTest addScreenCaptureFromPath(String path) {
10791079
}
10801080

10811081
public ExtentTest addScreenCaptureFromBase64String(String base64, String title) {
1082-
Assert.notEmpty(base64, "ScreenCapture's base64 string must not be null or empty");
1082+
Assert.notEmpty(base64, "ScreenCapture's base64 string must not be null or empty");
10831083
if (!base64.startsWith("data:"))
10841084
base64 = "data:image/png;base64," + base64;
10851085
Media m = ScreenCapture.builder().base64(base64).title(title).build();

src/main/java/com/aventstack/extentreports/model/Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public final class Test implements RunResult, Serializable, BaseEntity, MetaData
6565
private final List<Log> generatedLog = Collections.synchronizedList(new ArrayList<>());
6666

6767
public final void addChild(Test child) {
68-
Assert.notNull(child, "Node must not be null");
68+
Assert.notNull(child, "Node must not be null");
6969
child.setLevel(level + 1);
7070
child.setParent(this);
7171
child.setLeaf(true);
@@ -100,7 +100,7 @@ public final void addGeneratedLog(Log log) {
100100
}
101101

102102
private final void addLog(Log log, List<Log> list) {
103-
Assert.notNull(log, "Log must not be null");
103+
Assert.notNull(log, "Log must not be null");
104104
log.setSeq(list.size());
105105
list.add(log);
106106
end(log.getStatus());
@@ -148,7 +148,7 @@ public final String getFullName() {
148148
StringBuilder sb = new StringBuilder(test.getName());
149149
while (test.getParent() != null) {
150150
test = test.getParent();
151-
if (test.getBddType() == null || test.getBddType() != ScenarioOutline.class)
151+
if (!test.isBDD() || test.getBddType() != ScenarioOutline.class)
152152
sb.insert(0, test.getName() + ".");
153153
}
154154
return sb.toString();
@@ -168,7 +168,7 @@ public final boolean hasScreenCapture() {
168168
public final long timeTaken() {
169169
return endTime.getTime() - startTime.getTime();
170170
}
171-
171+
172172
public List<ExceptionInfo> aggregateExceptions() {
173173
return logs.stream()
174174
.filter(x -> x.getException() != null)
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.aventstack.extentreports.util;
22

33
public class Assert {
4-
public static void notNull(Object o, String message) {
5-
if (o == null) {
6-
throw new IllegalArgumentException(message);
7-
}
8-
}
9-
10-
public static void notEmpty(String s, String message) {
11-
if (s == null || s.isEmpty()) {
12-
throw new IllegalArgumentException(message);
13-
}
14-
}
4+
public static void notNull(Object o, String message) {
5+
if (o == null) {
6+
throw new IllegalArgumentException(message);
7+
}
8+
}
9+
10+
public static void notEmpty(String s, String message) {
11+
if (s == null || s.isEmpty()) {
12+
throw new IllegalArgumentException(message);
13+
}
14+
}
1515
}

0 commit comments

Comments
 (0)