Search in sources :

Example 26 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class GetServiceInstanceAppBindingResponseTest method responseWithDefaultsIsBuilt.

@Test
public void responseWithDefaultsIsBuilt() {
    GetServiceInstanceAppBindingResponse response = GetServiceInstanceAppBindingResponse.builder().build();
    assertThat(response.getParameters()).hasSize(0);
    assertThat(response.getCredentials()).hasSize(0);
    assertThat(response.getSyslogDrainUrl()).isNull();
    assertThat(response.getVolumeMounts()).hasSize(0);
    DocumentContext json = JsonUtils.toJsonPath(response);
    assertThat(json).hasNoPath("$.parameters");
    assertThat(json).hasNoPath("$.credentials");
    assertThat(json).hasNoPath("$.syslog_drain_url");
    assertThat(json).hasNoPath("$.volume_mounts");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 27 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class GetServiceInstanceAppBindingResponseTest method responseWithDiscreteValuesIsBuilt.

@Test
@SuppressWarnings("serial")
public void responseWithDiscreteValuesIsBuilt() {
    Map<String, Object> parameters = new HashMap<String, Object>() {

        {
            put("field4", "value4");
            put("field5", "value5");
        }
    };
    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());
    GetServiceInstanceAppBindingResponse response = GetServiceInstanceAppBindingResponse.builder().parameters("field1", "value1").parameters("field2", 2).parameters("field3", true).parameters(parameters).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.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.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("$.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("$.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)

Example 28 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class GetServiceInstanceResponseTest method responseWithDefaultsIsBuilt.

@Test
public void responseWithDefaultsIsBuilt() {
    GetServiceInstanceResponse response = GetServiceInstanceResponse.builder().build();
    assertThat(response.getServiceDefinitionId()).isNull();
    assertThat(response.getPlanId()).isNull();
    assertThat(response.getDashboardUrl()).isNull();
    assertThat(response.getParameters()).hasSize(0);
    DocumentContext json = JsonUtils.toJsonPath(response);
    assertThat(json).hasNoPath("$.service_id");
    assertThat(json).hasNoPath("$.plan_id");
    assertThat(json).hasNoPath("$.dashboard_url");
    assertThat(json).hasMapAtPath("$.parameters").hasSize(0);
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 29 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class GetServiceInstanceResponseTest method responseWithAllValuesIsBuilt.

@Test
@SuppressWarnings("serial")
public void responseWithAllValuesIsBuilt() {
    Map<String, Object> parameters = new HashMap<String, Object>() {

        {
            put("field4", "value4");
            put("field5", "value5");
        }
    };
    GetServiceInstanceResponse response = GetServiceInstanceResponse.builder().serviceDefinitionId("service-definition-id").planId("plan-id").dashboardUrl("https://dashboard.example.com").parameters("field1", "value1").parameters("field2", 2).parameters("field3", true).parameters(parameters).build();
    assertThat(response.getServiceDefinitionId()).isEqualTo("service-definition-id");
    assertThat(response.getPlanId()).isEqualTo("plan-id");
    assertThat(response.getDashboardUrl()).isEqualTo("https://dashboard.example.com");
    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");
    DocumentContext json = JsonUtils.toJsonPath(response);
    assertThat(json).hasPath("$.service_id").isEqualTo("service-definition-id");
    assertThat(json).hasPath("$.plan_id").isEqualTo("plan-id");
    assertThat(json).hasPath("$.dashboard_url").isEqualTo("https://dashboard.example.com");
    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");
}
Also used : HashMap(java.util.HashMap) DocumentContext(com.jayway.jsonpath.DocumentContext) Test(org.junit.Test)

Example 30 with DocumentContext

use of com.jayway.jsonpath.DocumentContext in project spring-cloud-open-service-broker by spring-cloud.

the class UpdateServiceInstanceResponseTest method responseWithDefaultsIsBuilt.

@Test
public void responseWithDefaultsIsBuilt() {
    UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().build();
    assertThat(response.isAsync()).isEqualTo(false);
    assertThat(response.getOperation()).isNull();
    DocumentContext json = JsonUtils.toJsonPath(response);
    assertThat(json).hasNoPath("$.operation");
}
Also used : 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