Skip to content

Commit

Permalink
[java] Fixing InternetExplorerOptions.merge, it should ignore "se:ieO…
Browse files Browse the repository at this point in the history
…ptions" and merge only real capabilities, "se:ieOptions" will be constructed automatically
  • Loading branch information
barancev committed Feb 23, 2021
1 parent 7d488f7 commit 0da772d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Expand Up @@ -96,8 +96,12 @@ public InternetExplorerOptions(Capabilities source) {
@Override
public InternetExplorerOptions merge(Capabilities extraCapabilities) {
InternetExplorerOptions newInstance = new InternetExplorerOptions();
this.asMap().forEach(newInstance::setCapability);
extraCapabilities.asMap().forEach(newInstance::setCapability);
this.asMap().entrySet().stream()
.filter(entry -> !entry.getKey().equals(IE_OPTIONS))
.forEach(entry -> newInstance.setCapability(entry.getKey(), entry.getValue()));
extraCapabilities.asMap().entrySet().stream()
.filter(entry -> !entry.getKey().equals(IE_OPTIONS))
.forEach(entry -> newInstance.setCapability(entry.getKey(), entry.getValue()));
return newInstance;
}

Expand Down
Expand Up @@ -121,9 +121,14 @@ public void mergingOptionsMergesArguments() {
InternetExplorerOptions two = new InternetExplorerOptions();
InternetExplorerOptions merged = one.merge(two);

assertThat(merged.asMap()).asInstanceOf(MAP)
Map<String, Object> asMap = merged.asMap();
assertThat(asMap)
.containsEntry(FORCE_CREATE_PROCESS, true)
.extractingByKey(IE_SWITCHES).asInstanceOf(LIST)
.containsExactly("-private");
assertThat(asMap)
.extractingByKey(IE_OPTIONS).asInstanceOf(MAP)
.containsEntry(FORCE_CREATE_PROCESS, true)
.extractingByKey(IE_SWITCHES).isEqualTo("-private");
}
}

0 comments on commit 0da772d

Please sign in to comment.