use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class DashboardClientTest method dashboardClientIsBuiltWithDefaults.
@Test
public void dashboardClientIsBuiltWithDefaults() {
DashboardClient client = DashboardClient.builder().build();
assertThat(client.getId()).isNull();
assertThat(client.getSecret()).isNull();
assertThat(client.getRedirectUri()).isNull();
DocumentContext json = JsonUtils.toJsonPath(client);
assertThat(json).hasNoPath("$.id");
assertThat(json).hasNoPath("$.secret");
assertThat(json).hasNoPath("$.redirect_uri");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class PlanTest method planWithAllFieldsIsSerializedToJson.
@Test
@SuppressWarnings("serial")
public void planWithAllFieldsIsSerializedToJson() {
Map<String, Object> metadata = new HashMap<String, Object>() {
{
put("field3", "value3");
put("field4", "value4");
}
};
Plan plan = Plan.builder().id("plan-id-one").name("plan-one").description("Plan One").free(false).bindable(true).metadata("field1", "value1").metadata("field2", "value2").metadata(metadata).schemas(Schemas.builder().build()).build();
assertThat(plan.getId()).isEqualTo("plan-id-one");
assertThat(plan.getName()).isEqualTo("plan-one");
assertThat(plan.getDescription()).isEqualTo("Plan One");
assertThat(plan.isFree()).isEqualTo(false);
assertThat(plan.isBindable()).isEqualTo(true);
assertThat(plan.getMetadata()).hasSize(4);
assertThat(plan.getMetadata()).contains(entry("field1", "value1"), entry("field2", "value2"), entry("field3", "value3"), entry("field4", "value4"));
assertThat(plan.getSchemas()).isNotNull();
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(false);
assertThat(json).hasPath("$.bindable").isEqualTo(true);
assertThat(json).hasMapAtPath("$.metadata").contains(entry("field1", "value1"), entry("field2", "value2"), entry("field3", "value3"), entry("field4", "value4"));
assertThat(json).hasPath("$.schemas");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class SchemasTest method allSchemaFieldsIsSerializedToJson.
@Test
@SuppressWarnings("serial")
public void allSchemaFieldsIsSerializedToJson() {
Map<String, Object> schemaProperties = new HashMap<String, Object>() {
{
put("properties", new HashMap<String, Object>() {
{
put("billing-account", new HashMap<String, String>() {
{
put("description", "Billing account number.");
put("type", "string");
}
});
}
});
}
};
Schemas schemas = Schemas.builder().serviceInstanceSchema(ServiceInstanceSchema.builder().createMethodSchema(MethodSchema.builder().parameters("$schema", "http://example.com/service/create/schema").parameters("type", "object").parameters(schemaProperties).build()).updateMethodSchema(MethodSchema.builder().parameters("$schema", "http://example.com/service/update/schema").parameters("type", "object").build()).build()).serviceBindingSchema(ServiceBindingSchema.builder().createMethodSchema(MethodSchema.builder().parameters("$schema", "http://example.com/binding/create/schema").parameters("type", "object").build()).build()).build();
assertThat(schemas.getServiceInstanceSchema().getCreateMethodSchema().getParameters().get("$schema")).isEqualTo("http://example.com/service/create/schema");
assertThat(schemas.getServiceInstanceSchema().getCreateMethodSchema().getParameters().get("type")).isEqualTo("object");
assertThat(schemas.getServiceInstanceSchema().getUpdateMethodSchema().getParameters().get("$schema")).isEqualTo("http://example.com/service/update/schema");
assertThat(schemas.getServiceInstanceSchema().getUpdateMethodSchema().getParameters().get("type")).isEqualTo("object");
assertThat(schemas.getServiceBindingSchema().getCreateMethodSchema().getParameters().get("$schema")).isEqualTo("http://example.com/binding/create/schema");
assertThat(schemas.getServiceBindingSchema().getCreateMethodSchema().getParameters().get("type")).isEqualTo("object");
DocumentContext json = JsonUtils.toJsonPath(schemas);
assertThat(json).hasPath("$.service_instance.create.parameters.$schema").isEqualTo("http://example.com/service/create/schema");
assertThat(json).hasPath("$.service_instance.create.parameters.type").isEqualTo("object");
assertThat(json).hasPath("$.service_instance.create.parameters.properties.billing-account.description").isEqualTo("Billing account number.");
assertThat(json).hasPath("$.service_instance.create.parameters.properties.billing-account.type").isEqualTo("string");
assertThat(json).hasMapAtPath("$.service_instance.update.parameters").contains(entry("$schema", "http://example.com/service/update/schema"), entry("type", "object"));
assertThat(json).hasMapAtPath("$.service_binding.create.parameters").contains(entry("$schema", "http://example.com/binding/create/schema"), entry("type", "object"));
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class SchemasTest method noSchemasIsSerializedToJson.
@Test
public void noSchemasIsSerializedToJson() {
Schemas schemas = Schemas.builder().build();
assertThat(schemas.getServiceInstanceSchema()).isNull();
assertThat(schemas.getServiceBindingSchema()).isNull();
DocumentContext json = JsonUtils.toJsonPath(schemas);
assertThat(json).hasNoPath("$.service_instance");
assertThat(json).hasNoPath("$.service_binding");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceDefinitionTest method serviceDefinitionWithAllFieldsIsSerializedToJson.
@Test
@SuppressWarnings("serial")
public void serviceDefinitionWithAllFieldsIsSerializedToJson() {
Map<String, Object> metadata = new HashMap<String, Object>() {
{
put("field3", "value3");
put("field4", "value4");
}
};
ServiceDefinition serviceDefinition = ServiceDefinition.builder().id("service-definition-id-one").name("service-definition-one").description("Service Definition One").plans(Plan.builder().build()).bindable(true).instancesRetrievable(true).bindingsRetrievable(true).tags("tag1", "tag2").metadata("field1", "value1").metadata("field2", "value2").metadata(metadata).requires(SERVICE_REQUIRES_ROUTE_FORWARDING, SERVICE_REQUIRES_SYSLOG_DRAIN, SERVICE_REQUIRES_VOLUME_MOUNT).requires("another_requires").planUpdateable(true).dashboardClient(DashboardClient.builder().build()).build();
assertThat(serviceDefinition.getId()).isEqualTo("service-definition-id-one");
assertThat(serviceDefinition.getName()).isEqualTo("service-definition-one");
assertThat(serviceDefinition.getDescription()).isEqualTo("Service Definition One");
assertThat(serviceDefinition.getPlans()).hasSize(1);
assertThat(serviceDefinition.isBindable()).isEqualTo(true);
assertThat(serviceDefinition.isPlanUpdateable()).isEqualTo(true);
assertThat(serviceDefinition.isInstancesRetrievable()).isEqualTo(true);
assertThat(serviceDefinition.isBindingsRetrievable()).isEqualTo(true);
assertThat(serviceDefinition.getTags()).contains("tag1", "tag2");
assertThat(serviceDefinition.getRequires()).contains(SERVICE_REQUIRES_ROUTE_FORWARDING.toString(), SERVICE_REQUIRES_SYSLOG_DRAIN.toString(), SERVICE_REQUIRES_VOLUME_MOUNT.toString(), "another_requires");
assertThat(serviceDefinition.getMetadata()).contains(entry("field1", "value1"), entry("field2", "value2"), entry("field3", "value3"), entry("field4", "value4"));
assertThat(serviceDefinition.getDashboardClient()).isNotNull();
DocumentContext json = JsonUtils.toJsonPath(serviceDefinition);
assertThat(json).hasPath("$.id").isEqualTo("service-definition-id-one");
assertThat(json).hasPath("$.name").isEqualTo("service-definition-one");
assertThat(json).hasPath("$.description").isEqualTo("Service Definition One");
assertThat(json).hasListAtPath("$.plans").hasSize(1);
assertThat(json).hasPath("$.bindable").isEqualTo(true);
assertThat(json).hasPath("$.plan_updateable").isEqualTo(true);
assertThat(json).hasPath("$.plan_updateable").isEqualTo(true);
assertThat(json).hasPath("$.instances_retrievable").isEqualTo(true);
assertThat(json).hasPath("$.bindings_retrievable").isEqualTo(true);
assertThat(json).hasListAtPath("$.tags[*]").contains("tag1", "tag2");
assertThat(json).hasListAtPath("$.requires[*]").contains(SERVICE_REQUIRES_ROUTE_FORWARDING.toString(), SERVICE_REQUIRES_SYSLOG_DRAIN.toString(), SERVICE_REQUIRES_VOLUME_MOUNT.toString(), "another_requires");
assertThat(json).hasMapAtPath("$.metadata").contains(entry("field1", "value1"), entry("field2", "value2"), entry("field3", "value3"), entry("field4", "value4"));
assertThat(json).hasPath("$.dashboard_client");
}
Aggregations