Skip to content

Commit c962984

Browse files
committed
Keep browser optional in log object
According to the specification (http://www.softwareishard.com/blog/har-12-spec/#log) `browser` field is optional in `log`: "browser [object, optional] - Name and version info of used browser." thus it is not required to create a default value in the getter.
1 parent 6e69860 commit c962984

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/main/java/de/sstoehr/harreader/model/HarLog.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,9 @@ public void setCreator(HarCreatorBrowser creator) {
5959
}
6060

6161
/**
62-
* @return Information about the browser used.
62+
* @return Information about the browser used, may be null.
6363
*/
6464
public HarCreatorBrowser getBrowser() {
65-
if (browser == null) {
66-
browser = new HarCreatorBrowser();
67-
}
6865
return browser;
6966
}
7067

src/test/java/de/sstoehr/harreader/model/HarLogTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import static org.junit.jupiter.api.Assertions.assertEquals;
66
import static org.junit.jupiter.api.Assertions.assertNotNull;
7+
import static org.junit.jupiter.api.Assertions.assertNull;
78

89
import java.util.ArrayList;
910
import java.util.List;
@@ -63,7 +64,7 @@ void testCreatorNull() {
6364
void testBrowserNull() {
6465
HarLog log = new HarLog();
6566
log.setBrowser(null);
66-
assertNotNull(log.getBrowser());
67+
assertNull(log.getBrowser());
6768
}
6869

6970
@Override

0 commit comments

Comments
 (0)