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);
}
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);
}
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);
});
}
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");
}
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);
}
Aggregations