Skip to content

Commit 62aa722

Browse files
committed
Refactoring a test, no logical changes
1 parent ff621a2 commit 62aa722

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

java/client/test/org/openqa/selenium/remote/RemoteLogsTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
package org.openqa.selenium.remote;
1919

2020
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.fail;
21+
import static org.junit.Assert.assertThat;
2222
import static org.mockito.Mockito.verifyNoMoreInteractions;
2323
import static org.mockito.Mockito.when;
2424

2525
import com.google.common.collect.ImmutableList;
2626
import com.google.common.collect.ImmutableMap;
2727

28+
import org.hamcrest.CoreMatchers;
2829
import org.junit.Before;
2930
import org.junit.Test;
3031
import org.junit.runner.RunWith;
@@ -36,6 +37,7 @@
3637
import org.openqa.selenium.logging.LogEntries;
3738
import org.openqa.selenium.logging.LogEntry;
3839
import org.openqa.selenium.logging.LogType;
40+
import org.openqa.selenium.testing.TestUtilities;
3941

4042
import java.util.ArrayList;
4143
import java.util.HashSet;
@@ -131,15 +133,13 @@ public void throwsOnBogusRemoteLogsResponse() {
131133
when(
132134
executeMethod
133135
.execute(DriverCommand.GET_LOG, ImmutableMap.of(RemoteLogs.TYPE_KEY, LogType.BROWSER)))
134-
.thenReturn(new ImmutableMap.Builder()
136+
.thenReturn(new ImmutableMap.Builder<>()
135137
.put("error", "unknown method")
136138
.put("message", "Command not found: POST /session/11037/log")
137139
.put("stacktrace", "").build());
138-
try {
139-
remoteLogs.get(LogType.BROWSER);
140-
fail("Should have thrown WebDriverException");
141-
} catch (WebDriverException expected) {
142-
}
140+
141+
Throwable ex = TestUtilities.catchThrowable(() -> remoteLogs.get(LogType.BROWSER));
142+
assertThat(ex, CoreMatchers.instanceOf(WebDriverException.class));
143143

144144
verifyNoMoreInteractions(localLogs);
145145
}

0 commit comments

Comments
 (0)