Java Examples for org.springframework.boot.test.json.JsonContent

The following java examples will help you to understand the usage of org.springframework.boot.test.json.JsonContent. These source code samples are taken from different open source projects.

Example 1
Project: find-master  File: TrendingWidgetTest.java View source code
@Override
protected void validateJson(final JsonContent<TrendingWidget> jsonContent) {
    jsonContent.assertThat().hasJsonPathStringValue("$.name", "Test Widget").hasJsonPathStringValue("$.type", "TrendingWidget").hasJsonPathNumberValue("$.x", 1).hasJsonPathNumberValue("$.y", 1).hasJsonPathNumberValue("$.width", 1).hasJsonPathNumberValue("$.height", 1).hasJsonPathNumberValue("$.datasource.config.id", 123).hasJsonPathStringValue("$.datasource.config.type", "QUERY").hasJsonPathStringValue("$.widgetSettings.parametricField", "/DOCUMENT/CONTENT_TYPE").hasJsonPathStringValue("$.widgetSettings.dateField", "/DOCUMENT/AUTN_DATE").hasJsonPathNumberValue("$.widgetSettings.maxValues", 5).hasJsonPathStringValue("$.widgetSettings.maxDate", "2010-04-05T00:00:00Z").hasJsonPathStringValue("$.widgetSettings.minDate", "2009-04-05T00:00:00Z").hasJsonPathNumberValue("$.widgetSettings.numberOfBuckets", 12);
}
Example 2
Project: spring-boot-master  File: JsonTestIntegrationTests.java View source code
@Test
public void customView() throws Exception {
    ExampleJsonObjectWithView object = new ExampleJsonObjectWithView();
    object.setValue("spring");
    JsonContent<ExampleJsonObjectWithView> content = this.jacksonWithViewJson.forView(ExampleJsonObjectWithView.TestView.class).write(object);
    assertThat(content).doesNotHaveJsonPathValue("id");
    assertThat(content).isEqualToJson("example.json");
}