org.springframework.cloud.servicebroker.model.catalog.Catalog Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.model.catalog.Catalog.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatalogConfiguration.java From tutorials with MIT License | 6 votes |
@Bean public Catalog catalog() { Plan mailFreePlan = Plan.builder() .id("fd81196c-a414-43e5-bd81-1dbb082a3c55") .name("mail-free-plan") .description("Mail Service Free Plan") .free(true) .build(); ServiceDefinition serviceDefinition = ServiceDefinition.builder() .id("b92c0ca7-c162-4029-b567-0d92978c0a97") .name("mail-service") .description("Mail Service") .bindable(true) .tags("mail", "service") .plans(mailFreePlan) .build(); return Catalog.builder() .serviceDefinitions(serviceDefinition) .build(); }
Example #2
Source File: ExampleCatalogConfiguration.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@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(); }
Example #3
Source File: ServiceCatalogConfiguration.java From bookstore-service-broker with Apache License 2.0 | 6 votes |
@Bean public Catalog catalog() { Plan plan = Plan.builder() .id("b973fb78-82f3-49ef-9b8b-c1876974a6cd") .name("standard") .description("A simple book store plan") .free(true) .build(); ServiceDefinition serviceDefinition = ServiceDefinition.builder() .id("bdb1be2e-360b-495c-8115-d7697f9c6a9e") .name("bookstore") .description("A simple book store service") .bindable(true) .tags("book-store", "books", "sample") .plans(plan) .metadata("displayName", "bookstore") .metadata("longDescription", "A simple book store service") .metadata("providerDisplayName", "Acme Books") .build(); return Catalog.builder() .serviceDefinitions(serviceDefinition) .build(); }
Example #4
Source File: AbstractBasePathIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Bean protected CatalogService catalogService() { return new CatalogService() { @Override public Mono<ServiceDefinition> getServiceDefinition(String serviceId) { return this.getCatalog() .flatMapIterable(Catalog::getServiceDefinitions) .filter(service -> serviceId.equals(service.getId())) .next(); } @Override public Mono<Catalog> getCatalog() { return Mono.just(Catalog.builder() .serviceDefinitions(ServiceDefinition.builder() .id("default-service") .plans(Plan.builder() .id("default-plan") .build()) .build()) .build() ); } }; }
Example #5
Source File: ApiVersionWebFilterIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void anyHeaderNotSent() { given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); mockWithDefaultVersion().get().uri(CATALOG_PATH) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); }
Example #6
Source File: BeanCatalogServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { serviceDefinition = ServiceDefinition.builder() .id(SVC_DEF_ID) .name("Name") .description("Description") .bindable(true) .build(); catalog = Catalog.builder() .serviceDefinitions(serviceDefinition) .build(); service = new BeanCatalogService(catalog); }
Example #7
Source File: CatalogControllerTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void catalogIsReturned() { Catalog expectedCatalog = Catalog.builder().build(); given(catalogService.getCatalog()).willReturn(Mono.just(expectedCatalog)); CatalogController controller = new CatalogController(catalogService); Catalog actualCatalog = controller.getCatalog().block(); assertThat(actualCatalog).isEqualTo(expectedCatalog); }
Example #8
Source File: CatalogController.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
/** * REST controller for getting a catalog * * @return the catalog */ @GetMapping({"/v2/catalog", "{platformInstanceId}/v2/catalog"}) public Mono<Catalog> getCatalog() { return catalogService.getCatalog() .doOnRequest(v -> LOG.info("Retrieving catalog")) .doOnSuccess(catalog -> { LOG.info("Success retrieving catalog"); LOG.debug("catalog={}", catalog); }) .doOnError(e -> LOG.error("Error retrieving catalog. error=" + e.getMessage(), e)); }
Example #9
Source File: ExampleCatalogService.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<Catalog> getCatalog() { return getServiceDefinition("example-service") .map(serviceDefinition -> Catalog.builder() .serviceDefinitions(serviceDefinition) .build()); }
Example #10
Source File: RequestIdentityWebFilterIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { this.client = WebTestClient.bindToController(controller) .webFilter(new RequestIdentityWebFilter()) .build(); given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); }
Example #11
Source File: CatalogControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { this.client = WebTestClient.bindToController(this.controller).build(); this.serviceDefinition = ServiceFixture.getSimpleService(); Catalog catalog = Catalog.builder() .serviceDefinitions(this.serviceDefinition) .build(); given(this.catalogService.getCatalog()) .willReturn(Mono.just(catalog)); }
Example #12
Source File: ApiVersionWebFilterIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void anyHeaderSent() { given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); mockWithDefaultVersion().get().uri(CATALOG_PATH) .header(BrokerApiVersion.DEFAULT_API_VERSION_HEADER, "ignored-version") .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); }
Example #13
Source File: ApiVersionWebFilterIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void matchingHeaderSent() { given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); mockWithExpectedVersion().get().uri(CATALOG_PATH) .header(BrokerApiVersion.DEFAULT_API_VERSION_HEADER, "expected-version") .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); }
Example #14
Source File: CatalogConfig.java From ecs-cf-service-broker with Apache License 2.0 | 5 votes |
@Bean public Catalog catalog() { return new Catalog(mergeServices().stream() .filter(ServiceDefinitionProxy::getActive) .map(ServiceDefinitionProxy::unproxy) .collect(Collectors.toList())); }
Example #15
Source File: RequiredCatalogBeanFailureAnalyzer.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override protected FailureAnalysis analyze(Throwable rootFailure, CatalogDefinitionDoesNotExistException cause) { String description = "A 'service broker catalog' is required for Spring Cloud Open Service Broker applications"; String action = String.format("Consider defining a catalog in properties or a bean of type" + " '%s' in your configuration. Alternatively, you may implement a service of type '%s'. See " + "the reference documentation for more information: " + REFERENCE_DOC, Catalog.class, CatalogService.class); return new FailureAnalysis(description, action, cause); }
Example #16
Source File: ServiceBrokerAutoConfiguration.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
/** * Conditionally provides a {@link CatalogService} bean * * @param catalog the catalog * @return the bean */ @Bean @ConditionalOnMissingBean(CatalogService.class) public CatalogService beanCatalogService(@Autowired(required = false) Catalog catalog) { if (catalog == null) { throw new CatalogDefinitionDoesNotExistException(); } return new BeanCatalogService(catalog); }
Example #17
Source File: CatalogControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { this.mockMvc = MockMvcBuilders.standaloneSetup(this.controller) .setMessageConverters(new MappingJackson2HttpMessageConverter()) .build(); this.serviceDefinition = ServiceFixture.getSimpleService(); Catalog catalog = Catalog.builder() .serviceDefinitions(this.serviceDefinition) .build(); given(this.catalogService.getCatalog()) .willReturn(Mono.just(catalog)); }
Example #18
Source File: RequestIdentityInterceptorIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { this.mvc = MockMvcBuilders.standaloneSetup(controller) .addInterceptors(new RequestIdentityInterceptor()) .build(); given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); }
Example #19
Source File: ApiVersionInterceptorIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void anyHeaderSent() throws Exception { given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); mockWithDefaultVersion().perform(get(CATALOG_PATH) .header(BrokerApiVersion.DEFAULT_API_VERSION_HEADER, "ignored-version") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); }
Example #20
Source File: ApiVersionInterceptorIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void anyHeaderNotSent() throws Exception { given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); mockWithDefaultVersion().perform(get(CATALOG_PATH) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); }
Example #21
Source File: ApiVersionInterceptorIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void matchingHeaderSent() throws Exception { given(catalogService.getCatalog()) .willReturn(Mono.just(Catalog.builder().build())); mockWithExpectedVersion().perform(get(CATALOG_PATH) .header(BrokerApiVersion.DEFAULT_API_VERSION_HEADER, "expected-version") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); }
Example #22
Source File: ServiceBrokerAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void servicesAreCreatedFromCatalogProperties() { this.contextRunner .withUserConfiguration(MissingCatalogServiceConfiguration.class) .withPropertyValues( "spring.cloud.openservicebroker.catalog.services[0].id=service-one-id", "spring.cloud.openservicebroker.catalog.services[0].name=Service One", "spring.cloud.openservicebroker.catalog.services[0].description=Description for Service One", "spring.cloud.openservicebroker.catalog.services[0].plans[0].id=plan-one-id", "spring.cloud.openservicebroker.catalog.services[0].plans[0].name=Plan One", "spring.cloud.openservicebroker.catalog.services[0].plans[0].description=Description for Plan One") .run((context) -> { assertThat(context).hasSingleBean(Catalog.class); Catalog catalog = context.getBean(Catalog.class); assertThat(catalog.getServiceDefinitions()).hasSize(1); assertThat(catalog.getServiceDefinitions().get(0).getId()).isEqualTo("service-one-id"); assertThat(catalog.getServiceDefinitions().get(0).getName()).isEqualTo("Service One"); assertThat(catalog.getServiceDefinitions().get(0).getDescription()) .isEqualTo("Description for Service One"); assertThat(catalog.getServiceDefinitions().get(0).getPlans()).hasSize(1); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getId()) .isEqualTo("plan-one-id"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getName()) .isEqualTo("Plan One"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getDescription()) .isEqualTo("Description for Plan One"); assertThat(context) .getBean(CatalogService.class) .isExactlyInstanceOf(BeanCatalogService.class); assertThat(context) .getBean(ServiceInstanceBindingService.class) .isExactlyInstanceOf(NonBindableServiceInstanceBindingService.class); assertThat(context) .getBean(ServiceInstanceService.class) .isExactlyInstanceOf(TestServiceInstanceService.class); }); }
Example #23
Source File: BindingReactiveBase.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Bean protected Catalog catalog() { return Catalog.builder() .serviceDefinitions(ServiceFixture.getSimpleService()) .build(); }
Example #24
Source File: BeanCatalogService.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Override public Mono<Catalog> getCatalog() { return Mono.just(catalog); }
Example #25
Source File: TestCatalogService.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Override public Mono<Catalog> getCatalog() { return Mono.empty(); }
Example #26
Source File: ServiceBrokerPropertiesTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
private void validateCatalogModel(Catalog catalog) { assertThat(catalog.getServiceDefinitions().get(0).getId()).isEqualTo("service-one-id"); assertThat(catalog.getServiceDefinitions().get(0).getName()).isEqualTo("Service One"); assertThat(catalog.getServiceDefinitions().get(0).getDescription()).isEqualTo("Description for Service One"); assertThat(catalog.getServiceDefinitions().get(0).isBindable()).isTrue(); assertThat(catalog.getServiceDefinitions().get(0).isBindingsRetrievable()).isTrue(); assertThat(catalog.getServiceDefinitions().get(0).isAllowContextUpdates()).isFalse(); assertThat(catalog.getServiceDefinitions().get(0).isInstancesRetrievable()).isTrue(); assertThat(catalog.getServiceDefinitions().get(0).isPlanUpdateable()).isTrue(); assertThat(catalog.getServiceDefinitions().get(0).getMetadata()) .contains(entry("key1", "value1"), entry("key2", "value2")); assertThat(catalog.getServiceDefinitions().get(0).getMetadata().get("displayName")) .isEqualTo("service display name"); assertThat(catalog.getServiceDefinitions().get(0).getMetadata().get("imageUrl")).isEqualTo("image-uri"); assertThat(catalog.getServiceDefinitions().get(0).getMetadata().get("longDescription")) .isEqualTo("service long description"); assertThat(catalog.getServiceDefinitions().get(0).getMetadata().get("providerDisplayName")) .isEqualTo("service provider display name"); assertThat(catalog.getServiceDefinitions().get(0).getMetadata().get("documentationUrl")) .isEqualTo("service-documentation-url"); assertThat(catalog.getServiceDefinitions().get(0).getMetadata().get("supportUrl")) .isEqualTo("service-support-url"); assertThat(catalog.getServiceDefinitions().get(0).getRequires()) .containsOnly("syslog_drain", "route_forwarding"); assertThat(catalog.getServiceDefinitions().get(0).getTags()).containsOnly("tag1", "tag2"); assertThat(catalog.getServiceDefinitions().get(0).getDashboardClient().getId()).isEqualTo("dashboard-id"); assertThat(catalog.getServiceDefinitions().get(0).getDashboardClient().getSecret()) .isEqualTo("dashboard-secret"); assertThat(catalog.getServiceDefinitions().get(0).getDashboardClient().getRedirectUri()) .isEqualTo("dashboard-redirect-uri"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getId()).isEqualTo("plan-one-id"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getName()).isEqualTo("Plan One"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getDescription()) .isEqualTo("Description for Plan One"); assertThat( catalog.getServiceDefinitions().get(0).getPlans().get(0).getMaintenanceInfo().getVersion()) .isEqualTo("1.0.1"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getMaintenanceInfo().getDescription()) .isEqualTo("Description for maintenance info"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getId()).isEqualTo("plan-two-id"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getName()).isEqualTo("Plan Two"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getDescription()) .isEqualTo("Description for Plan Two"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getMetadata()) .contains(entry("key1", "value1"), entry("key2", "value2"), entry("displayName", "sample display name")); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getMetadata().get("costs")).isNotNull(); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getMetadata().get("bullets")).isNotNull(); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getMetadata()) .contains(entry("displayName", "sample display name"), entry("bullets", Arrays.asList("bullet1", "bullet2")), entry("key1", "value1"), entry("key2", "value2")); @SuppressWarnings("unchecked") Map<String, Object> cost = ((List<Map<String, Object>>) catalog.getServiceDefinitions().get(0).getPlans().get(1).getMetadata() .get("costs")).get(0); assertThat(cost.get("unit")).isEqualTo("MONTHLY"); @SuppressWarnings("unchecked") Map<String, Object> amount = (Map<String, Object>) cost.get("amount"); assertThat(amount).containsOnly(entry("usd", 649.0)); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).isBindable()).isTrue(); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).isFree()).isTrue(); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).isPlanUpdateable()).isTrue(); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema() .getCreateMethodSchema().getParameters()) .contains(entry("$schema", "http://json-schema.org/draft-04/schema#"), entry("type", "string")); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema() .getCreateMethodSchema().getParameters().get("enum")).isInstanceOf(List.class); @SuppressWarnings("unchecked") List<String> enumList = (List<String>) catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas() .getServiceInstanceSchema().getCreateMethodSchema().getParameters().get("enum"); assertThat(enumList).containsOnly("one", "two", "three"); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema() .getUpdateMethodSchema().getParameters()) .containsOnly(entry("$schema", "http://json-schema.org/draft-04/schema#"), entry("type", "object")); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceBindingSchema() .getCreateMethodSchema().getParameters()) .containsOnly(entry("$schema", "http://json-schema.org/draft-04/schema#"), entry("type", "object")); assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getMaximumPollingDuration()).isEqualTo(200); assertThat(catalog.getServiceDefinitions().get(1).getId()).isEqualTo("service-two-id"); assertThat(catalog.getServiceDefinitions().get(1).getName()).isEqualTo("Service Two"); assertThat(catalog.getServiceDefinitions().get(1).getDescription()).isEqualTo("Description for Service Two"); assertThat(catalog.getServiceDefinitions().get(1).getPlans().get(0).getId()).isEqualTo("plan-one-id"); assertThat(catalog.getServiceDefinitions().get(1).getPlans().get(0).getName()).isEqualTo("Plan One"); assertThat(catalog.getServiceDefinitions().get(1).getPlans().get(0).getDescription()) .isEqualTo("Description for Plan One"); }
Example #27
Source File: InstanceServletBase.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Bean protected Catalog catalog() { return Catalog.builder() .serviceDefinitions(ServiceFixture.getSimpleService()) .build(); }
Example #28
Source File: CatalogServletBase.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Bean protected Catalog catalog() { return Catalog.builder() .serviceDefinitions(ServiceFixture.getSimpleService()) .build(); }
Example #29
Source File: CatalogReactiveBase.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Bean protected Catalog catalog() { return Catalog.builder() .serviceDefinitions(ServiceFixture.getSimpleService()) .build(); }
Example #30
Source File: BindingServletBase.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Bean protected Catalog catalog() { return Catalog.builder() .serviceDefinitions(ServiceFixture.getSimpleService()) .build(); }