Skip to content

Instantly share code, notes, and snippets.

@luuizeduardo
Created November 4, 2022 10:54
Show Gist options
  • Save luuizeduardo/a560af2734340b3cfa6befbff05c57a0 to your computer and use it in GitHub Desktop.
Save luuizeduardo/a560af2734340b3cfa6befbff05c57a0 to your computer and use it in GitHub Desktop.
package org.example.repositories;
import com.fasterxml.jackson.databind.JsonNode;
import io.restassured.response.Response;
import org.json.JSONException;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.stereotype.Repository;
@Repository
public class ResponseUtils {
public static void assertJson(String actualJson, String expectedJson, JSONCompareMode mode) throws JSONException {
JSONAssert.assertEquals(expectedJson, actualJson, mode);
}
public static void assertJson(Response response, JsonNode expectedJson) throws JSONException {
assertJson(response.getBody().asString(), expectedJson.toString(), JSONCompareMode.LENIENT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment