Search in sources :

Example 11 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class GetServiceInstanceRouteBindingResponseTest method responseWithValuesIsBuilt.

@Test
@SuppressWarnings("serial")
public void responseWithValuesIsBuilt() {
    Map<String, Object> parameters = new HashMap<String, Object>() {

        {
            put("field4", "value4");
            put("field5", "value5");
        }
    };
    GetServiceInstanceRouteBindingResponse response = GetServiceInstanceRouteBindingResponse.builder().parameters("field1", "value1").parameters("field2", 2).parameters("field3", true).parameters(parameters).routeServiceUrl("https://routes.example.com").build();
    assertThat(response.getParameters()).hasSize(5);
    assertThat(response.getParameters().get("field1")).isEqualTo("value1");
    assertThat(response.getParameters().get("field2")).isEqualTo(2);
    assertThat(response.getParameters().get("field3")).isEqualTo(true);
    assertThat(response.getParameters().get("field4")).isEqualTo("value4");
    assertThat(response.getParameters().get("field5")).isEqualTo("value5");
    assertThat(response.getRouteServiceUrl()).isEqualTo("https://routes.example.com");
    DocumentContext json = JsonUtils.toJsonPath(response);
    assertThat(json).hasPath("$.parameters.field1").isEqualTo("value1");
    assertThat(json).hasPath("$.parameters.field2").isEqualTo(2);
    assertThat(json).hasPath("$.parameters.field3").isEqualTo(true);
    assertThat(json).hasPath("$.parameters.field4").isEqualTo("value4");
    assertThat(json).hasPath("$.parameters.field5").isEqualTo("value5");
    assertThat(json).hasPath("$.route_service_url").isEqualTo("https://routes.example.com");
}
Also used : HashMap(java.util.HashMap) DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 12 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class GetServiceInstanceRouteBindingResponseTest method responseWithDefaultsIsBuilt.

@Test
public void responseWithDefaultsIsBuilt() {
    GetServiceInstanceRouteBindingResponse response = GetServiceInstanceRouteBindingResponse.builder().build();
    assertThat(response.getRouteServiceUrl()).isNull();
    DocumentContext json = JsonUtils.toJsonPath(response);
    assertThat(json).hasNoPath("$.parameters");
    assertThat(json).hasNoPath("$.route_service_url");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 13 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class VolumeMountTest method volumeMountIsBuiltWithAllValues.

@Test
@SuppressWarnings("serial")
public void volumeMountIsBuiltWithAllValues() {
    Map<String, Object> config = new HashMap<String, Object>() {

        {
            put("config3", "value3");
            put("config4", true);
        }
    };
    VolumeMount mount = VolumeMount.builder().driver("test-driver").containerDir("/data/images").mode(READ_ONLY).deviceType(SHARED).device(SharedVolumeDevice.builder().volumeId("volume-id").mountConfig("config1", "value1").mountConfig("config2", 2).mountConfig(config).build()).build();
    assertThat(mount.getDriver()).isEqualTo("test-driver");
    assertThat(mount.getContainerDir()).isEqualTo("/data/images");
    assertThat(mount.getMode()).isEqualTo(READ_ONLY);
    assertThat(mount.getDeviceType()).isEqualTo(SHARED);
    SharedVolumeDevice device = (SharedVolumeDevice) mount.getDevice();
    assertThat(device.getVolumeId()).isEqualTo("volume-id");
    assertThat(device.getMountConfig()).hasSize(4);
    assertThat(device.getMountConfig().get("config1")).isEqualTo("value1");
    assertThat(device.getMountConfig().get("config2")).isEqualTo(2);
    assertThat(device.getMountConfig().get("config3")).isEqualTo("value3");
    assertThat(device.getMountConfig().get("config4")).isEqualTo(true);
    DocumentContext json = JsonUtils.toJsonPath(mount);
    assertThat(json).hasPath("$.driver").isEqualTo("test-driver");
    assertThat(json).hasPath("$.container_dir").isEqualTo("/data/images");
    assertThat(json).hasPath("$.mode").isEqualTo("r");
    assertThat(json).hasPath("$.device_type").isEqualTo("shared");
    assertThat(json).hasPath("$.device.volume_id").isEqualTo("volume-id");
    assertThat(json).hasPath("$.device.mount_config.config1").isEqualTo("value1");
    assertThat(json).hasPath("$.device.mount_config.config2").isEqualTo(2);
    assertThat(json).hasPath("$.device.mount_config.config3").isEqualTo("value3");
    assertThat(json).hasPath("$.device.mount_config.config4").isEqualTo(true);
}
Also used : HashMap(java.util.HashMap) DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 14 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class VolumeMountTest method volumeMountIsBuiltWithDefaults.

@Test
public void volumeMountIsBuiltWithDefaults() {
    VolumeMount mount = VolumeMount.builder().build();
    assertThat(mount.getDriver()).isNull();
    assertThat(mount.getContainerDir()).isNull();
    assertThat(mount.getMode()).isNull();
    assertThat(mount.getDeviceType()).isNull();
    assertThat(mount.getDevice()).isNull();
    DocumentContext json = JsonUtils.toJsonPath(mount);
    assertThat(json).hasNoPath("$.driver");
    assertThat(json).hasNoPath("$.container_dir");
    assertThat(json).hasNoPath("$.mode");
    assertThat(json).hasNoPath("$.device_type");
    assertThat(json).hasNoPath("$.device");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 15 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class CatalogTest method emptyCatalogIsSerializedToJson.

@Test
public void emptyCatalogIsSerializedToJson() {
    Catalog catalog = Catalog.builder().build();
    assertThat(catalog.getServiceDefinitions()).hasSize(0);
    DocumentContext json = JsonUtils.toJsonPath(catalog);
    assertThat(json).hasListAtPath("$.services").hasSize(0);
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Aggregations

DocumentContext (com.jayway.jsonpath.DocumentContext)150 Test (org.junit.Test)106 HashMap (java.util.HashMap)14 BaseTest (com.jayway.jsonpath.BaseTest)12 Map (java.util.Map)12 PathNotFoundException (com.jayway.jsonpath.PathNotFoundException)9 JsonPath (com.jayway.jsonpath.JsonPath)7 File (java.io.File)7 List (java.util.List)7 JsonPathAssert (com.revinate.assertj.json.JsonPathAssert)6 Query (org.graylog.plugins.views.search.Query)6 MessageList (org.graylog.plugins.views.search.searchtypes.MessageList)6 Time (org.graylog.plugins.views.search.searchtypes.pivot.buckets.Time)6 Values (org.graylog.plugins.views.search.searchtypes.pivot.buckets.Values)6 DateTime (org.joda.time.DateTime)6 Configuration (com.jayway.jsonpath.Configuration)5 ArrayList (java.util.ArrayList)5 Test (org.junit.jupiter.api.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 IOException (java.io.IOException)4