use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class CreateServiceInstanceRouteBindingResponseTest method responseWithValuesIsBuilt.
@Test
public void responseWithValuesIsBuilt() {
CreateServiceInstanceRouteBindingResponse response = CreateServiceInstanceRouteBindingResponse.builder().bindingExisted(true).routeServiceUrl("https://routes.example.com").build();
assertThat(response.isBindingExisted()).isEqualTo(true);
assertThat(response.getRouteServiceUrl()).isEqualTo("https://routes.example.com");
DocumentContext json = JsonUtils.toJsonPath(response);
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 CatalogTest method catalogWithServicesIsSerializedToJson.
@Test
public void catalogWithServicesIsSerializedToJson() {
List<ServiceDefinition> serviceDefinitions = Collections.singletonList(ServiceDefinition.builder().id("service-definition-id-two").name("service-definition-two").description("Service Definition Two").plans(Plan.builder().build()).build());
Catalog catalog = Catalog.builder().serviceDefinitions(ServiceDefinition.builder().id("service-definition-id-one").name("service-definition-one").description("Service Definition One").plans(Plan.builder().build()).build()).serviceDefinitions(serviceDefinitions).build();
List<ServiceDefinition> actualDefinitions = catalog.getServiceDefinitions();
assertThat(actualDefinitions.get(0).getId()).isEqualTo("service-definition-id-one");
assertThat(actualDefinitions.get(0).getName()).isEqualTo("service-definition-one");
assertThat(actualDefinitions.get(0).getDescription()).isEqualTo("Service Definition One");
assertThat(actualDefinitions.get(1).getId()).isEqualTo("service-definition-id-two");
assertThat(actualDefinitions.get(1).getName()).isEqualTo("service-definition-two");
assertThat(actualDefinitions.get(1).getDescription()).isEqualTo("Service Definition Two");
DocumentContext json = JsonUtils.toJsonPath(catalog);
assertThat(json).hasListAtPath("$.services").hasSize(2);
assertThat(json).hasPath("$.services[0].id").isEqualTo("service-definition-id-one");
assertThat(json).hasPath("$.services[0].name").isEqualTo("service-definition-one");
assertThat(json).hasPath("$.services[0].description").isEqualTo("Service Definition One");
assertThat(json).hasPath("$.services[1].id").isEqualTo("service-definition-id-two");
assertThat(json).hasPath("$.services[1].name").isEqualTo("service-definition-two");
assertThat(json).hasPath("$.services[1].description").isEqualTo("Service Definition Two");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class DashboardClientTest method dashboardClientIsBuiltWithAllValues.
@Test
public void dashboardClientIsBuiltWithAllValues() {
DashboardClient client = DashboardClient.builder().id("client-id").secret("client-secret").redirectUri("https://token.example.com").build();
assertThat(client.getId()).isEqualTo("client-id");
assertThat(client.getSecret()).isEqualTo("client-secret");
assertThat(client.getRedirectUri()).isEqualTo("https://token.example.com");
DocumentContext json = JsonUtils.toJsonPath(client);
assertThat(json).hasPath("$.id").isEqualTo("client-id");
assertThat(json).hasPath("$.secret").isEqualTo("client-secret");
assertThat(json).hasPath("$.redirect_uri").isEqualTo("https://token.example.com");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class PlanTest method planWithDefaultsIsSerializedToJson.
@Test
public void planWithDefaultsIsSerializedToJson() {
Plan plan = Plan.builder().id("plan-id-one").name("plan-one").description("Plan One").build();
assertThat(plan.getId()).isEqualTo("plan-id-one");
assertThat(plan.getName()).isEqualTo("plan-one");
assertThat(plan.getDescription()).isEqualTo("Plan One");
assertThat(plan.isFree()).isEqualTo(true);
assertThat(plan.isBindable()).isNull();
assertThat(plan.getMetadata()).isNull();
assertThat(plan.getSchemas()).isNull();
DocumentContext json = JsonUtils.toJsonPath(plan);
assertThat(json).hasPath("$.id").isEqualTo("plan-id-one");
assertThat(json).hasPath("$.name").isEqualTo("plan-one");
assertThat(json).hasPath("$.description").isEqualTo("Plan One");
assertThat(json).hasPath("$.free").isEqualTo(true);
assertThat(json).hasNoPath("$.bindable");
assertThat(json).hasNoPath("$.metadata");
assertThat(json).hasNoPath("$.schemas");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class SchemasTest method emptySchemasIsSerializedToJson.
@Test
public void emptySchemasIsSerializedToJson() {
Schemas schemas = Schemas.builder().serviceInstanceSchema(ServiceInstanceSchema.builder().build()).serviceBindingSchema(ServiceBindingSchema.builder().build()).build();
assertThat(schemas.getServiceInstanceSchema().getCreateMethodSchema()).isNull();
assertThat(schemas.getServiceInstanceSchema().getUpdateMethodSchema()).isNull();
assertThat(schemas.getServiceBindingSchema().getCreateMethodSchema()).isNull();
DocumentContext json = JsonUtils.toJsonPath(schemas);
assertThat(json).hasPath("$.service_instance");
assertThat(json).hasNoPath("$.service_instance.create");
assertThat(json).hasNoPath("$.service_instance.update");
assertThat(json).hasPath("$.service_binding");
assertThat(json).hasNoPath("$.service_binding.create");
}
Aggregations