use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceDefinitionTest method serviceDefinitionWithDefaultsIsSerializedToJson.
@Test
public void serviceDefinitionWithDefaultsIsSerializedToJson() {
ServiceDefinition serviceDefinition = ServiceDefinition.builder().id("service-definition-id-one").name("service-definition-one").description("Service Definition One").plans(Plan.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(false);
assertThat(serviceDefinition.isPlanUpdateable()).isNull();
assertThat(serviceDefinition.isInstancesRetrievable()).isNull();
assertThat(serviceDefinition.isBindingsRetrievable()).isNull();
assertThat(serviceDefinition.getTags()).isNull();
assertThat(serviceDefinition.getRequires()).isNull();
assertThat(serviceDefinition.getMetadata()).isNull();
assertThat(serviceDefinition.getDashboardClient()).isNull();
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(false);
assertThat(json).hasNoPath("$.plan_updateable");
assertThat(json).hasNoPath("$.tags");
assertThat(json).hasNoPath("$.requires");
assertThat(json).hasNoPath("$.metadata");
assertThat(json).hasNoPath("$.dashboard_client");
assertThat(json).hasNoPath("$.instances_retrievable");
assertThat(json).hasNoPath("$.bindings_retrievable");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class ErrorMessageTest method errorWithCodeAndDescriptionIsBuilt.
@Test
public void errorWithCodeAndDescriptionIsBuilt() {
ErrorMessage errorMessage = new ErrorMessage("ErrorCode", "error description");
DocumentContext json = JsonUtils.toJsonPath(errorMessage);
assertThat(json).hasPath("$.error").isEqualTo("ErrorCode");
assertThat(json).hasPath("$.description").isEqualTo("error description");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class CreateServiceInstanceResponseTest method responseWithDefaultsIsBuilt.
@Test
public void responseWithDefaultsIsBuilt() {
CreateServiceInstanceResponse response = CreateServiceInstanceResponse.builder().build();
assertThat(response.isAsync()).isEqualTo(false);
assertThat(response.getOperation()).isNull();
assertThat(response.isInstanceExisted()).isEqualTo(false);
assertThat(response.getDashboardUrl()).isNull();
DocumentContext json = JsonUtils.toJsonPath(response);
assertThat(json).hasNoPath("$.operation");
assertThat(json).hasNoPath("$.dashboard_url");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class CreateServiceInstanceResponseTest method responseWithAllValuesIsBuilt.
@Test
public void responseWithAllValuesIsBuilt() {
CreateServiceInstanceResponse response = CreateServiceInstanceResponse.builder().async(true).operation("in progress").instanceExisted(true).dashboardUrl("http://dashboard.example.com").build();
assertThat(response.isAsync()).isEqualTo(true);
assertThat(response.getOperation()).isEqualTo("in progress");
assertThat(response.isInstanceExisted()).isEqualTo(true);
assertThat(response.getDashboardUrl()).isEqualTo("http://dashboard.example.com");
DocumentContext json = JsonUtils.toJsonPath(response);
assertThat(json).hasPath("$.operation").isEqualTo("in progress");
assertThat(json).hasPath("$.dashboard_url").isEqualTo("http://dashboard.example.com");
}
use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.
the class CreateServiceInstanceAppBindingResponseTest method responseWithDiscreteValuesIsBuilt.
@Test
@SuppressWarnings("serial")
public void responseWithDiscreteValuesIsBuilt() {
Map<String, Object> credentials = new HashMap<String, Object>() {
{
put("credential4", "value4");
put("credential5", "value5");
}
};
List<VolumeMount> volumeMounts = Arrays.asList(VolumeMount.builder().build(), VolumeMount.builder().build());
CreateServiceInstanceAppBindingResponse response = CreateServiceInstanceAppBindingResponse.builder().bindingExisted(true).credentials("credential1", "value1").credentials("credential2", 2).credentials("credential3", true).credentials(credentials).syslogDrainUrl("https://logs.example.com").volumeMounts(VolumeMount.builder().build()).volumeMounts(VolumeMount.builder().build()).volumeMounts(volumeMounts).build();
assertThat(response.isBindingExisted()).isEqualTo(true);
assertThat(response.getCredentials()).hasSize(5);
assertThat(response.getCredentials().get("credential1")).isEqualTo("value1");
assertThat(response.getCredentials().get("credential2")).isEqualTo(2);
assertThat(response.getCredentials().get("credential3")).isEqualTo(true);
assertThat(response.getCredentials().get("credential4")).isEqualTo("value4");
assertThat(response.getCredentials().get("credential5")).isEqualTo("value5");
assertThat(response.getSyslogDrainUrl()).isEqualTo("https://logs.example.com");
assertThat(response.getVolumeMounts()).hasSize(4);
DocumentContext json = JsonUtils.toJsonPath(response);
assertThat(json).hasPath("$.credentials.credential1").isEqualTo("value1");
assertThat(json).hasPath("$.credentials.credential2").isEqualTo(2);
assertThat(json).hasPath("$.credentials.credential3").isEqualTo(true);
assertThat(json).hasPath("$.credentials.credential4").isEqualTo("value4");
assertThat(json).hasPath("$.credentials.credential5").isEqualTo("value5");
assertThat(json).hasPath("$.syslog_drain_url").isEqualTo("https://logs.example.com");
assertThat(json).hasListAtPath("$.volume_mounts").hasSize(4);
}
Aggregations