1
0
mirror of https://github.com/square/okhttp.git synced 2025-07-31 05:04:26 +03:00

Use more AssertJ features

This commit is contained in:
Jesse Wilson
2019-03-13 22:35:04 -04:00
parent 8aa1e51789
commit dedc6ecd5b
49 changed files with 1140 additions and 1211 deletions

View File

@ -19,7 +19,6 @@ import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.net.ssl.HostnameVerifier;
import okhttp3.HttpUrl;
@ -846,17 +845,16 @@ public final class HttpLoggingInterceptorTest {
private int index;
LogRecorder assertLogEqual(String expected) {
assertThat(index < logs.size()).overridingErrorMessage("No more messages found").isTrue();
assertThat(index).overridingErrorMessage("No more messages found").isLessThan(logs.size());
String actual = logs.get(index++);
assertThat(actual).isEqualTo(expected);
return this;
}
LogRecorder assertLogMatch(String pattern) {
assertThat(index < logs.size()).overridingErrorMessage("No more messages found").isTrue();
assertThat(index).overridingErrorMessage("No more messages found").isLessThan(logs.size());
String actual = logs.get(index++);
assertThat(Pattern.matches(pattern, actual)).overridingErrorMessage(
"<" + actual + "> did not match pattern <" + pattern + ">").isTrue();
assertThat(actual).matches(pattern);
return this;
}