@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"); }
.id("plan-id-one") .name("plan-one") .description("Plan One") .free(false) .bindable(true)
@Bean public Catalog catalog() { Plan plan = Plan.builder() .id("simple-plan") .name("standard") .description("A simple plan") .free(true) .build(); ServiceDefinition serviceDefinition = ServiceDefinition.builder() .id("example-service") .name("example") .description("A simple example") .bindable(true) .tags("example", "tags") .plans(plan) .build(); return Catalog.builder() .serviceDefinitions(serviceDefinition) .build(); } }
private static Plan getPlanTwo() { Schemas schemas = Schemas.builder() .serviceInstanceSchema(ServiceInstanceSchema.builder() .createMethodSchema(MethodSchema.builder() .parameters("$schema", "http://example.com/service/create/schema") .parameters("type", "object") .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(); return Plan.builder() .id("plan-two-id") .name("Plan Two") .description("Description for Plan Two") .metadata("key1", "value1") .metadata("key2", "value2") .bindable(false) .free(true) .schemas(schemas) .build(); }
/** * Converts this object into its corresponding model * * @return a Plan model * @see org.springframework.cloud.servicebroker.model.catalog.Plan */ public org.springframework.cloud.servicebroker.model.catalog.Plan toModel() { return org.springframework.cloud.servicebroker.model.catalog.Plan.builder() .id(this.id) .name(this.name) .description(this.description) .bindable(this.bindable) .free(this.free) .schemas(this.schemas != null ? this.schemas.toModel() : null) .metadata(this.metadata) .build(); }
private static Plan getPlanOne() { return Plan.builder() .id("plan-one-id") .name("Plan One") .description("Description for Plan One") .build(); }
private Plan getPlan() { return Plan.builder() .id("simple-plan") .name("standard") .description("A simple plan") .free(true) .build(); } }
private static Plan getPlanThree() { return Plan.builder() .id("plan-three-id") .name("Plan Three") .description("Description for Plan Three") .build(); } }