Skip to content

Commit

Permalink
remove jsonassert dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed May 17, 2022
1 parent 279e297 commit bcd5a38
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ethereum/executionclient/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ dependencies {

integrationTestImplementation testFixtures(project(':infrastructure:json'))
integrationTestImplementation testFixtures(project(':infrastructure:time'))
integrationTestImplementation testFixtures(project(':data:serializer'))
integrationTestImplementation 'com.squareup.okhttp3:mockwebserver'
integrationTestImplementation 'org.skyscreamer:jsonassert'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import java.io.IOException;
import java.io.UncheckedIOException;
Expand All @@ -26,19 +27,19 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import okio.Buffer;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.bytes.Bytes48;
import org.json.JSONException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.skyscreamer.jsonassert.JSONAssert;
import tech.pegasys.teku.bls.BLSPublicKey;
import tech.pegasys.teku.ethereum.executionclient.schema.BuilderApiResponse;
import tech.pegasys.teku.infrastructure.json.JsonUtil;
import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.provider.JsonProvider;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.TestSpecContext;
Expand All @@ -55,6 +56,8 @@
network = {Eth2Network.MAINNET})
class RestExecutionBuilderClientTest {

private static final JsonProvider JSON_PROVIDER = new JsonProvider();

private static final Duration WAIT_FOR_CALL_COMPLETION = Duration.ofSeconds(10);

private static final String INTERNAL_SERVER_ERROR_MESSAGE =
Expand Down Expand Up @@ -300,18 +303,22 @@ private void verifyPostRequest(String apiPath, String requestBody) {
verifyRequest("POST", apiPath, Optional.of(requestBody));
}

private <T> void verifyRequest(String method, String apiPath, Optional<String> requestBody) {
private <T> void verifyRequest(
String method, String apiPath, Optional<String> expectedRequestBody) {
try {
RecordedRequest request = mockWebServer.takeRequest();
assertThat(request.getMethod()).isEqualTo(method);
assertThat(request.getPath()).isEqualTo(apiPath);
if (requestBody.isEmpty()) {
assertThat(request.getBody().size()).isZero();
Buffer actualRequestBody = request.getBody();
if (expectedRequestBody.isEmpty()) {
assertThat(actualRequestBody.size()).isZero();
} else {
assertThat(request.getBody().size()).isNotZero();
JSONAssert.assertEquals(requestBody.get(), request.getBody().readUtf8(), true);
assertThat(actualRequestBody.size()).isNotZero();
ObjectMapper jsonMapper = JSON_PROVIDER.getObjectMapper();
assertThat(jsonMapper.readTree(expectedRequestBody.get()))
.isEqualTo(jsonMapper.readTree(actualRequestBody.readUtf8()));
}
} catch (InterruptedException | JSONException ex) {
} catch (InterruptedException | JsonProcessingException ex) {
Assertions.fail(ex);
}
}
Expand Down
2 changes: 0 additions & 2 deletions gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,5 @@ dependencyManagement {
}

dependency 'net.jqwik:jqwik:1.6.5'

dependency 'org.skyscreamer:jsonassert:1.5.0'
}
}

0 comments on commit bcd5a38

Please sign in to comment.