Search in sources :

Example 96 with DocumentContext

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

Example 97 with DocumentContext

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

Example 98 with DocumentContext

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

Example 99 with DocumentContext

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

Example 100 with DocumentContext

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

Aggregations

DocumentContext (com.jayway.jsonpath.DocumentContext)146 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)8 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 InvalidJsonException (com.jayway.jsonpath.InvalidJsonException)4