Java Code Examples for org.skyscreamer.jsonassert.JSONAssert#assertEquals()
The following examples show how to use
org.skyscreamer.jsonassert.JSONAssert#assertEquals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryConverterIT.java From sql-to-mongo-db-query-converter with Apache License 2.0 | 6 votes |
@Test public void countGroupByNestedFieldSortByCountAliasAllQueryOffset() throws ParseException, IOException, JSONException { QueryConverter queryConverter = new QueryConverter.Builder().sqlString("select address.zipcode as az, count(borough) as co from "+COLLECTION+" GROUP BY address.zipcode order by address.zipcode asc limit 3 offset 3\n" + "ORDER BY count(borough) DESC;").build(); QueryResultIterator<Document> distinctIterable = queryConverter.run(mongoDatabase); List<Document> results = Lists.newArrayList(distinctIterable); assertEquals(3, results.size()); JSONAssert.assertEquals("[{\n" + " \"co\" : 520,\n" + " \"az\" : \"10001\"\n" + "},{\n" + " \"co\" : 471,\n" + " \"az\" : \"10002\"\n" + "},{\n" + " \"co\" : 686,\n" + " \"az\" : \"10003\"\n" + "}]",toJson(results),false); }
Example 2
Source File: TransformationServiceTest.java From data-prep with Apache License 2.0 | 6 votes |
@Test public void exportDataSet() throws Exception { // given String dataSetId = createDataset("input_dataset.csv", "my dataset", "text/csv"); // when String exportContent = given() // .queryParam("name", "ds_export") .expect() .statusCode(200) .log() .ifError()// .when() // .get("/export/dataset/{id}/{format}", dataSetId, "JSON") // .asString(); // then String expectedContent = IOUtils.toString(this.getClass().getResourceAsStream("no_action_expected.json"), UTF_8); JSONAssert.assertEquals(expectedContent, exportContent, false); }
Example 3
Source File: JsonSerializationIT.java From camunda-external-task-client-java with Apache License 2.0 | 6 votes |
@Test public void shouldGetTypedSerializedJson() throws JSONException { // given engineRule.startProcessInstance(processDefinition.getId(), VARIABLE_NAME_JSON, VARIABLE_VALUE_JSON_OBJECT_VALUE); // when client.subscribe(EXTERNAL_TASK_TOPIC_FOO) .handler(handler) .open(); // then clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty()); ExternalTask task = handler.getHandledTasks().get(0); ObjectValue typedValue = task.getVariableTyped(VARIABLE_NAME_JSON, false); JSONAssert.assertEquals(VARIABLE_VALUE_JSON_DESERIALIZED.toExpectedJsonString(), new String(typedValue.getValueSerialized()), true); assertThat(typedValue.getObjectTypeName()).isEqualTo(JsonSerializable.class.getName()); assertThat(typedValue.getType()).isEqualTo(OBJECT); assertThat(typedValue.isDeserialized()).isFalse(); }
Example 4
Source File: GsonHttpMessageConverterTests.java From spring-analysis-note with MIT License | 6 votes |
@Test @SuppressWarnings("unchecked") public void readAndWriteGenerics() throws Exception { Field beansList = ListHolder.class.getField("listField"); String body = "[{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," + "\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}]"; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8)); inputMessage.getHeaders().setContentType(new MediaType("application", "json")); Type genericType = beansList.getGenericType(); List<MyBean> results = (List<MyBean>) converter.read(genericType, MyBeanListHolder.class, inputMessage); assertEquals(1, results.size()); MyBean result = results.get(0); assertEquals("Foo", result.getString()); assertEquals(42, result.getNumber()); assertEquals(42F, result.getFraction(), 0F); assertArrayEquals(new String[] {"Foo", "Bar"}, result.getArray()); assertTrue(result.isBool()); assertArrayEquals(new byte[] {0x1, 0x2}, result.getBytes()); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(results, genericType, new MediaType("application", "json"), outputMessage); JSONAssert.assertEquals(body, outputMessage.getBodyAsString(StandardCharsets.UTF_8), true); }
Example 5
Source File: QueryConverterIT.java From sql-to-mongo-db-query-converter with Apache License 2.0 | 6 votes |
@Test public void selectOrderByAliasBothInAliasQuery() throws ParseException, IOException, JSONException { QueryConverter queryConverter = new QueryConverter.Builder().sqlString("select borough as b, cuisine as c from "+COLLECTION+" order by borough asc,c asc limit 6").build(); QueryResultIterator<Document> distinctIterable = queryConverter.run(mongoDatabase); List<Document> results = Lists.newArrayList(distinctIterable); assertEquals(6, results.size()); JSONAssert.assertEquals("[{\n" + " \"b\" : \"Bronx\",\n" + " \"c\" : \"African\"\n" + "},{\n" + " \"b\" : \"Bronx\",\n" + " \"c\" : \"African\"\n" + "},{\n" + " \"b\" : \"Bronx\",\n" + " \"c\" : \"African\"\n" + "},{\n" + " \"b\" : \"Bronx\",\n" + " \"c\" : \"African\"\n" + "},{\n" + " \"b\" : \"Bronx\",\n" + " \"c\" : \"African\"\n" + "},{\n" + " \"b\" : \"Bronx\",\n" + " \"c\" : \"African\"\n" + "}]",toJson(results),false); }
Example 6
Source File: MessengerProfileTest.java From messenger4j with MIT License | 6 votes |
@Test void shouldSetupTargetAudienceNone() throws Exception { // tag::setup-TargetAudienceNone[] final NoneTargetAudience noneTargetAudience = NoneTargetAudience.create(); final MessengerSettings messengerSettings = MessengerSettings.create( empty(), empty(), empty(), empty(), empty(), empty(), of(noneTargetAudience)); messenger.updateSettings(messengerSettings); // end::setup-TargetAudienceNone[] // then final ArgumentCaptor<String> payloadCaptor = ArgumentCaptor.forClass(String.class); final String expectedJsonBody = "{\n" + " \"target_audience\":{\n" + " \"audience_type\":\"none\"" + " }" + "}"; verify(mockHttpClient).execute(eq(POST), endsWith(PAGE_ACCESS_TOKEN), payloadCaptor.capture()); JSONAssert.assertEquals(expectedJsonBody, payloadCaptor.getValue(), true); }
Example 7
Source File: MappingJackson2HttpMessageConverterTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void readAndWriteParameterizedType() throws Exception { ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {}; String body = "[{" + "\"bytes\":\"AQI=\"," + "\"array\":[\"Foo\",\"Bar\"]," + "\"number\":42," + "\"string\":\"Foo\"," + "\"bool\":true," + "\"fraction\":42.0}]"; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8")); inputMessage.getHeaders().setContentType(new MediaType("application", "json")); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); List<MyBean> results = (List<MyBean>) converter.read(beansList.getType(), null, inputMessage); assertEquals(1, results.size()); MyBean result = results.get(0); assertEquals("Foo", result.getString()); assertEquals(42, result.getNumber()); assertEquals(42F, result.getFraction(), 0F); assertArrayEquals(new String[] {"Foo", "Bar"}, result.getArray()); assertTrue(result.isBool()); assertArrayEquals(new byte[] {0x1, 0x2}, result.getBytes()); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(results, beansList.getType(), new MediaType("application", "json"), outputMessage); JSONAssert.assertEquals(body, outputMessage.getBodyAsString(StandardCharsets.UTF_8), true); }
Example 8
Source File: JsonCollectionAsMemberTest.java From testfun with Apache License 2.0 | 5 votes |
@Test public void listOfSizeOne() throws JSONException { JSONAssert.assertEquals( "{\"collection\":[{\"str\":\"0\",\"num\":0}]}", getCollection(1), JSONCompareMode.LENIENT ); }
Example 9
Source File: DataExportEngineTest.java From TomboloDigitalConnector with MIT License | 5 votes |
@Test public void testReturnsSubjectAndValuesByTimeForAttribute() throws Exception { Attribute attribute = TestFactory.makeAttribute(TestFactory.DEFAULT_PROVIDER, "attr_label"); TestFactory.makeTimedValue(lsoa, "E01000001", attribute, "2011-01-01T00:00", 100d); builder.addSubjectSpecification( new SubjectSpecificationBuilder(AbstractONSImporter.PROVIDER.getLabel(), "lsoa").setMatcher("label", "E01000001") ).addFieldSpecification( FieldBuilder.wrapperField("attributes", Arrays.asList( FieldBuilder.valuesByTime("default_provider_label", "attr_label") )) ); engine.execute(builder.build(), writer, emptyImporterMatcher); JSONAssert.assertEquals("{" + " features: [" + " {" + " properties: {" + " name: 'City of London 001A'," + " attributes: {" + " attr_label: [" + " {" + " value: 100.0," + " timestamp: '2011-01-01T00:00:00'" + " }" + " ]" + " }," + " label: 'E01000001'" + " }" + " }" + " ]" + "}", writer.toString(), false); }
Example 10
Source File: RoadEndpointsIntegrationTest.java From data-highway with Apache License 2.0 | 5 votes |
private void assertJsonEquals(String expected, String actual) { try { JSONAssert.assertEquals(expected, actual, false); } catch (JSONException e) { throw new RuntimeException(e); } }
Example 11
Source File: DittoBsonJsonTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void serializeJsonWithDotsInKeys() throws JSONException { final BsonDocument parse = BsonDocument.parse(JSON_WITH_DOTS_INKEYS); final JsonValue serialized = underTest.serialize(parse); JSONAssert.assertEquals(JSON_WITH_DOTS_INKEYS, serialized.toString(), true); }
Example 12
Source File: CommonGTest.java From bdt with Apache License 2.0 | 5 votes |
@Test public void modifyDataArrayAddObjectTest() throws Exception{ String data = "[{\"businessAssets\":{\"id\":1},\"metadataPath\":\"\",\"description\":\"\",\"id\":-1,\"name\":\"\"}]"; String expectedData = "[{\"businessAssets\":{\"id\":1},\"metadataPath\":\"\",\"description\":\"\",\"id\":-1,\"name\":\"\",\"key\":{}}]"; CommonG commong = new CommonG(); String type = "json"; List<List<String>> rawData = Arrays.asList(Arrays.asList("$.[0].key", "ADD", "{}", "object")); DataTable modifications = DataTable.create(rawData); String modifiedData = commong.modifyData(data, type, modifications); JSONAssert.assertEquals(expectedData, modifiedData, false); }
Example 13
Source File: ImprovedigitalTest.java From prebid-server-java with Apache License 2.0 | 5 votes |
@Test public void openrtb2AuctionShouldRespondWithBidsFromImproveDigital() throws IOException, JSONException { // given // Improvedigital bid response for imp 001 WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/improvedigital-exchange")) .withRequestBody(equalToJson( jsonFrom("openrtb2/improvedigital/test-improvedigital-bid-request-1.json"))) .willReturn(aResponse().withBody( jsonFrom("openrtb2/improvedigital/test-improvedigital-bid-response-1.json")))); // pre-bid cache WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache")) .withRequestBody(equalToJson( jsonFrom("openrtb2/improvedigital/test-cache-improvedigital-request.json"))) .willReturn(aResponse().withBody( jsonFrom("openrtb2/improvedigital/test-cache-improvedigital-response.json")))); // when final Response response = given(SPEC) .header("Referer", "http://www.example.com") .header("X-Forwarded-For", "193.168.244.1") .header("User-Agent", "userAgent") .header("Origin", "http://www.example.com") // this uids cookie value stands for {"uids":{"improvedigital":"ID-UID"}} .cookie("uids", "eyJ1aWRzIjp7ImltcHJvdmVkaWdpdGFsIjoiSUQtVUlEIn19") .body(jsonFrom("openrtb2/improvedigital/test-auction-improvedigital-request.json")) .post("/openrtb2/auction"); // then final String expectedAuctionResponse = openrtbAuctionResponseFrom( "openrtb2/improvedigital/test-auction-improvedigital-response.json", response, singletonList("improvedigital")); JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE); }
Example 14
Source File: AdvangelistsTest.java From prebid-server-java with Apache License 2.0 | 5 votes |
@Test public void openrtb2AuctionShouldRespondWithBidsFromAdvangelists() throws IOException, JSONException { // given // advangelists bid response for imp WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/advangelists-exchange")) .withQueryParam("pubid", equalTo("19f1b372c7548ec1fe734d2c9f8dc688")) .withHeader("Content-Type", equalToIgnoreCase("application/json;charset=UTF-8")) .withHeader("Accept", equalTo("application/json")) .withHeader("x-openrtb-version", equalTo("2.5")) .withRequestBody(equalToJson(jsonFrom("openrtb2/advangelists/test-advangelists-bid-request.json"))) .willReturn(aResponse().withBody( jsonFrom("openrtb2/advangelists/test-advangelists-bid-response.json")))); // pre-bid cache WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache")) .withRequestBody(equalToJson(jsonFrom("openrtb2/advangelists/test-cache-advangelists-request.json"))) .willReturn(aResponse().withBody( jsonFrom("openrtb2/advangelists/test-cache-advangelists-response.json")))); // when final Response response = given(SPEC) .header("Referer", "http://www.example.com") .header("X-Forwarded-For", "193.168.244.1") .header("User-Agent", "userAgent") .header("Origin", "http://www.example.com") // this uids cookie value stands for {"uids":{"advangelists":"AV-UID"}} .cookie("uids", "eyJ1aWRzIjp7ImFkdmFuZ2VsaXN0cyI6IkFWLVVJRCJ9fQ==") .body(jsonFrom("openrtb2/advangelists/test-auction-advangelists-request.json")) .post("/openrtb2/auction"); // then final String expectedAuctionResponse = openrtbAuctionResponseFrom( "openrtb2/advangelists/test-auction-advangelists-response.json", response, singletonList("advangelists")); JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE); }
Example 15
Source File: MappingJackson2HttpMessageConverterTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void writeParameterizedBaseType() throws Exception { ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {}; ParameterizedTypeReference<List<MyBase>> baseList = new ParameterizedTypeReference<List<MyBase>>() {}; String body = "[{" + "\"bytes\":\"AQI=\"," + "\"array\":[\"Foo\",\"Bar\"]," + "\"number\":42," + "\"string\":\"Foo\"," + "\"bool\":true," + "\"fraction\":42.0}]"; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8")); inputMessage.getHeaders().setContentType(new MediaType("application", "json")); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); List<MyBean> results = (List<MyBean>) converter.read(beansList.getType(), null, inputMessage); assertEquals(1, results.size()); MyBean result = results.get(0); assertEquals("Foo", result.getString()); assertEquals(42, result.getNumber()); assertEquals(42F, result.getFraction(), 0F); assertArrayEquals(new String[] {"Foo", "Bar"}, result.getArray()); assertTrue(result.isBool()); assertArrayEquals(new byte[] {0x1, 0x2}, result.getBytes()); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(results, baseList.getType(), new MediaType("application", "json"), outputMessage); JSONAssert.assertEquals(body, outputMessage.getBodyAsString(StandardCharsets.UTF_8), true); }
Example 16
Source File: CpmStarTest.java From prebid-server-java with Apache License 2.0 | 5 votes |
@Test public void openrtb2AuctionShouldRespondWithBidsFromCPMStar() throws IOException, JSONException { // given // Cpmstar bid response WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cpmstar-exchange")) .withHeader("Accept", equalTo("application/json")) .withHeader("Content-Type", equalTo("application/json;charset=UTF-8")) .withRequestBody(equalToJson(jsonFrom("openrtb2/cpmstar/test-cpmstar-bid-request-1.json"))) .willReturn(aResponse().withBody(jsonFrom("openrtb2/cpmstar/test-cpmstar-bid-response-1.json")))); // pre-bid cache WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache")) .withRequestBody(equalToJson(jsonFrom("openrtb2/cpmstar/test-cache-cpmstar-request.json"))) .willReturn(aResponse().withBody(jsonFrom("openrtb2/cpmstar/test-cache-cpmstar-response.json")))); // when final Response response = given(SPEC) .header("Referer", "http://www.example.com") .header("X-Forwarded-For", "193.168.244.1") .header("User-Agent", "userAgent") .header("Origin", "http://www.example.com") .cookie("uids", "eyJ1aWRzIjp7ImNwbXN0YXIiOiJDUy1VSUQifX0=") .body(jsonFrom("openrtb2/cpmstar/test-auction-cpmstar-request.json")) .post("/openrtb2/auction"); // then final String expectedAuctionResponse = openrtbAuctionResponseFrom( "openrtb2/cpmstar/test-auction-cpmstar-response.json", response, singletonList("cpmstar")); JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), JSONCompareMode.NON_EXTENSIBLE); }
Example 17
Source File: GetProfileMetadataExecutorTest.java From docker-elastic-agents-plugin with Apache License 2.0 | 4 votes |
@Test public void assertJsonStructure() throws Exception { GoPluginApiResponse response = new GetProfileMetadataExecutor().execute(); assertThat(response.responseCode(), is(200)); String expectedJSON = "[\n" + " {\n" + " \"key\": \"Image\",\n" + " \"metadata\": {\n" + " \"required\": true,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"Command\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"Environment\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"ReservedMemory\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"MaxMemory\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"Cpus\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"Mounts\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"Hosts\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " },\n" + " {\n" + " \"key\": \"Privileged\",\n" + " \"metadata\": {\n" + " \"required\": false,\n" + " \"secure\": false\n" + " }\n" + " }\n" + "]"; JSONAssert.assertEquals(expectedJSON, response.responseBody(), true); }
Example 18
Source File: SecureLdapIT.java From nifi-registry with Apache License 2.0 | 4 votes |
@Test public void testTokenGenerationAndAccessStatus() throws Exception { // Note: this test intentionally does not use the token generated // for nifiadmin by the @Before method // Given: the client and server have been configured correctly for LDAP authentication String expectedJwtPayloadJson = "{" + "\"sub\":\"nobel\"," + "\"preferred_username\":\"nobel\"," + "\"iss\":\"LdapIdentityProvider\"" + "}"; String expectedAccessStatusJson = "{" + "\"identity\":\"nobel\"," + "\"anonymous\":false" + "}"; // When: the /access/token/login endpoint is queried final String basicAuthCredentials = encodeCredentialsForBasicAuth("nobel", "password"); final Response tokenResponse = client .target(createURL(tokenIdentityProviderPath)) .request() .header("Authorization", "Basic " + basicAuthCredentials) .post(null, Response.class); // Then: the server returns 200 OK with an access token assertEquals(201, tokenResponse.getStatus()); String token = tokenResponse.readEntity(String.class); assertTrue(StringUtils.isNotEmpty(token)); String[] jwtParts = token.split("\\."); assertEquals(3, jwtParts.length); String jwtPayload = new String(Base64.getDecoder().decode(jwtParts[1]), "UTF-8"); JSONAssert.assertEquals(expectedJwtPayloadJson, jwtPayload, false); // When: the token is returned in the Authorization header final Response accessResponse = client .target(createURL("access")) .request() .header("Authorization", "Bearer " + token) .get(Response.class); // Then: the server acknowledges the client has access assertEquals(200, accessResponse.getStatus()); String accessStatus = accessResponse.readEntity(String.class); JSONAssert.assertEquals(expectedAccessStatusJson, accessStatus, false); }
Example 19
Source File: JsonSerializationIT.java From camunda-external-task-client-java with Apache License 2.0 | 4 votes |
@Test public void shoudSetVariable() throws JSONException { // given engineRule.startProcessInstance(processDefinition.getId()); client.subscribe(EXTERNAL_TASK_TOPIC_FOO) .handler(invocationHandler) .open(); clientRule.waitForFetchAndLockUntil(() -> !invocationHandler.getInvocations().isEmpty()); RecordedInvocation invocation = invocationHandler.getInvocations().get(0); ExternalTask fooTask = invocation.getExternalTask(); ExternalTaskService fooService = invocation.getExternalTaskService(); client.subscribe(EXTERNAL_TASK_TOPIC_BAR) .handler(handler) .open(); // when Map<String, Object> variables = Variables.createVariables(); variables.put(VARIABLE_NAME_JSON, VARIABLE_VALUE_JSON_DESERIALIZED); fooService.complete(fooTask, variables); // then clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty()); ExternalTask task = handler.getHandledTasks().get(0); ObjectValue serializedValue = task.getVariableTyped(VARIABLE_NAME_JSON, false); assertThat(serializedValue.isDeserialized()).isFalse(); JSONAssert.assertEquals(VARIABLE_VALUE_JSON_SERIALIZED, new String(serializedValue.getValueSerialized()), true); assertThat(serializedValue.getType()).isEqualTo(OBJECT); assertThat(serializedValue.getObjectTypeName()).isEqualTo(JsonSerializable.class.getName()); ObjectValue deserializedValue = task.getVariableTyped(VARIABLE_NAME_JSON); assertThat(deserializedValue.isDeserialized()).isTrue(); assertThat(deserializedValue.getValue()).isEqualTo(VARIABLE_VALUE_JSON_DESERIALIZED); assertThat(deserializedValue.getType()).isEqualTo(OBJECT); assertThat(deserializedValue.getObjectTypeName()).isEqualTo(JsonSerializable.class.getName()); JsonSerializable variableValue = task.getVariable(VARIABLE_NAME_JSON); assertThat(variableValue).isEqualTo(VARIABLE_VALUE_JSON_DESERIALIZED); }
Example 20
Source File: JsonExpectationsHelper.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Parse the expected and actual strings as JSON and assert the two * are "similar" - i.e. they contain the same attribute-value pairs * regardless of formatting. * * <p>Can compare in two modes, depending on {@code strict} parameter value: * <ul> * <li>{@code true}: strict checking. Not extensible, and strict array ordering.</li> * <li>{@code false}: lenient checking. Extensible, and non-strict array ordering.</li> * </ul> * * @param expected the expected JSON content * @param actual the actual JSON content * @param strict enables strict checking * @since 4.2 */ public void assertJsonEqual(String expected, String actual, boolean strict) throws Exception { JSONAssert.assertEquals(expected, actual, strict); }