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");
}
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");
}
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);
}
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");
}
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);
}
Aggregations