Search in sources :

Example 1 with Catalog

use of org.springframework.cloud.servicebroker.model.catalog.Catalog in project spring-cloud-open-service-broker by spring-cloud.

the class CatalogControllerIntegrationTest method setUp.

@Before
public void setUp() {
    this.client = WebTestClient.bindToController(this.controller).build();
    this.serviceDefinition = ServiceFixture.getSimpleService();
    Catalog catalog = Catalog.builder().serviceDefinitions(this.serviceDefinition).build();
    when(this.catalogService.getCatalog()).thenReturn(catalog);
}
Also used : Catalog(org.springframework.cloud.servicebroker.model.catalog.Catalog) Before(org.junit.Before)

Example 2 with Catalog

use of org.springframework.cloud.servicebroker.model.catalog.Catalog in project spring-cloud-open-service-broker by spring-cloud.

the class CatalogControllerIntegrationTest method setUp.

@Before
public void setUp() {
    this.mockMvc = MockMvcBuilders.standaloneSetup(controller).setMessageConverters(new MappingJackson2HttpMessageConverter()).build();
    serviceDefinition = ServiceFixture.getSimpleService();
    Catalog catalog = Catalog.builder().serviceDefinitions(serviceDefinition).build();
    when(catalogService.getCatalog()).thenReturn(catalog);
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) Catalog(org.springframework.cloud.servicebroker.model.catalog.Catalog) Before(org.junit.Before)

Example 3 with Catalog

use of org.springframework.cloud.servicebroker.model.catalog.Catalog in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceBrokerAutoConfigurationTest method servicesAreCreatedFromCatalogProperties.

@Test
public void servicesAreCreatedFromCatalogProperties() {
    this.contextRunner.withUserConfiguration(NoCatalogBeanConfiguration.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);
    });
}
Also used : ServiceInstanceService(org.springframework.cloud.servicebroker.service.ServiceInstanceService) BeanCatalogService(org.springframework.cloud.servicebroker.service.BeanCatalogService) CatalogService(org.springframework.cloud.servicebroker.service.CatalogService) Catalog(org.springframework.cloud.servicebroker.model.catalog.Catalog) NonBindableServiceInstanceBindingService(org.springframework.cloud.servicebroker.service.NonBindableServiceInstanceBindingService) ServiceInstanceBindingService(org.springframework.cloud.servicebroker.service.ServiceInstanceBindingService) Test(org.junit.Test)

Example 4 with Catalog

use of org.springframework.cloud.servicebroker.model.catalog.Catalog in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceBrokerPropertiesTest method fullCatalog.

