Skip to content

Commit

Permalink
Import String.format statically
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Jan 16, 2022
1 parent 3ad2ec9 commit 57cfebe
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;

import static java.lang.String.format;
import static java.time.Duration.ofMillis;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
Expand Down Expand Up @@ -440,16 +441,16 @@ private void checkRequest(RecordedRequest recordedRequest, Object event)
private void checkRequest(RecordedRequest recordedRequest, Map<String, String> customHeaders, Object event)
throws JsonProcessingException
{
assertNotNull(recordedRequest, String.format("No request sent when logging is enabled for %s", event));
assertNotNull(recordedRequest, format("No request sent when logging is enabled for %s", event));
for (String key : customHeaders.keySet()) {
assertNotNull(recordedRequest.getHeader(key), String.format("Custom header %s not present in request for %s event", key, event));
assertNotNull(recordedRequest.getHeader(key), format("Custom header %s not present in request for %s event", key, event));
assertEquals(recordedRequest.getHeader(key), customHeaders.get(key),
String.format("Expected value %s for header %s but got %s for %s event", customHeaders.get(key), key, recordedRequest.getHeader(key), event));
format("Expected value %s for header %s but got %s for %s event", customHeaders.get(key), key, recordedRequest.getHeader(key), event));
}
String body = recordedRequest.getBody().readUtf8();
assertFalse(body.isEmpty(), String.format("Body is empty for %s event", event));
assertFalse(body.isEmpty(), format("Body is empty for %s event", event));
String eventJson = objectMapper.writeValueAsString(event);
assertTrue(objectMapper.readTree(eventJson).equals(objectMapper.readTree(body)), String.format("Json value is wrong for event %s, expected %s but found %s", event, eventJson, body));
assertTrue(objectMapper.readTree(eventJson).equals(objectMapper.readTree(body)), format("Json value is wrong for event %s, expected %s but found %s", event, eventJson, body));
}

private void setupServerTLSCertificate()
Expand Down

0 comments on commit 57cfebe

Please sign in to comment.