Search in sources :

Example 21 with DocumentContext

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");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 22 with DocumentContext

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");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 23 with DocumentContext

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");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 24 with DocumentContext

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");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 25 with DocumentContext

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);
}
Also used : HashMap(java.util.HashMap) 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