@Test
public void fullCatalog() {
    Map<String, String> map = new HashMap<>();
    map.put("spring.cloud.openservicebroker.catalog.services[0].id", "service-one-id");
    map.put("spring.cloud.openservicebroker.catalog.services[0].name", "Service One");
    map.put("spring.cloud.openservicebroker.catalog.services[0].description", "Description for Service One");
    map.put("spring.cloud.openservicebroker.catalog.services[0].bindable", "true");
    map.put("spring.cloud.openservicebroker.catalog.services[0].bindings-retrievable", "true");
    map.put("spring.cloud.openservicebroker.catalog.services[0].instances-retrievable", "true");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plan-updateable", "true");
    map.put("spring.cloud.openservicebroker.catalog.services[0].metadata[key1]", "value1");
    map.put("spring.cloud.openservicebroker.catalog.services[0].metadata[key2]", "value2");
    map.put("spring.cloud.openservicebroker.catalog.services[0].requires[0]", "syslog_drain");
    map.put("spring.cloud.openservicebroker.catalog.services[0].requires[1]", "route_forwarding");
    map.put("spring.cloud.openservicebroker.catalog.services[0].tags[0]", "tag1");
    map.put("spring.cloud.openservicebroker.catalog.services[0].tags[1]", "tag2");
    map.put("spring.cloud.openservicebroker.catalog.services[0].dashboard-client.id", "dashboard-id");
    map.put("spring.cloud.openservicebroker.catalog.services[0].dashboard-client.secret", "dashboard-secret");
    map.put("spring.cloud.openservicebroker.catalog.services[0].dashboard-client.redirect-uri", "dashboard-redirect-uri");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].id", "plan-one-id");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].name", "Plan One");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].description", "Description for Plan One");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].id", "plan-two-id");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].name", "Plan Two");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].description", "Description for Plan Two");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata[key1]", "value1");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata[key2]", "value2");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].bindable", "true");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].free", "true");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[$schema]", "http://example.com/service/create/schema");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[type]", "object");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.update.parameters[$schema]", "http://example.com/service/update/schema");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.update.parameters[type]", "object");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.servicebinding.create.parameters[$schema]", "http://example.com/service/create/schema");
    map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.servicebinding.create.parameters[type]", "object");
    map.put("spring.cloud.openservicebroker.catalog.services[1].id", "service-two-id");
    map.put("spring.cloud.openservicebroker.catalog.services[1].name", "Service Two");
    map.put("spring.cloud.openservicebroker.catalog.services[1].description", "Description for Service Two");
    map.put("spring.cloud.openservicebroker.catalog.services[1].plans[0].id", "plan-one-id");
    map.put("spring.cloud.openservicebroker.catalog.services[1].plans[0].name", "Plan One");
    map.put("spring.cloud.openservicebroker.catalog.services[1].plans[0].description", "Description for Plan One");
    ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
    Binder binder = new Binder(source);
    ServiceBrokerProperties properties = new ServiceBrokerProperties();
    binder.bind("spring.cloud.openservicebroker", Bindable.ofInstance(properties));
    assertThat(properties.getCatalog()).isNotNull();
    assertThat(properties.getCatalog().getServices()).hasSize(2);
    assertThat(properties.getCatalog().getServices().get(0).getId()).isEqualTo("service-one-id");
    assertThat(properties.getCatalog().getServices().get(0).getName()).isEqualTo("Service One");
    assertThat(properties.getCatalog().getServices().get(0).getDescription()).isEqualTo("Description for Service One");
    assertThat(properties.getCatalog().getServices().get(0).isBindable()).isTrue();
    assertThat(properties.getCatalog().getServices().get(0).isBindingsRetrievable()).isTrue();
    assertThat(properties.getCatalog().getServices().get(0).isInstancesRetrievable()).isTrue();
    assertThat(properties.getCatalog().getServices().get(0).isPlanUpdateable()).isTrue();
    assertThat(properties.getCatalog().getServices().get(0).getMetadata()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
    assertThat(properties.getCatalog().getServices().get(0).getRequires()).containsOnly("syslog_drain", "route_forwarding");
    assertThat(properties.getCatalog().getServices().get(0).getTags()).containsOnly("tag1", "tag2");
    assertThat(properties.getCatalog().getServices().get(0).getDashboardClient().getId()).isEqualTo("dashboard-id");
    assertThat(properties.getCatalog().getServices().get(0).getDashboardClient().getSecret()).isEqualTo("dashboard-secret");
    assertThat(properties.getCatalog().getServices().get(0).getDashboardClient().getRedirectUri()).isEqualTo("dashboard-redirect-uri");
    assertThat(properties.getCatalog().getServices().get(0).getPlans()).hasSize(2);
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getId()).isEqualTo("plan-one-id");
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getName()).isEqualTo("Plan One");
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getId()).isEqualTo("plan-two-id");
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getName()).isEqualTo("Plan Two");
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getDescription()).isEqualTo("Description for Plan Two");
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).isBindable()).isTrue();
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).isFree()).isTrue();
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getUpdate().getParameters()).containsOnly(entry("$schema", "http://example.com/service/update/schema"), entry("type", "object"));
    assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceBinding().getCreate().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
    assertThat(properties.getCatalog().getServices().get(1).getId()).isEqualTo("service-two-id");
    assertThat(properties.getCatalog().getServices().get(1).getName()).isEqualTo("Service Two");
    assertThat(properties.getCatalog().getServices().get(1).getDescription()).isEqualTo("Description for Service Two");
    assertThat(properties.getCatalog().getServices().get(1).getPlans()).hasSize(1);
    assertThat(properties.getCatalog().getServices().get(1).getPlans().get(0).getId()).isEqualTo("plan-one-id");
    assertThat(properties.getCatalog().getServices().get(1).getPlans().get(0).getName()).isEqualTo("Plan One");
    assertThat(properties.getCatalog().getServices().get(1).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
    Catalog catalog = properties.getCatalog().toModel();
    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).isInstancesRetrievable()).isTrue();
    assertThat(catalog.getServiceDefinitions().get(0).isPlanUpdateable()).isTrue();
    assertThat(catalog.getServiceDefinitions().get(0).getMetadata()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
    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(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()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
    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).getSchemas().getServiceInstanceSchema().getCreateMethodSchema().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
    assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema().getUpdateMethodSchema().getParameters()).containsOnly(entry("$schema", "http://example.com/service/update/schema"), entry("type", "object"));
    assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceBindingSchema().getCreateMethodSchema().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
    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");
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) HashMap(java.util.HashMap) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) Catalog(org.springframework.cloud.servicebroker.model.catalog.Catalog) Test(org.junit.Test)

Example 5 with Catalog

use of org.springframework.cloud.servicebroker.model.catalog.Catalog in project spring-cloud-open-service-broker by spring-cloud.

the class CatalogControllerTest method catalogIsReturned.

@Test
public void catalogIsReturned() {
    Catalog expectedCatalog = Catalog.builder().build();
    when(catalogService.getCatalog()).thenReturn(expectedCatalog);
    CatalogController controller = new CatalogController(catalogService);
    Catalog actualCatalog = controller.getCatalog();
    assertThat(actualCatalog).isEqualTo(expectedCatalog);
}
Also used : Catalog(org.springframework.cloud.servicebroker.model.catalog.Catalog) Test(org.junit.Test)

Aggregations

Catalog (org.springframework.cloud.servicebroker.model.catalog.Catalog)5 Test (org.junit.Test)3 Before (org.junit.Before)2 HashMap (java.util.HashMap)1 Binder (org.springframework.boot.context.properties.bind.Binder)1 ConfigurationPropertySource (org.springframework.boot.context.properties.source.ConfigurationPropertySource)1 MapConfigurationPropertySource (org.springframework.boot.context.properties.source.MapConfigurationPropertySource)1 BeanCatalogService (org.springframework.cloud.servicebroker.service.BeanCatalogService)1 CatalogService (org.springframework.cloud.servicebroker.service.CatalogService)1 NonBindableServiceInstanceBindingService (org.springframework.cloud.servicebroker.service.NonBindableServiceInstanceBindingService)1 ServiceInstanceBindingService (org.springframework.cloud.servicebroker.service.ServiceInstanceBindingService)1 ServiceInstanceService (org.springframework.cloud.servicebroker.service.ServiceInstanceService)1 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)1