Skip to content

Commit

Permalink
Use correct equalTo value a character not string
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Nov 16, 2023
1 parent 77e800e commit 42c05dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
Expand Down Expand Up @@ -298,13 +297,13 @@ public HttpResponse(CloseableHttpResponse inner) throws IllegalStateException, I
private void verifyContentType() {
final String contentType = this.getHeader(HttpHeaders.CONTENT_TYPE).getValue();
if (contentType.equals("application/json")) {
assertThat("Response body format was not json, body: " + body, body.charAt(0), equalTo("{"));
assertThat("Response body format was not json, body: " + body, body.charAt(0), equalTo('{'));
} else {
if (body.length() != 0) {
assertThat(
"Response body format was json, whereas content-type was " + contentType + ", body: " + body,
body.charAt(0),
not(equalTo("{"))
not(equalTo('{'))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
import org.opensearch.security.test.helper.file.FileHelper;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;

Expand Down Expand Up @@ -422,12 +421,12 @@ private void verifyBodyContentType() {
.orElseThrow(() -> new RuntimeException("No content type found. Headers:\n" + getHeaders() + "\n\nBody:\n" + body));

if (contentType.equals("application/json")) {
assertThat("Response body format was not json, body: " + body, body.charAt(0), equalTo("{"));
assertThat("Response body format was not json, body: " + body, body.charAt(0), equalTo('{'));
} else {
assertThat(
"Response body format was json, whereas content-type was " + contentType + ", body: " + body,
body.charAt(0),
not(equalTo("{"))
not(equalTo('{'))
);
}
}
Expand Down

0 comments on commit 42c05dc

Please sign in to comment.