Skip to content

Commit

Permalink
[java] Adding more tests for ImmutableCapabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed May 22, 2020
1 parent d9426c7 commit 979f02a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public ImmutableCapabilities(Capabilities other) {

public ImmutableCapabilities(Map<?, ?> capabilities) {
capabilities.forEach((key, value) -> {
if (!(key instanceof String)) {
throw new IllegalArgumentException("Key values must be strings");
}
Require.argument("Key", key).instanceOf(String.class);
setCapability(String.valueOf(key), value);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
package org.openqa.selenium;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import com.google.common.collect.ImmutableMap;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

public class ImmutableCapabilitiesTest {

@Test
Expand Down Expand Up @@ -76,4 +80,12 @@ public void canCompareCapabilities() {
assertThat(new ImmutableCapabilities(caps2)).isEqualTo(new ImmutableCapabilities(caps1));
}

@Test
public void shouldCheckKeyType() {
Map<Object, Object> map = new HashMap<>();
map.put(new Object(), new Object());
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new ImmutableCapabilities(map));
}

}

0 comments on commit 979f02a

Please sign in to comment.