Enforce Spring coding style
- Add .editorconfig - Add checkstyle rules based on Spring Framework - Resolve checkstyle rule violations - Reformat all the things
This commit is contained in:
11
.editorconfig
Normal file
11
.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
||||
root = true
|
||||
|
||||
[*.{adoc,bat,groovy,html,java,js,jsp,kt,kts,md,properties,py,rb,sh,sql,svg,txt,xml,xsd}]
|
||||
charset = utf-8
|
||||
|
||||
[*.{groovy,java,kt,kts,xml,xsd}]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
continuation_indent_size = 8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
@@ -24,8 +24,83 @@
|
||||
<property name="ignoreLines" value="2, 8"/>
|
||||
</module>
|
||||
|
||||
<!-- Root Checks -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck">
|
||||
<property name="lineSeparator" value="lf"/>
|
||||
</module>
|
||||
|
||||
<!-- TreeWalker Checks -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
|
||||
<!-- Annotations -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck">
|
||||
<property name="elementStyle" value="compact" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.PackageAnnotationCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck">
|
||||
<property name="allowSamelineSingleParameterlessAnnotation"
|
||||
value="false" />
|
||||
</module>
|
||||
|
||||
<!-- Block Checks -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck">
|
||||
<property name="option" value="text" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck">
|
||||
<property name="option" value="alone" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck" />
|
||||
|
||||
<!-- Class Design -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck">
|
||||
<property name="format" value="^.*Exception$" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.design.InnerTypeLastCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck" />
|
||||
|
||||
<!-- Coding -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck">
|
||||
<property name="max" value="3" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck">
|
||||
<property name="max" value="5" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck">
|
||||
<property name="max" value="3" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck" />
|
||||
|
||||
<!-- Imports -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
|
||||
<property name="processJavadoc" value="true" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck">
|
||||
<property name="groups" value="java,javax,*,io.pivotal,org.springframework" />
|
||||
<property name="ordered" value="true" />
|
||||
<property name="separated" value="true" />
|
||||
<property name="option" value="bottom" />
|
||||
<property name="sortStaticImportsAlphabetically" value="true" />
|
||||
</module>
|
||||
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">-->
|
||||
<!-- <property name="id" value="bannedImports"/>-->
|
||||
<!-- <property name="regexp" value="true" />-->
|
||||
<!-- <property name="illegalClasses"-->
|
||||
<!-- value="^reactor\.core\.support\.Assert,^org\.slf4j\.LoggerFactory" />-->
|
||||
<!-- </module>-->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||
<property name="id" value="bannedJUnit3Imports"/>
|
||||
<property name="regexp" value="true" />
|
||||
@@ -50,6 +125,54 @@
|
||||
value="Please use specialized AssertJ assertThat*Exception method." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">-->
|
||||
<!-- <property name="id" value="bannedHamcrestImports"/>-->
|
||||
<!-- <property name="regexp" value="true" />-->
|
||||
<!-- <property name="illegalClasses" value="^org\.hamcrest\..+" />-->
|
||||
<!-- </module>-->
|
||||
|
||||
<!-- Javadoc Comments -->
|
||||
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck">-->
|
||||
<!-- <property name="scope" value="package"/>-->
|
||||
<!-- <property name="authorFormat" value=".+\s.+"/>-->
|
||||
<!-- </module>-->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck">
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
<property name="allowMissingJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck">
|
||||
<property name="scope" value="public"/>
|
||||
</module>
|
||||
<!-- <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck">-->
|
||||
<!-- <property name="checkEmptyJavadoc" value="true"/>-->
|
||||
<!-- </module>-->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagContinuationIndentationCheck">
|
||||
<property name="offset" value="0"/>
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck">
|
||||
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>
|
||||
<property name="tagOrder" value="@author, @since, @param, @see, @version, @serial, @deprecated"/>
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck">
|
||||
<property name="target" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
<property name="tagOrder" value="@param, @return, @throws, @since, @deprecated, @see"/>
|
||||
</module>
|
||||
|
||||
<!-- Regexp -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||
<property name="format" value="^\t* +\t*\S" />
|
||||
<property name="message"
|
||||
value="Line has leading space characters; indentation should be performed with tabs only." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck">
|
||||
<property name="format" value="[ \t]+$" />
|
||||
<property name="illegalPattern" value="true" />
|
||||
<property name="message" value="Trailing whitespace" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||
<property name="id" value="bddMockito"/>
|
||||
<property name="maximum" value="0"/>
|
||||
|
||||
@@ -61,4 +61,5 @@ public class NoOpServiceInstanceService implements ServiceInstanceService {
|
||||
public Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request) {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,4 +47,5 @@ public class WebFluxApplication {
|
||||
public ServiceInstanceService serviceInstanceService() {
|
||||
return new NoOpServiceInstanceService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,4 +36,4 @@ public class WebFluxApplicationTest {
|
||||
assertThat(context).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +61,5 @@ public class NoOpServiceInstanceService implements ServiceInstanceService {
|
||||
public Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request) {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,4 +47,5 @@ public class WebMvcApplication {
|
||||
public ServiceInstanceService serviceInstanceService() {
|
||||
return new NoOpServiceInstanceService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,4 +36,4 @@ public class WebMvcApplicationTest {
|
||||
assertThat(context).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling a catalog of services within
|
||||
* {@link ServiceBrokerProperties} configuration properties.
|
||||
* Internal class for marshaling a catalog of services within {@link ServiceBrokerProperties} configuration properties.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
* @author Scott Frederick
|
||||
|
||||
@@ -51,6 +51,7 @@ public class Cost {
|
||||
|
||||
/**
|
||||
* Set a single amount key-value pair
|
||||
*
|
||||
* @param amount currency code
|
||||
* @param value currency amount
|
||||
*/
|
||||
@@ -90,4 +91,5 @@ public class Cost {
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties
|
||||
* that describe the dashboard URI for a {@link ServiceDefinition}.
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describe the dashboard
|
||||
* URI for a {@link ServiceDefinition}.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
* @see org.springframework.cloud.servicebroker.model.catalog.DashboardClient
|
||||
@@ -26,9 +26,9 @@ package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
public class DashboardClient {
|
||||
|
||||
/**
|
||||
* The client ID of the dashboard OAuth2 client that the service intends to use. The
|
||||
* name must be unique within the platform. If the name is already in use, the
|
||||
* platform will return an error to the operator when the service is registered.
|
||||
* The client ID of the dashboard OAuth2 client that the service intends to use. The name must be unique within the
|
||||
* platform. If the name is already in use, the platform will return an error to the operator when the service is
|
||||
* registered.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
@@ -38,8 +38,7 @@ public class DashboardClient {
|
||||
private String secret;
|
||||
|
||||
/**
|
||||
* A domain for the service dashboard that will be whitelisted by the UAA to enable
|
||||
* dashboard SSO.
|
||||
* A domain for the service dashboard that will be whitelisted by the UAA to enable dashboard SSO.
|
||||
*/
|
||||
private String redirectUri;
|
||||
|
||||
|
||||
@@ -177,7 +177,8 @@ public class EventFlowsAutoConfiguration {
|
||||
@Autowired(required = false) List<AsyncOperationServiceInstanceBindingInitializationFlow> initializationFlows,
|
||||
@Autowired(required = false) List<AsyncOperationServiceInstanceBindingCompletionFlow> completionFlows,
|
||||
@Autowired(required = false) List<AsyncOperationServiceInstanceBindingErrorFlow> errorFlows) {
|
||||
return new AsyncOperationServiceInstanceBindingEventFlowRegistry(initializationFlows, completionFlows, errorFlows);
|
||||
return new AsyncOperationServiceInstanceBindingEventFlowRegistry(initializationFlows, completionFlows,
|
||||
errorFlows);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties
|
||||
* that describes a maintenance info available for a {@link Plan}.
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describes a maintenance
|
||||
* info available for a {@link Plan}.
|
||||
*
|
||||
* @author ilyavy
|
||||
* @see org.springframework.cloud.servicebroker.model.catalog.MaintenanceInfo
|
||||
@@ -63,4 +63,5 @@ public class MaintenanceInfo {
|
||||
.description(this.description)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import javax.validation.constraints.NotEmpty;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties
|
||||
* that describe a service plan available for a {@link ServiceDefinition}.
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describe a service plan
|
||||
* available for a {@link ServiceDefinition}.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
* @author Scott Frederick
|
||||
@@ -32,15 +32,15 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
public class Plan {
|
||||
|
||||
/**
|
||||
* An identifier used to correlate this plan in future requests to the catalog. This
|
||||
* must be unique within the platform. Using a GUID is recommended.
|
||||
* An identifier used to correlate this plan in future requests to the catalog. This must be unique within the
|
||||
* platform. Using a GUID is recommended.
|
||||
*/
|
||||
@NotEmpty
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* A CLI-friendly name of the plan that will appear in the catalog. The value should
|
||||
* be all lowercase, with no spaces.
|
||||
* A CLI-friendly name of the plan that will appear in the catalog. The value should be all lowercase, with no
|
||||
* spaces.
|
||||
*/
|
||||
@NotEmpty
|
||||
private String name;
|
||||
@@ -64,15 +64,13 @@ public class Plan {
|
||||
private Schemas schemas;
|
||||
|
||||
/**
|
||||
* Indicates whether the service with this plan can be bound to applications. This is
|
||||
* an optional field. If the value is <code>null</code>, the field will be omitted
|
||||
* from the serialized JSON.
|
||||
* Indicates whether the service with this plan can be bound to applications. This is an optional field. If the
|
||||
* value is <code>null</code>, the field will be omitted from the serialized JSON.
|
||||
*/
|
||||
private Boolean bindable;
|
||||
|
||||
/**
|
||||
* Indicates whether the plan can be limited by the non_basic_services_allowed field
|
||||
* in a platform quota.
|
||||
* Indicates whether the plan can be limited by the non_basic_services_allowed field in a platform quota.
|
||||
*/
|
||||
private Boolean free;
|
||||
|
||||
@@ -83,14 +81,14 @@ public class Plan {
|
||||
private Boolean planUpdateable;
|
||||
|
||||
/**
|
||||
* A duration, in seconds, that the Platform SHOULD use as the Service's maximum polling duration. If the
|
||||
* value is <code>null</code>, the field will be omitted from the serialized JSON.
|
||||
* A duration, in seconds, that the Platform SHOULD use as the Service's maximum polling duration. If the value is
|
||||
* <code>null</code>, the field will be omitted from the serialized JSON.
|
||||
*/
|
||||
private Integer maximumPollingDuration;
|
||||
|
||||
/**
|
||||
* Maintenance information for a Service Instance which is provisioned using the Service Plan. If provided,
|
||||
* a version string MUST be provided and platforms MAY use this when Provisioning or Updating a Service Instance.
|
||||
* Maintenance information for a Service Instance which is provisioned using the Service Plan. If provided, a
|
||||
* version string MUST be provided and platforms MAY use this when Provisioning or Updating a Service Instance.
|
||||
*/
|
||||
private MaintenanceInfo maintenanceInfo;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties
|
||||
* that describes a JSON Schemas available for a {@link Plan}.
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describes a JSON Schemas
|
||||
* available for a {@link Plan}.
|
||||
*
|
||||
* @author sgunaratne@pivotal.io
|
||||
* @author Sam Gunaratne
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties
|
||||
* that describe a Service binding JSON Schemas.
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describe a Service
|
||||
* binding JSON Schemas.
|
||||
*
|
||||
* @author sgunaratne@pivotal.io
|
||||
* @author Sam Gunaratne
|
||||
|
||||
@@ -31,15 +31,13 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker
|
||||
* implementation beans.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker implementation beans.
|
||||
* <p>
|
||||
* Provides a default {@link CatalogService} bean if a {@link Catalog} bean is provided. A
|
||||
* catalog may be defined in external configuration, or via a Spring bean.
|
||||
* Provides a default {@link CatalogService} bean if a {@link Catalog} bean is provided. A catalog may be defined in
|
||||
* external configuration, or via a Spring bean.
|
||||
* <p>
|
||||
* Provides a {@link NonBindableServiceInstanceBindingService} if a
|
||||
* {@link ServiceInstanceBindingService} is not provided, indicating that the service
|
||||
* broker provides no bindable services.
|
||||
* Provides a {@link NonBindableServiceInstanceBindingService} if a {@link ServiceInstanceBindingService} is not
|
||||
* provided, indicating that the service broker provides no bindable services.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
@@ -48,6 +46,32 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class ServiceBrokerAutoConfiguration {
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally provides a {@link ServiceInstanceBindingService} bean
|
||||
*
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ServiceInstanceBindingService.class)
|
||||
public ServiceInstanceBindingService nonBindableServiceInstanceBindingService() {
|
||||
return new NonBindableServiceInstanceBindingService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a {@link Catalog} bean when catalog properties are available in external configuration
|
||||
*/
|
||||
@@ -77,32 +101,6 @@ public class ServiceBrokerAutoConfiguration {
|
||||
public Catalog catalog() {
|
||||
return this.serviceBrokerProperties.getCatalog().toModel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally provides a {@link ServiceInstanceBindingService} bean
|
||||
*
|
||||
* @return the bean
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ServiceInstanceBindingService.class)
|
||||
public ServiceInstanceBindingService nonBindableServiceInstanceBindingService() {
|
||||
return new NonBindableServiceInstanceBindingService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
import org.springframework.cloud.servicebroker.model.catalog.ServiceDefinitionRequires;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties
|
||||
* that describes a service offered by this broker.
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describes a service
|
||||
* offered by this broker.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
* @author Scott Frederick
|
||||
@@ -36,15 +36,15 @@ import org.springframework.cloud.servicebroker.model.catalog.ServiceDefinitionRe
|
||||
public class ServiceDefinition {
|
||||
|
||||
/**
|
||||
* An identifier used to correlate this service in future requests to the catalog. This must be unique within
|
||||
* the platform. Using a GUID is recommended.
|
||||
* An identifier used to correlate this service in future requests to the catalog. This must be unique within the
|
||||
* platform. Using a GUID is recommended.
|
||||
*/
|
||||
@NotEmpty
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* A CLI-friendly name of the service that will appear in the catalog. The value should be all lowercase,
|
||||
* with no spaces.
|
||||
* A CLI-friendly name of the service that will appear in the catalog. The value should be all lowercase, with no
|
||||
* spaces.
|
||||
*/
|
||||
@NotEmpty
|
||||
private String name;
|
||||
@@ -61,8 +61,8 @@ public class ServiceDefinition {
|
||||
private Boolean bindable = false;
|
||||
|
||||
/**
|
||||
* Indicates whether the service supports requests to update instances to use a different plan from the one
|
||||
* used to provision a service instance.
|
||||
* Indicates whether the service supports requests to update instances to use a different plan from the one used to
|
||||
* provision a service instance.
|
||||
*/
|
||||
private Boolean planUpdateable;
|
||||
|
||||
@@ -77,8 +77,8 @@ public class ServiceDefinition {
|
||||
private Boolean bindingsRetrievable;
|
||||
|
||||
/**
|
||||
* Specifies whether a Service Instance supports Update requests when contextual data for the Service Instance
|
||||
* in the Platform changes.
|
||||
* Specifies whether a Service Instance supports Update requests when contextual data for the Service Instance in
|
||||
* the Platform changes.
|
||||
*/
|
||||
private Boolean allowContextUpdates;
|
||||
|
||||
@@ -94,8 +94,8 @@ public class ServiceDefinition {
|
||||
private ServiceMetadata metadata;
|
||||
|
||||
/**
|
||||
* A list of permissions that the user would have to give the service, if they provision it. See
|
||||
* {@link ServiceDefinitionRequires} for supported permissions.
|
||||
* A list of permissions that the user would have to give the service, if they provision it.
|
||||
* @see org.springframework.cloud.servicebroker.model.catalog.ServiceDefinitionRequires supported permissions
|
||||
*/
|
||||
private final List<String> requires = new ArrayList<>();
|
||||
|
||||
@@ -232,4 +232,5 @@ public class ServiceDefinition {
|
||||
.plans(modelPlans)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties
|
||||
* that describes service instance JSON Schemas.
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describes service
|
||||
* instance JSON Schemas.
|
||||
*
|
||||
* @author Sam Gunaratne
|
||||
* @author Roy Clarkson
|
||||
|
||||
@@ -35,10 +35,9 @@ import org.springframework.util.StringUtils;
|
||||
* Internal class for marshaling {@link ServiceBrokerProperties} configuration properties that describes a service
|
||||
* offered by this broker.
|
||||
*
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/profile.md#service-metadata">
|
||||
* Service Metadata API Specification</a>
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/profile.md#service-metadata">
|
||||
* Service Metadata API Specification</a>
|
||||
* @see org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition
|
||||
*/
|
||||
public class ServiceMetadata {
|
||||
@@ -204,7 +203,7 @@ public class ServiceMetadata {
|
||||
private String base64EncodeImageData(String filename) {
|
||||
String formattedImageData = null;
|
||||
ClassPathResource resource = new ClassPathResource(filename);
|
||||
try(InputStream stream = resource.getInputStream()) {
|
||||
try (InputStream stream = resource.getInputStream()) {
|
||||
byte[] imageBytes = StreamUtils.copyToByteArray(stream);
|
||||
String imageData = Base64Utils.encodeToString(imageBytes);
|
||||
formattedImageData = String.format(IMAGE_DATA_FORMAT, imageData);
|
||||
|
||||
@@ -22,4 +22,5 @@ package org.springframework.cloud.servicebroker.autoconfigure.web.exception;
|
||||
public class CatalogDefinitionDoesNotExistException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -6345978650178340540L;
|
||||
|
||||
}
|
||||
|
||||
@@ -22,4 +22,5 @@ package org.springframework.cloud.servicebroker.autoconfigure.web.exception;
|
||||
public class ServiceInstanceServiceBeanDoesNotExistException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -5517038451033555513L;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Support for Spring Boot auto-configuration in web environments
|
||||
*/
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web;
|
||||
|
||||
@@ -55,8 +55,7 @@ public class ApiVersionWebFilter implements WebFilter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a filter that validates the API version passed in request headers to the
|
||||
* configured version.
|
||||
* Construct a filter that validates the API version passed in request headers to the configured version.
|
||||
*
|
||||
* @param version the API version supported by the broker.
|
||||
*/
|
||||
@@ -65,8 +64,8 @@ public class ApiVersionWebFilter implements WebFilter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the web request and validate the API version in the header. If the API version
|
||||
* does not match, then set an HTTP 412 status and write the error message to the response.
|
||||
* Process the web request and validate the API version in the header. If the API version does not match, then set
|
||||
* an HTTP 412 status and write the error message to the response.
|
||||
*
|
||||
* @param exchange {@inheritDoc}
|
||||
* @param chain {@inheritDoc}
|
||||
@@ -117,4 +116,4 @@ public class ApiVersionWebFilter implements WebFilter {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,11 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker API
|
||||
* validation. Configures support for any service broker API version if a version is not
|
||||
* specifically configured.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker API validation. Configures support for any
|
||||
* service broker API version if a version is not specifically configured.
|
||||
*
|
||||
* <p>
|
||||
* API validation may be disabled completely by setting the following configuration
|
||||
* property:
|
||||
* API validation may be disabled completely by setting the following configuration property:
|
||||
*
|
||||
* <pre>
|
||||
* spring.cloud.openservicebroker.api-version-check-enabled = false
|
||||
|
||||
@@ -38,8 +38,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker REST API
|
||||
* endpoints.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker REST API endpoints.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Auto-configuration to support Spring WebFlux
|
||||
*/
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web.reactive;
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web.reactive;
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* {@link HandlerInterceptor} that inspects the service broker API version passed in all request headers
|
||||
* and compares it to the API version supported by the broker.
|
||||
* {@link HandlerInterceptor} that inspects the service broker API version passed in all request headers and compares it
|
||||
* to the API version supported by the broker.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
@@ -43,8 +43,7 @@ public class ApiVersionInterceptor extends HandlerInterceptorAdapter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an interceptor that validates the API version passed in request headers to the
|
||||
* configured version.
|
||||
* Construct an interceptor that validates the API version passed in request headers to the configured version.
|
||||
*
|
||||
* @param version the API version supported by the broker.
|
||||
*/
|
||||
@@ -59,8 +58,8 @@ public class ApiVersionInterceptor extends HandlerInterceptorAdapter {
|
||||
* @param request {@inheritDoc}
|
||||
* @param response {@inheritDoc}
|
||||
* @param handler {@inheritDoc}
|
||||
* @throws ServiceBrokerApiVersionException if the API version header value does not match the version
|
||||
* supported by the broker
|
||||
* @throws ServiceBrokerApiVersionException if the API version header value does not match the version supported
|
||||
* by the broker
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
||||
@@ -31,13 +31,11 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker API
|
||||
* validation. Configures support for any service broker API version if a version is not
|
||||
* specifically configured.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker API validation. Configures support for any
|
||||
* service broker API version if a version is not specifically configured.
|
||||
*
|
||||
* <p>
|
||||
* API validation may be disabled completely by setting the following configuration
|
||||
* property:
|
||||
* API validation may be disabled completely by setting the following configuration property:
|
||||
*
|
||||
* <pre>
|
||||
* spring.cloud.openservicebroker.api-version-check-enabled = false
|
||||
@@ -49,7 +47,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnBean({ ServiceInstanceService.class })
|
||||
@ConditionalOnBean({ServiceInstanceService.class})
|
||||
@ConditionalOnProperty(prefix = "spring.cloud.openservicebroker", name = "api-version-check-enabled", havingValue = "true", matchIfMissing = true)
|
||||
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
|
||||
@EnableConfigurationProperties(ServiceBrokerProperties.class)
|
||||
|
||||
@@ -33,6 +33,7 @@ public class ApiVersionWebMvcConfigurerAdapter implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* Auto-wire the expected beans
|
||||
*
|
||||
* @param apiVersionInterceptor the ApiVersionInterceptor bean
|
||||
*/
|
||||
protected ApiVersionWebMvcConfigurerAdapter(ApiVersionInterceptor apiVersionInterceptor) {
|
||||
@@ -44,4 +45,4 @@ public class ApiVersionWebMvcConfigurerAdapter implements WebMvcConfigurer {
|
||||
registry.addInterceptor(this.apiVersionInterceptor).addPathPatterns(V2_API_PATH_PATTERN);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker REST API
|
||||
* endpoints.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the service broker REST API endpoints.
|
||||
*
|
||||
* @author Benjamin Ihrig
|
||||
* @author Roy Clarkson
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Auto-configuration to support Spring MVC
|
||||
*/
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web.servlet;
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web.servlet;
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* utilities
|
||||
*/
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web.util;
|
||||
package org.springframework.cloud.servicebroker.autoconfigure.web.util;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CatalogReactiveBase {
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {
|
||||
ServiceBrokerAutoConfiguration.class,
|
||||
ServiceBrokerWebFluxAutoConfiguration.class }, exclude = ServiceBrokerWebMvcAutoConfiguration.class)
|
||||
ServiceBrokerWebFluxAutoConfiguration.class}, exclude = ServiceBrokerWebMvcAutoConfiguration.class)
|
||||
protected static class TestApplication {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CatalogServletBase {
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {
|
||||
ServiceBrokerAutoConfiguration.class,
|
||||
ServiceBrokerWebMvcAutoConfiguration.class }, exclude = ServiceBrokerWebFluxAutoConfiguration.class)
|
||||
ServiceBrokerWebMvcAutoConfiguration.class}, exclude = ServiceBrokerWebFluxAutoConfiguration.class)
|
||||
protected static class TestApplication {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -61,7 +61,7 @@ public class InstanceReactiveBase {
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {
|
||||
ServiceBrokerAutoConfiguration.class,
|
||||
ServiceBrokerWebFluxAutoConfiguration.class }, exclude = ServiceBrokerWebMvcAutoConfiguration.class)
|
||||
ServiceBrokerWebFluxAutoConfiguration.class}, exclude = ServiceBrokerWebMvcAutoConfiguration.class)
|
||||
protected static class TestApplication {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -61,7 +61,7 @@ public class InstanceServletBase {
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {
|
||||
ServiceBrokerAutoConfiguration.class,
|
||||
ServiceBrokerWebMvcAutoConfiguration.class }, exclude = ServiceBrokerWebFluxAutoConfiguration.class)
|
||||
ServiceBrokerWebMvcAutoConfiguration.class}, exclude = ServiceBrokerWebFluxAutoConfiguration.class)
|
||||
protected static class TestApplication {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -90,6 +90,7 @@ public abstract class AbstractServiceBrokerWebAutoConfigurationTest {
|
||||
public EventFlowRegistries eventFlowRegistries() {
|
||||
return new EventFlowRegistries();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -110,6 +111,7 @@ public abstract class AbstractServiceBrokerWebAutoConfigurationTest {
|
||||
public EventFlowRegistries eventFlowRegistries() {
|
||||
return new EventFlowRegistries();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceB
|
||||
import org.springframework.cloud.servicebroker.service.ServiceInstanceBindingService;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
public abstract class AbstractServiceInstanceBindingControllerIntegrationTest extends ServiceInstanceBindingIntegrationTest {
|
||||
|
||||
@@ -47,7 +47,8 @@ public abstract class AbstractServiceInstanceBindingControllerIntegrationTest ex
|
||||
protected ServiceInstanceBindingService serviceInstanceBindingService;
|
||||
|
||||
protected void setupServiceInstanceBindingService(CreateServiceInstanceBindingResponse createResponse) {
|
||||
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
.willReturn(Mono.just(createResponse));
|
||||
}
|
||||
|
||||
@@ -57,7 +58,8 @@ public abstract class AbstractServiceInstanceBindingControllerIntegrationTest ex
|
||||
}
|
||||
|
||||
protected void setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse deleteResponse) {
|
||||
given(serviceInstanceBindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
.willReturn(Mono.just(deleteResponse));
|
||||
}
|
||||
|
||||
@@ -67,17 +69,20 @@ public abstract class AbstractServiceInstanceBindingControllerIntegrationTest ex
|
||||
}
|
||||
|
||||
protected void setupServiceInstanceBindingService(ServiceBrokerCreateOperationInProgressException exception) {
|
||||
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
.willReturn(Mono.error(exception));
|
||||
}
|
||||
|
||||
protected void setupServiceInstanceBindingService(ServiceBrokerDeleteOperationInProgressException exception) {
|
||||
given(serviceInstanceBindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
.willReturn(Mono.error(exception));
|
||||
}
|
||||
|
||||
protected CreateServiceInstanceBindingRequest verifyCreateBinding() {
|
||||
ArgumentCaptor<CreateServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor.forClass(CreateServiceInstanceBindingRequest.class);
|
||||
ArgumentCaptor<CreateServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(CreateServiceInstanceBindingRequest.class);
|
||||
then(serviceInstanceBindingService)
|
||||
.should()
|
||||
.createServiceInstanceBinding(argumentCaptor.capture());
|
||||
@@ -85,7 +90,8 @@ public abstract class AbstractServiceInstanceBindingControllerIntegrationTest ex
|
||||
}
|
||||
|
||||
protected GetServiceInstanceBindingRequest verifyGetBinding() {
|
||||
ArgumentCaptor<GetServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor.forClass(GetServiceInstanceBindingRequest.class);
|
||||
ArgumentCaptor<GetServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(GetServiceInstanceBindingRequest.class);
|
||||
then(serviceInstanceBindingService)
|
||||
.should()
|
||||
.getServiceInstanceBinding(argumentCaptor.capture());
|
||||
@@ -93,7 +99,8 @@ public abstract class AbstractServiceInstanceBindingControllerIntegrationTest ex
|
||||
}
|
||||
|
||||
protected DeleteServiceInstanceBindingRequest verifyDeleteBinding() {
|
||||
ArgumentCaptor<DeleteServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor.forClass(DeleteServiceInstanceBindingRequest.class);
|
||||
ArgumentCaptor<DeleteServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(DeleteServiceInstanceBindingRequest.class);
|
||||
then(serviceInstanceBindingService)
|
||||
.should()
|
||||
.deleteServiceInstanceBinding(argumentCaptor.capture());
|
||||
@@ -101,10 +108,12 @@ public abstract class AbstractServiceInstanceBindingControllerIntegrationTest ex
|
||||
}
|
||||
|
||||
protected GetLastServiceBindingOperationRequest verifyLastOperation() {
|
||||
ArgumentCaptor<GetLastServiceBindingOperationRequest> argumentCaptor = ArgumentCaptor.forClass(GetLastServiceBindingOperationRequest.class);
|
||||
ArgumentCaptor<GetLastServiceBindingOperationRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(GetLastServiceBindingOperationRequest.class);
|
||||
then(serviceInstanceBindingService)
|
||||
.should()
|
||||
.getLastOperation(argumentCaptor.capture());
|
||||
return argumentCaptor.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -185,32 +185,38 @@ public abstract class AbstractServiceInstanceControllerIntegrationTest extends C
|
||||
}
|
||||
|
||||
protected CreateServiceInstanceRequest verifyCreateServiceInstance() {
|
||||
ArgumentCaptor<CreateServiceInstanceRequest> argumentCaptor = ArgumentCaptor.forClass(CreateServiceInstanceRequest.class);
|
||||
ArgumentCaptor<CreateServiceInstanceRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(CreateServiceInstanceRequest.class);
|
||||
Mockito.verify(serviceInstanceService).createServiceInstance(argumentCaptor.capture());
|
||||
return argumentCaptor.getValue();
|
||||
}
|
||||
|
||||
protected GetServiceInstanceRequest verifyGetServiceInstance() {
|
||||
ArgumentCaptor<GetServiceInstanceRequest> argumentCaptor = ArgumentCaptor.forClass(GetServiceInstanceRequest.class);
|
||||
ArgumentCaptor<GetServiceInstanceRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(GetServiceInstanceRequest.class);
|
||||
Mockito.verify(serviceInstanceService).getServiceInstance(argumentCaptor.capture());
|
||||
return argumentCaptor.getValue();
|
||||
}
|
||||
|
||||
protected DeleteServiceInstanceRequest verifyDeleteServiceInstance() {
|
||||
ArgumentCaptor<DeleteServiceInstanceRequest> argumentCaptor = ArgumentCaptor.forClass(DeleteServiceInstanceRequest.class);
|
||||
ArgumentCaptor<DeleteServiceInstanceRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(DeleteServiceInstanceRequest.class);
|
||||
Mockito.verify(serviceInstanceService).deleteServiceInstance(argumentCaptor.capture());
|
||||
return argumentCaptor.getValue();
|
||||
}
|
||||
|
||||
protected UpdateServiceInstanceRequest verifyUpdateServiceInstance() {
|
||||
ArgumentCaptor<UpdateServiceInstanceRequest> argumentCaptor = ArgumentCaptor.forClass(UpdateServiceInstanceRequest.class);
|
||||
ArgumentCaptor<UpdateServiceInstanceRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(UpdateServiceInstanceRequest.class);
|
||||
Mockito.verify(serviceInstanceService).updateServiceInstance(argumentCaptor.capture());
|
||||
return argumentCaptor.getValue();
|
||||
}
|
||||
|
||||
protected GetLastServiceOperationRequest verifyLastOperation() {
|
||||
ArgumentCaptor<GetLastServiceOperationRequest> argumentCaptor = ArgumentCaptor.forClass(GetLastServiceOperationRequest.class);
|
||||
ArgumentCaptor<GetLastServiceOperationRequest> argumentCaptor = ArgumentCaptor
|
||||
.forClass(GetLastServiceOperationRequest.class);
|
||||
Mockito.verify(serviceInstanceService).getLastOperation(argumentCaptor.capture());
|
||||
return argumentCaptor.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
|
||||
private void assertEventFlowBeans(EventFlowRegistry<?, ?, ?, ?, ?> registry, int initializationFlowCount,
|
||||
int completionFlowCount, int errorFlowCount) {
|
||||
int completionFlowCount, int errorFlowCount) {
|
||||
List<?> initializationFlows = (List<?>) ReflectionTestUtils
|
||||
.getField(registry, "initializationFlows");
|
||||
assertThat(initializationFlows.size()).isEqualTo(initializationFlowCount);
|
||||
@@ -307,7 +307,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new CreateServiceInstanceCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(CreateServiceInstanceRequest request,
|
||||
CreateServiceInstanceResponse response) {
|
||||
CreateServiceInstanceResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -322,6 +322,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -342,7 +343,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new UpdateServiceInstanceCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(UpdateServiceInstanceRequest request,
|
||||
UpdateServiceInstanceResponse response) {
|
||||
UpdateServiceInstanceResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -357,6 +358,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -377,7 +379,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new DeleteServiceInstanceCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(DeleteServiceInstanceRequest request,
|
||||
DeleteServiceInstanceResponse response) {
|
||||
DeleteServiceInstanceResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -402,6 +404,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -422,7 +425,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new AsyncOperationServiceInstanceCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(GetLastServiceOperationRequest request,
|
||||
GetLastServiceOperationResponse response) {
|
||||
GetLastServiceOperationResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -433,7 +436,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new AsyncOperationServiceInstanceCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(GetLastServiceOperationRequest request,
|
||||
GetLastServiceOperationResponse response) {
|
||||
GetLastServiceOperationResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -448,6 +451,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -468,7 +472,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new CreateServiceInstanceBindingCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(CreateServiceInstanceBindingRequest request,
|
||||
CreateServiceInstanceBindingResponse response) {
|
||||
CreateServiceInstanceBindingResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -483,6 +487,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -503,7 +508,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new DeleteServiceInstanceBindingCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(DeleteServiceInstanceBindingRequest request,
|
||||
DeleteServiceInstanceBindingResponse response) {
|
||||
DeleteServiceInstanceBindingResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -518,6 +523,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -538,7 +544,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new AsyncOperationServiceInstanceBindingCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(GetLastServiceBindingOperationRequest request,
|
||||
GetLastServiceBindingOperationResponse response) {
|
||||
GetLastServiceBindingOperationResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -549,7 +555,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
return new AsyncOperationServiceInstanceBindingCompletionFlow() {
|
||||
@Override
|
||||
public Mono<Void> complete(GetLastServiceBindingOperationRequest request,
|
||||
GetLastServiceBindingOperationResponse response) {
|
||||
GetLastServiceBindingOperationResponse response) {
|
||||
return Mono.empty();
|
||||
}
|
||||
};
|
||||
@@ -564,5 +570,7 @@ public class EventFlowsAutoConfigurationTest {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,14 +25,15 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MethodSchemaTest {
|
||||
|
||||
@Test
|
||||
public void convertsParametersNumberedMapToArray() {
|
||||
//given the properties converted from yml, with array converted to numbered map
|
||||
|
||||
// Simplified example adapted from https://json-schema.org/understanding-json-schema/UnderstandingJSONSchema.pdf
|
||||
// section 4.6 "array"
|
||||
@Test
|
||||
public void convertsParametersNumberedMapToArray() {
|
||||
//given the properties converted from yml, with array converted to numbered map
|
||||
|
||||
// Simplified example adapted from https://json-schema.org/understanding-json-schema/UnderstandingJSONSchema.pdf
|
||||
// section 4.6 "array"
|
||||
/*
|
||||
{
|
||||
"type": "object",
|
||||
@@ -48,41 +49,44 @@ public class MethodSchemaTest {
|
||||
*/
|
||||
|
||||
|
||||
MethodSchema methodSchema = new MethodSchema();
|
||||
methodSchema.getParameters().put("type", "object");
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("type", "number");
|
||||
Map<String, String> number = new HashMap<>();
|
||||
number.put("type", "number");
|
||||
Map<String, Object> streetType = new HashMap<>();
|
||||
streetType.put("type", "string");
|
||||
Map<String, String> enumMap = new HashMap<>();
|
||||
enumMap.put("0", "Street");
|
||||
enumMap.put("1", "Avenue");
|
||||
enumMap.put("2", "Boulevard");
|
||||
streetType.put("enum", enumMap);
|
||||
properties.put("street_type", streetType);
|
||||
methodSchema.getParameters().put("properties", properties);
|
||||
|
||||
//when
|
||||
org.springframework.cloud.servicebroker.model.catalog.MethodSchema model = methodSchema.toModel();
|
||||
MethodSchema methodSchema = new MethodSchema();
|
||||
methodSchema.getParameters().put("type", "object");
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("type", "number");
|
||||
Map<String, String> number = new HashMap<>();
|
||||
number.put("type", "number");
|
||||
Map<String, Object> streetType = new HashMap<>();
|
||||
streetType.put("type", "string");
|
||||
Map<String, String> enumMap = new HashMap<>();
|
||||
enumMap.put("0", "Street");
|
||||
enumMap.put("1", "Avenue");
|
||||
enumMap.put("2", "Boulevard");
|
||||
streetType.put("enum", enumMap);
|
||||
properties.put("street_type", streetType);
|
||||
methodSchema.getParameters().put("properties", properties);
|
||||
|
||||
//then
|
||||
assertThat(model.getParameters()).contains(entry("type", "object"));
|
||||
assertThat(model.getParameters().get("properties")).isInstanceOf(Map.class);
|
||||
@SuppressWarnings("unchecked") Map<String,Object> readProperties = (Map<String,Object>) model.getParameters().get("properties");
|
||||
assertThat(readProperties.get("street_type")).isInstanceOf(Map.class);
|
||||
@SuppressWarnings("unchecked") Map<String,Object> readStreetType = (Map<String,Object>) readProperties.get("street_type");
|
||||
assertThat(readStreetType.get("enum")).isInstanceOf(List.class);
|
||||
@SuppressWarnings("unchecked") List<Object> readEnum = (List<Object>) readStreetType.get("enum");
|
||||
assertThat(readEnum).contains("Street", "Avenue", "Boulevard");
|
||||
}
|
||||
//when
|
||||
org.springframework.cloud.servicebroker.model.catalog.MethodSchema model = methodSchema.toModel();
|
||||
|
||||
@Test
|
||||
public void convertsNestedParametersNumberedMapToArray() {
|
||||
//given the properties converted from yml, with array converted to numbered map
|
||||
//then
|
||||
assertThat(model.getParameters()).contains(entry("type", "object"));
|
||||
assertThat(model.getParameters().get("properties")).isInstanceOf(Map.class);
|
||||
|
||||
// Simplified example adapted from https://json-schema.org/understanding-json-schema/UnderstandingJSONSchema.pdf
|
||||
Map<String, Object> readProperties = (Map<String, Object>) model.getParameters()
|
||||
.get("properties");
|
||||
assertThat(readProperties.get("street_type")).isInstanceOf(Map.class);
|
||||
Map<String, Object> readStreetType = (Map<String, Object>) readProperties
|
||||
.get("street_type");
|
||||
assertThat(readStreetType.get("enum")).isInstanceOf(List.class);
|
||||
List<Object> readEnum = (List<Object>) readStreetType.get("enum");
|
||||
assertThat(readEnum).contains("Street", "Avenue", "Boulevard");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertsNestedParametersNumberedMapToArray() {
|
||||
//given the properties converted from yml, with array converted to numbered map
|
||||
|
||||
// Simplified example adapted from https://json-schema.org/understanding-json-schema/UnderstandingJSONSchema.pdf
|
||||
/*
|
||||
{
|
||||
"type": "array",
|
||||
@@ -97,56 +101,57 @@ public class MethodSchemaTest {
|
||||
*/
|
||||
|
||||
|
||||
MethodSchema methodSchema = new MethodSchema();
|
||||
methodSchema.getParameters().put("type", "array");
|
||||
Map<String, Object> itemsArray= new HashMap<>();
|
||||
Map<String, Object> firstItem = new HashMap<>();
|
||||
firstItem.put("type", "string");
|
||||
itemsArray.put("0", firstItem);
|
||||
Map<String, String> enumMap = new HashMap<>();
|
||||
enumMap.put("0", "Street");
|
||||
enumMap.put("1", "Avenue");
|
||||
enumMap.put("2", "Boulevard");
|
||||
firstItem.put("enum", enumMap);
|
||||
methodSchema.getParameters().put("items", itemsArray);
|
||||
MethodSchema methodSchema = new MethodSchema();
|
||||
methodSchema.getParameters().put("type", "array");
|
||||
Map<String, Object> itemsArray = new HashMap<>();
|
||||
Map<String, Object> firstItem = new HashMap<>();
|
||||
firstItem.put("type", "string");
|
||||
itemsArray.put("0", firstItem);
|
||||
Map<String, String> enumMap = new HashMap<>();
|
||||
enumMap.put("0", "Street");
|
||||
enumMap.put("1", "Avenue");
|
||||
enumMap.put("2", "Boulevard");
|
||||
firstItem.put("enum", enumMap);
|
||||
methodSchema.getParameters().put("items", itemsArray);
|
||||
|
||||
//when
|
||||
org.springframework.cloud.servicebroker.model.catalog.MethodSchema model = methodSchema.toModel();
|
||||
//when
|
||||
org.springframework.cloud.servicebroker.model.catalog.MethodSchema model = methodSchema.toModel();
|
||||
|
||||
//then
|
||||
assertThat(model.getParameters()).contains(entry("type", "array"));
|
||||
assertThat(model.getParameters().get("items")).isInstanceOf(List.class);
|
||||
@SuppressWarnings("unchecked") List<Object> items = (List<Object>) model.getParameters().get("items");
|
||||
assertThat(items.get(0)).isInstanceOf(Map.class);
|
||||
@SuppressWarnings("unchecked") Map<String,Object> readfirstItem= (Map<String,Object>) items.get(0);
|
||||
assertThat(readfirstItem).contains(entry("type", "string"));
|
||||
assertThat(readfirstItem.get("enum")).isInstanceOf(List.class);
|
||||
@SuppressWarnings("unchecked") List<Object> readEnum = (List<Object>) readfirstItem.get("enum");
|
||||
assertThat(readEnum).contains("Street", "Avenue", "Boulevard");
|
||||
}
|
||||
//then
|
||||
assertThat(model.getParameters()).contains(entry("type", "array"));
|
||||
assertThat(model.getParameters().get("items")).isInstanceOf(List.class);
|
||||
List<Object> items = (List<Object>) model.getParameters().get("items");
|
||||
assertThat(items.get(0)).isInstanceOf(Map.class);
|
||||
Map<String, Object> readfirstItem = (Map<String, Object>) items.get(0);
|
||||
assertThat(readfirstItem).contains(entry("type", "string"));
|
||||
assertThat(readfirstItem.get("enum")).isInstanceOf(List.class);
|
||||
List<Object> readEnum = (List<Object>) readfirstItem.get("enum");
|
||||
assertThat(readEnum).contains("Street", "Avenue", "Boulevard");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotConvertOthersParameters() {
|
||||
//given the properties converted from yml, with array converted to numbered map
|
||||
MethodSchema methodSchema = new MethodSchema();
|
||||
methodSchema.getParameters().put("type", "Object");
|
||||
Map<String, String> enumMap = new HashMap<>();
|
||||
enumMap.put("property1", "value1");
|
||||
enumMap.put("property2", "value2");
|
||||
enumMap.put("property3", "value3");
|
||||
methodSchema.getParameters().put("properties", enumMap);
|
||||
@Test
|
||||
public void doesNotConvertOthersParameters() {
|
||||
//given the properties converted from yml, with array converted to numbered map
|
||||
MethodSchema methodSchema = new MethodSchema();
|
||||
methodSchema.getParameters().put("type", "Object");
|
||||
Map<String, String> enumMap = new HashMap<>();
|
||||
enumMap.put("property1", "value1");
|
||||
enumMap.put("property2", "value2");
|
||||
enumMap.put("property3", "value3");
|
||||
methodSchema.getParameters().put("properties", enumMap);
|
||||
|
||||
//when
|
||||
org.springframework.cloud.servicebroker.model.catalog.MethodSchema model = methodSchema.toModel();
|
||||
//when
|
||||
org.springframework.cloud.servicebroker.model.catalog.MethodSchema model = methodSchema.toModel();
|
||||
|
||||
//then
|
||||
assertThat(model.getParameters()).contains(entry("type", "Object"));
|
||||
assertThat(model.getParameters().get("properties")).isInstanceOf(Map.class);
|
||||
@SuppressWarnings("unchecked") Map<String,Object> propertiesMap = (Map<String,Object>) model.getParameters().get("properties");
|
||||
assertThat(propertiesMap).containsOnly(
|
||||
entry("property1", "value1"),
|
||||
entry("property2", "value2"),
|
||||
entry("property3", "value3"));
|
||||
}
|
||||
//then
|
||||
assertThat(model.getParameters()).contains(entry("type", "Object"));
|
||||
assertThat(model.getParameters().get("properties")).isInstanceOf(Map.class);
|
||||
Map<String, Object> propertiesMap = (Map<String, Object>) model.getParameters()
|
||||
.get("properties");
|
||||
assertThat(propertiesMap).containsOnly(
|
||||
entry("property1", "value1"),
|
||||
entry("property2", "value2"),
|
||||
entry("property3", "value3"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(MissingInstanceServiceConfiguration.class)
|
||||
.run(context -> assertThat(context.getStartupFailure())
|
||||
.isExactlyInstanceOf(UnsatisfiedDependencyException.class));
|
||||
.isExactlyInstanceOf(UnsatisfiedDependencyException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,11 +171,15 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
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).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(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);
|
||||
@@ -192,6 +196,7 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
|
||||
@TestConfiguration
|
||||
public static class MinimalWithCatalogConfiguration {
|
||||
|
||||
@Bean
|
||||
public Catalog catalog() {
|
||||
return Catalog.builder().build();
|
||||
@@ -201,10 +206,12 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
public ServiceInstanceService serviceInstanceService() {
|
||||
return new TestServiceInstanceService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
public static class FullServicesWithCatalogConfiguration {
|
||||
|
||||
@Bean
|
||||
public Catalog catalog() {
|
||||
return Catalog.builder().build();
|
||||
@@ -219,10 +226,12 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
public ServiceInstanceBindingService serviceInstanceBindingService() {
|
||||
return new TestServiceInstanceBindingService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
public static class FullServicesConfiguration {
|
||||
|
||||
@Bean
|
||||
public CatalogService catalogService() {
|
||||
return new TestCatalogService();
|
||||
@@ -237,10 +246,12 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
public ServiceInstanceBindingService serviceInstanceBindingService() {
|
||||
return new TestServiceInstanceBindingService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
public static class CatalogAndCatalogServiceConfiguration {
|
||||
|
||||
@Bean
|
||||
public Catalog catalog() {
|
||||
return Catalog.builder().build();
|
||||
@@ -255,6 +266,7 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
public ServiceInstanceService serviceInstanceService() {
|
||||
return new TestServiceInstanceService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -270,6 +282,7 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
public Catalog catalog() {
|
||||
return Catalog.builder().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -285,6 +298,7 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
public ServiceInstanceService serviceInstanceService() {
|
||||
return new TestServiceInstanceService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -298,6 +312,7 @@ public class ServiceBrokerAutoConfigurationTest {
|
||||
this.catalogService = catalogService;
|
||||
this.serviceInstanceService = serviceInstanceService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,8 @@ public class ServiceBrokerPropertiesBindingTest {
|
||||
assertThat(catalog.getServices().get(0).getPlans()).hasSize(1);
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getId()).isEqualTo("plan-one-id");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getName()).isEqualTo("Plan One");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getDescription())
|
||||
.isEqualTo("Description for Plan One");
|
||||
|
||||
//Mandatory fields should have a default set when unspecified in configuration
|
||||
assertThat(catalog.getServices().get(0).isBindable()).isNotNull();
|
||||
@@ -138,15 +139,19 @@ public class ServiceBrokerPropertiesBindingTest {
|
||||
assertThat(catalog.getServices().get(0).getTags()).containsOnly("tag1", "tag2");
|
||||
assertThat(catalog.getServices().get(0).getDashboardClient().getId()).isEqualTo("dashboard-id");
|
||||
assertThat(catalog.getServices().get(0).getDashboardClient().getSecret()).isEqualTo("dashboard-secret");
|
||||
assertThat(catalog.getServices().get(0).getDashboardClient().getRedirectUri()).isEqualTo("dashboard-redirect-uri");
|
||||
assertThat(catalog.getServices().get(0).getDashboardClient().getRedirectUri())
|
||||
.isEqualTo("dashboard-redirect-uri");
|
||||
}
|
||||
|
||||
private void validateServiceOneMetadata(Catalog catalog) {
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getDisplayName()).isEqualTo("service display name");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getImageUrl()).isEqualTo("image-uri");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getLongDescription()).isEqualTo("service long description");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getProviderDisplayName()).isEqualTo("service provider display name");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getDocumentationUrl()).isEqualTo("service-documentation-url");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getLongDescription())
|
||||
.isEqualTo("service long description");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getProviderDisplayName())
|
||||
.isEqualTo("service provider display name");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getDocumentationUrl())
|
||||
.isEqualTo("service-documentation-url");
|
||||
assertThat(catalog.getServices().get(0).getMetadata().getSupportUrl()).isEqualTo("service-support-url");
|
||||
|
||||
Object licenses = catalog.getServices().get(0).getMetadata().getProperties().get("licenses");
|
||||
@@ -169,32 +174,44 @@ public class ServiceBrokerPropertiesBindingTest {
|
||||
assertThat(catalog.getServices().get(0).getPlans()).hasSize(2);
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getId()).isEqualTo("plan-one-id");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getName()).isEqualTo("Plan One");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getDescription())
|
||||
.isEqualTo("Description for Plan One");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getMaintenanceInfo().getVersion()).isEqualTo("1.0.1");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getMaintenanceInfo().getDescription()).isEqualTo("Description for maintenance info");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(0).getMaintenanceInfo().getDescription())
|
||||
.isEqualTo("Description for maintenance info");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getId()).isEqualTo("plan-two-id");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getName()).isEqualTo("Plan Two");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getDescription()).isEqualTo("Description for Plan Two");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getProperties()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getDescription())
|
||||
.isEqualTo("Description for Plan Two");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getProperties())
|
||||
.containsOnly(entry("key1", "value1"), entry("key2", "value2"));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getCosts()).hasSize(1);
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0).getUnit()).isEqualTo("MONTHLY");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0).getAmount()).contains(entry("usd", 649.0));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getDisplayName()).isEqualTo("sample display name");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getBullets()).containsExactlyInAnyOrder("bullet1", "bullet2");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0).getUnit())
|
||||
.isEqualTo("MONTHLY");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0).getAmount())
|
||||
.contains(entry("usd", 649.0));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getDisplayName())
|
||||
.isEqualTo("sample display name");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMetadata().getBullets())
|
||||
.containsExactlyInAnyOrder("bullet1", "bullet2");
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).isBindable()).isTrue();
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).isFree()).isTrue();
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).isPlanUpdateable()).isTrue();
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters())
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate()
|
||||
.getParameters())
|
||||
.contains(entry("$schema", "https://json-schema.org/draft-04/schema#"),
|
||||
entry("type", "string"));
|
||||
Object enumMap = catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters().get("enum");
|
||||
Object enumMap = catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate()
|
||||
.getParameters().get("enum");
|
||||
assertThat(enumMap).isInstanceOf(Map.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> castedMap = (Map<String, Object> ) enumMap;
|
||||
assertThat(castedMap).containsOnly(entry("0","one"),entry("1", "two"), entry("2", "three"));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getUpdate().getParameters())
|
||||
Map<String, Object> castedMap = (Map<String, Object>) enumMap;
|
||||
assertThat(castedMap).containsOnly(entry("0", "one"), entry("1", "two"), entry("2", "three"));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getUpdate()
|
||||
.getParameters())
|
||||
.containsOnly(entry("$schema", "https://json-schema.org/draft-04/schema#"), entry("type", "object"));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceBinding().getCreate().getParameters())
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getSchemas().getServiceBinding().getCreate()
|
||||
.getParameters())
|
||||
.containsOnly(entry("$schema", "https://json-schema.org/draft-04/schema#"), entry("type", "object"));
|
||||
assertThat(catalog.getServices().get(0).getPlans().get(1).getMaximumPollingDuration()).isEqualTo(120);
|
||||
}
|
||||
@@ -206,7 +223,8 @@ public class ServiceBrokerPropertiesBindingTest {
|
||||
assertThat(catalog.getServices().get(1).getPlans()).hasSize(1);
|
||||
assertThat(catalog.getServices().get(1).getPlans().get(0).getId()).isEqualTo("plan-one-id");
|
||||
assertThat(catalog.getServices().get(1).getPlans().get(0).getName()).isEqualTo("Plan One");
|
||||
assertThat(catalog.getServices().get(1).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
|
||||
assertThat(catalog.getServices().get(1).getPlans().get(0).getDescription())
|
||||
.isEqualTo("Description for Plan One");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -82,9 +82,12 @@ public class ServiceBrokerPropertiesTest {
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.properties[key2]", "value2");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.displayName", "service display name");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.imageUrl", "image-uri");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.longDescription", "service long description");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.providerDisplayName", "service provider display name");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.documentationUrl", "service-documentation-url");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.longDescription",
|
||||
"service long description");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.providerDisplayName",
|
||||
"service provider display name");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.documentationUrl",
|
||||
"service-documentation-url");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata.supportUrl", "service-support-url");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].requires[0]", "syslog_drain");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].requires[1]", "route_forwarding");
|
||||
@@ -92,18 +95,21 @@ public class ServiceBrokerPropertiesTest {
|
||||
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].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[0].maintenance_info.version", "1.0.1");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].maintenance_info.description", "Description for maintenance info");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].maintenance_info.description",
|
||||
"Description for maintenance info");
|
||||
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.properties[key1]", "value1");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata.properties[key2]", "value2");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata.displayName", "sample display name");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata.displayName",
|
||||
"sample display name");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata.bullets[0]", "bullet1");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata.bullets[1]", "bullet2");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata.costs[0].amount[usd]", "649.0");
|
||||
@@ -111,15 +117,24 @@ public class ServiceBrokerPropertiesTest {
|
||||
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].planUpdateable", "true");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[$schema]", "https://json-schema.org/draft-04/schema#");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[type]", "string");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[enum].0", "one");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[enum].1", "two");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[enum].2", "three");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.update.parameters[$schema]", "https://json-schema.org/draft-04/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]", "https://json-schema.org/draft-04/schema#");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.servicebinding.create.parameters[type]", "object");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[$schema]",
|
||||
"https://json-schema.org/draft-04/schema#");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[type]",
|
||||
"string");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[enum].0",
|
||||
"one");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[enum].1",
|
||||
"two");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[enum].2",
|
||||
"three");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.update.parameters[$schema]",
|
||||
"https://json-schema.org/draft-04/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]",
|
||||
"https://json-schema.org/draft-04/schema#");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.servicebinding.create.parameters[type]",
|
||||
"object");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].maximumPollingDuration", "200");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[1].id", "service-two-id");
|
||||
map.put("spring.cloud.openservicebroker.catalog.services[1].name", "Service Two");
|
||||
@@ -134,58 +149,85 @@ public class ServiceBrokerPropertiesTest {
|
||||
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).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).isAllowContextUpdates()).isFalse();
|
||||
assertThat(properties.getCatalog().getServices().get(0).isInstancesRetrievable()).isTrue();
|
||||
assertThat(properties.getCatalog().getServices().get(0).isPlanUpdateable()).isTrue();
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getDisplayName()).isEqualTo("service display name");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getDisplayName())
|
||||
.isEqualTo("service display name");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getImageUrl()).isEqualTo("image-uri");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getLongDescription()).isEqualTo("service long description");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getProviderDisplayName()).isEqualTo("service provider display name");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getDocumentationUrl()).isEqualTo("service-documentation-url");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getSupportUrl()).isEqualTo("service-support-url");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getProperties()).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).getMetadata().getLongDescription())
|
||||
.isEqualTo("service long description");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getProviderDisplayName())
|
||||
.isEqualTo("service provider display name");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getDocumentationUrl())
|
||||
.isEqualTo("service-documentation-url");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getSupportUrl())
|
||||
.isEqualTo("service-support-url");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getMetadata().getProperties())
|
||||
.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).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(0).getMaintenanceInfo().getVersion()).isEqualTo("1.0.1");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getMaintenanceInfo().getDescription()).isEqualTo("Description for maintenance info");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getDescription())
|
||||
.isEqualTo("Description for Plan One");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getMaintenanceInfo().getVersion())
|
||||
.isEqualTo("1.0.1");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getMaintenanceInfo().getDescription())
|
||||
.isEqualTo("Description for maintenance info");
|
||||
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().getProperties()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata().getBullets()).contains("bullet1", "bullet2");
|
||||
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().getProperties())
|
||||
.containsOnly(entry("key1", "value1"), entry("key2", "value2"));
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata().getBullets())
|
||||
.contains("bullet1", "bullet2");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata().getCosts()).hasSize(1);
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0).getAmount().get("usd")).isEqualTo(649.0d);
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0).getUnit()).isEqualTo("MONTHLY");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0)
|
||||
.getAmount().get("usd")).isEqualTo(649.0d);
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata().getCosts().get(0)
|
||||
.getUnit()).isEqualTo("MONTHLY");
|
||||
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).isPlanUpdateable()).isTrue();
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters())
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance()
|
||||
.getCreate().getParameters())
|
||||
.contains(entry("$schema", "https://json-schema.org/draft-04/schema#"), entry("type", "string"));
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters().get("enum")).isInstanceOf(Map.class);
|
||||
@SuppressWarnings("unchecked") Map<String, String> enumMap = (Map<String, String>) properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters().get("enum");
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance()
|
||||
.getCreate().getParameters().get("enum")).isInstanceOf(Map.class);
|
||||
@SuppressWarnings("unchecked") Map<String, String> enumMap = (Map<String, String>) properties.getCatalog()
|
||||
.getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters()
|
||||
.get("enum");
|
||||
assertThat(enumMap).containsOnly(entry("0", "one"), entry("1", "two"), entry("2", "three"));
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getUpdate().getParameters())
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance()
|
||||
.getUpdate().getParameters())
|
||||
.containsOnly(entry("$schema", "https://json-schema.org/draft-04/schema#"), entry("type", "object"));
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceBinding().getCreate().getParameters())
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceBinding()
|
||||
.getCreate().getParameters())
|
||||
.containsOnly(entry("$schema", "https://json-schema.org/draft-04/schema#"), entry("type", "object"));
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMaximumPollingDuration()).isEqualTo(200);
|
||||
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMaximumPollingDuration())
|
||||
.isEqualTo(200);
|
||||
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).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");
|
||||
assertThat(properties.getCatalog().getServices().get(1).getPlans().get(0).getDescription())
|
||||
.isEqualTo("Description for Plan One");
|
||||
}
|
||||
|
||||
private void validateCatalogModel(Catalog catalog) {
|
||||
@@ -197,27 +239,43 @@ public class ServiceBrokerPropertiesTest {
|
||||
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())
|
||||
.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).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).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().toString()).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(0).getDescription())
|
||||
.isEqualTo("Description for Plan One");
|
||||
assertThat(
|
||||
catalog.getServiceDefinitions().get(0).getPlans().get(0).getMaintenanceInfo().getVersion().toString())
|
||||
.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).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())
|
||||
@@ -235,15 +293,20 @@ public class ServiceBrokerPropertiesTest {
|
||||
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())
|
||||
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema()
|
||||
.getCreateMethodSchema().getParameters())
|
||||
.contains(entry("$schema", "https://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);
|
||||
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");
|
||||
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())
|
||||
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema()
|
||||
.getUpdateMethodSchema().getParameters())
|
||||
.containsOnly(entry("$schema", "https://json-schema.org/draft-04/schema#"), entry("type", "object"));
|
||||
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceBindingSchema().getCreateMethodSchema().getParameters())
|
||||
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceBindingSchema()
|
||||
.getCreateMethodSchema().getParameters())
|
||||
.containsOnly(entry("$schema", "https://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");
|
||||
@@ -251,7 +314,8 @@ public class ServiceBrokerPropertiesTest {
|
||||
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");
|
||||
assertThat(catalog.getServiceDefinitions().get(1).getPlans().get(0).getDescription())
|
||||
.isEqualTo("Description for Plan One");
|
||||
}
|
||||
|
||||
private ServiceBrokerProperties bindProperties() {
|
||||
|
||||
@@ -24,9 +24,9 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
public abstract class ServiceInstanceBindingIntegrationTest extends ControllerIntegrationTest {
|
||||
|
||||
public static final String SERVICE_INSTANCE_BINDING_ID = "service-instance-binding-id";
|
||||
protected static final String SERVICE_INSTANCE_BINDING_ID = "service-instance-binding-id";
|
||||
|
||||
protected static final String SERVICE_INSTANCES_ROOT_PATH = "/v2/service_instances/";
|
||||
private static final String SERVICE_INSTANCES_ROOT_PATH = "/v2/service_instances/";
|
||||
|
||||
protected String createRequestBody;
|
||||
|
||||
|
||||
@@ -66,4 +66,4 @@ public class ServiceMetadataTest {
|
||||
assertThat(actual).isEqualTo(BASE64_ENCODED_IMAGE_DATA);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,4 +111,5 @@ public final class ServiceFixture {
|
||||
.description("Description for Plan Three")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,8 @@ public class ApiVersionWebFluxAutoConfigurationTest {
|
||||
@Test
|
||||
public void apiVersionBeansAreCreatedFromCustomVersionProperty() {
|
||||
webApplicationContextRunner()
|
||||
.withUserConfiguration(ServicesConfiguration.class, CustomBrokerApiVersionConfigurationFromProperty.class)
|
||||
.withUserConfiguration(ServicesConfiguration.class,
|
||||
CustomBrokerApiVersionConfigurationFromProperty.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).getBean(BrokerApiVersion.class)
|
||||
.hasFieldOrPropertyWithValue("apiVersion", "42.321");
|
||||
@@ -101,7 +102,8 @@ public class ApiVersionWebFluxAutoConfigurationTest {
|
||||
@Test
|
||||
public void apiVersionBeansAreCreatedFromCustomVersionBeanOverridesProperty() {
|
||||
webApplicationContextRunner()
|
||||
.withUserConfiguration(ServicesConfiguration.class, CustomBrokerApiVersionConfigurationFromBeanAndProperty.class)
|
||||
.withUserConfiguration(ServicesConfiguration.class,
|
||||
CustomBrokerApiVersionConfigurationFromBeanAndProperty.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).getBean(BrokerApiVersion.class)
|
||||
.hasFieldOrPropertyWithValue("apiVersion", "99.999");
|
||||
@@ -123,18 +125,22 @@ public class ApiVersionWebFluxAutoConfigurationTest {
|
||||
|
||||
@Configuration
|
||||
public static class ServicesConfiguration {
|
||||
|
||||
@Bean
|
||||
public ServiceInstanceService serviceInstanceService() {
|
||||
return new TestServiceInstanceService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class CustomBrokerApiVersionConfigurationFromBean {
|
||||
|
||||
@Bean
|
||||
public BrokerApiVersion version() {
|
||||
return new BrokerApiVersion(API_VERSION_CURRENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -146,10 +152,12 @@ public class ApiVersionWebFluxAutoConfigurationTest {
|
||||
@Configuration
|
||||
@PropertySource("classpath:apiversion.properties")
|
||||
public static class CustomBrokerApiVersionConfigurationFromBeanAndProperty {
|
||||
|
||||
@Bean
|
||||
public BrokerApiVersion version() {
|
||||
return new BrokerApiVersion("99.999");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,5 @@ public class BasePathDoubleIntegrationTest extends AbstractBasePathWebApplicatio
|
||||
public void basePathWithAdditionalSegmentsNotFound() {
|
||||
assertNotFound("/api/broker/123/456");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,21 +20,22 @@ package org.springframework.cloud.servicebroker.autoconfigure.web.reactive;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class BasePathEmptyIntegrationTest extends AbstractBasePathWebApplicationIntegrationTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void noBasePathFound() {
|
||||
assertFound("", "null");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noBasePathWithPlatformIdFound() {
|
||||
assertFound("/123", "123");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void alternativeDoublePathNotFound() {
|
||||
assertNotFound("/api/broker");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alternativeTriplePathNotFound() {
|
||||
assertNotFound("/api/broker/123");
|
||||
@@ -44,4 +45,5 @@ public class BasePathEmptyIntegrationTest extends AbstractBasePathWebApplication
|
||||
public void alternativeQuadruplePathNotFound() {
|
||||
assertNotFound("/api/broker/123/456");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,4 +58,5 @@ public class BasePathSimpleIntegrationTest extends AbstractBasePathWebApplicatio
|
||||
public void basePathWithPrefixAndMultipleSuffixSegmentsNotFound() {
|
||||
assertNotFound("/api/broker/123/456");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,9 +81,12 @@ public class CatalogControllerIntegrationTest {
|
||||
private void assertCatalog(final String uri) {
|
||||
List<Plan> plans = serviceDefinition.getPlans();
|
||||
Schemas schemas = plans.get(1).getSchemas();
|
||||
Map<String, Object> createServiceInstanceSchema = schemas.getServiceInstanceSchema().getCreateMethodSchema().getParameters();
|
||||
Map<String, Object> updateServiceInstanceSchema = schemas.getServiceInstanceSchema().getUpdateMethodSchema().getParameters();
|
||||
Map<String, Object> createServiceBindingSchema = schemas.getServiceBindingSchema().getCreateMethodSchema().getParameters();
|
||||
Map<String, Object> createServiceInstanceSchema = schemas.getServiceInstanceSchema().getCreateMethodSchema()
|
||||
.getParameters();
|
||||
Map<String, Object> updateServiceInstanceSchema = schemas.getServiceInstanceSchema().getUpdateMethodSchema()
|
||||
.getParameters();
|
||||
Map<String, Object> createServiceBindingSchema = schemas.getServiceBindingSchema().getCreateMethodSchema()
|
||||
.getParameters();
|
||||
|
||||
client.get().uri(uri)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
@@ -114,7 +117,8 @@ public class CatalogControllerIntegrationTest {
|
||||
.jsonPath("$.services[0].plans[0].free").isEqualTo(plans.get(0).isFree())
|
||||
.jsonPath("$.services[0].plans[0].maintenance_info").isNotEmpty()
|
||||
.jsonPath("$.services[0].plans[0].maintenance_info.version").isEqualTo("1.0.0-alpha+001")
|
||||
.jsonPath("$.services[0].plans[0].maintenance_info.description").isEqualTo("Description for maintenance info")
|
||||
.jsonPath("$.services[0].plans[0].maintenance_info.description")
|
||||
.isEqualTo("Description for maintenance info")
|
||||
.jsonPath("$.services[0].plans[1].id").isEqualTo(plans.get(1).getId())
|
||||
.jsonPath("$.services[0].plans[1].name").isEqualTo(plans.get(1).getName())
|
||||
.jsonPath("$.services[0].plans[1].description").isEqualTo(plans.get(1).getDescription())
|
||||
@@ -122,17 +126,21 @@ public class CatalogControllerIntegrationTest {
|
||||
.jsonPath("$.services[0].plans[1].bindable").isEqualTo(plans.get(1).isBindable())
|
||||
.jsonPath("$.services[0].plans[1].free").isEqualTo(plans.get(1).isFree())
|
||||
.jsonPath("$.services[0].plans[1].plan_updateable").isEqualTo(plans.get(1).isPlanUpdateable())
|
||||
.jsonPath("$.services[0].plans[1].schemas.service_instance.create.parameters").isEqualTo(createServiceInstanceSchema)
|
||||
.jsonPath("$.services[0].plans[1].schemas.service_instance.update.parameters").isEqualTo(updateServiceInstanceSchema)
|
||||
.jsonPath("$.services[0].plans[1].schemas.service_binding.create.parameters").isEqualTo(createServiceBindingSchema)
|
||||
.jsonPath("$.services[0].plans[1].maximum_polling_duration").isEqualTo(plans.get(1).getMaximumPollingDuration())
|
||||
.jsonPath("$.services[0].plans[1].schemas.service_instance.create.parameters")
|
||||
.isEqualTo(createServiceInstanceSchema)
|
||||
.jsonPath("$.services[0].plans[1].schemas.service_instance.update.parameters")
|
||||
.isEqualTo(updateServiceInstanceSchema)
|
||||
.jsonPath("$.services[0].plans[1].schemas.service_binding.create.parameters")
|
||||
.isEqualTo(createServiceBindingSchema)
|
||||
.jsonPath("$.services[0].plans[1].maximum_polling_duration")
|
||||
.isEqualTo(plans.get(1).getMaximumPollingDuration())
|
||||
.jsonPath("$.services[0].plans[1].maintenance_info").doesNotExist()
|
||||
.jsonPath("$.services[0].plans[2].id").isEqualTo(plans.get(2).getId())
|
||||
.jsonPath("$.services[0].plans[2].name").isEqualTo(plans.get(2).getName())
|
||||
.jsonPath("$.services[0].plans[2].description").isEqualTo(plans.get(2).getDescription())
|
||||
.jsonPath("$.services[0].plans[2].free").isEqualTo(plans.get(2).isFree())
|
||||
.jsonPath("$.services[0].plans[2].id").isEqualTo(plans.get(2).getId())
|
||||
.jsonPath("$.services[0].plans[2].name").isEqualTo(plans.get(2).getName())
|
||||
.jsonPath("$.services[0].plans[2].description").isEqualTo(plans.get(2).getDescription())
|
||||
.jsonPath("$.services[0].plans[2].free").isEqualTo(plans.get(2).isFree())
|
||||
.jsonPath("$.services[0].plans[2].maintenance_info").doesNotExist()
|
||||
.jsonPath("$.services[0].plans[3]").doesNotExist()
|
||||
.jsonPath("$.services[0].plans[3]").doesNotExist()
|
||||
.jsonPath("$.services[1]").doesNotExist();
|
||||
}
|
||||
|
||||
|
||||
@@ -95,13 +95,13 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
.build());
|
||||
|
||||
client.put().uri(buildCreateUrl(PLATFORM_INSTANCE_ID, false))
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(createRequestBody)
|
||||
.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
|
||||
.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isCreated();
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(createRequestBody)
|
||||
.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
|
||||
.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isCreated();
|
||||
|
||||
CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding();
|
||||
assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId());
|
||||
@@ -203,11 +203,11 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
.build());
|
||||
|
||||
client.put().uri(buildCreateUrl())
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(createRequestBody)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isCreated();
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(createRequestBody)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isCreated();
|
||||
|
||||
CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
@@ -259,7 +259,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
public void createBindingWithUnknownServiceInstanceIdFails() throws Exception {
|
||||
setupCatalogService();
|
||||
|
||||
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
.willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));
|
||||
|
||||
client.put().uri(buildCreateUrl())
|
||||
@@ -294,7 +295,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
public void createBindingWithDuplicateIdFails() throws Exception {
|
||||
setupCatalogService();
|
||||
|
||||
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
.willThrow(new ServiceInstanceBindingExistsException(SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID));
|
||||
|
||||
client.put().uri(buildCreateUrl())
|
||||
@@ -306,7 +308,9 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
.expectStatus().isEqualTo(HttpStatus.CONFLICT)
|
||||
.expectBody()
|
||||
.jsonPath("$.description").isNotEmpty()
|
||||
.consumeWith(result -> assertDescriptionContains(result, String.format("serviceInstanceId=%s, bindingId=%s", SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID)));
|
||||
.consumeWith(result -> assertDescriptionContains(result,
|
||||
String.format("serviceInstanceId=%s, bindingId=%s", SERVICE_INSTANCE_ID,
|
||||
SERVICE_INSTANCE_BINDING_ID)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -412,15 +416,15 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
setupCatalogService();
|
||||
|
||||
setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder()
|
||||
.build());
|
||||
.build());
|
||||
|
||||
client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID, false))
|
||||
.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
|
||||
.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectBody()
|
||||
.json("{}");
|
||||
.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
|
||||
.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectBody()
|
||||
.json("{}");
|
||||
|
||||
then(serviceInstanceBindingService)
|
||||
.should()
|
||||
@@ -480,7 +484,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
public void deleteBindingWithUnknownInstanceIdFails() throws Exception {
|
||||
setupCatalogService();
|
||||
|
||||
given(serviceInstanceBindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
.willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));
|
||||
|
||||
client.delete().uri(buildDeleteUrl())
|
||||
@@ -496,7 +501,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
public void deleteBindingWithUnknownBindingIdFails() throws Exception {
|
||||
setupCatalogService();
|
||||
|
||||
given(serviceInstanceBindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
|
||||
.willThrow(new ServiceInstanceBindingDoesNotExistException(SERVICE_INSTANCE_BINDING_ID));
|
||||
|
||||
client.delete().uri(buildDeleteUrl())
|
||||
|
||||
@@ -218,11 +218,11 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.build());
|
||||
|
||||
client.put().uri(buildCreateUpdateUrl())
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(createRequestBody)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isCreated();
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(createRequestBody)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isCreated();
|
||||
|
||||
CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
@@ -243,7 +243,8 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.expectStatus().isEqualTo(HttpStatus.BAD_REQUEST)
|
||||
.expectBody()
|
||||
.jsonPath("$.description").isNotEmpty()
|
||||
.consumeWith(result -> assertDescriptionContains(result, String.format("id=%s", serviceDefinition.getId())));
|
||||
.consumeWith(
|
||||
result -> assertDescriptionContains(result, String.format("id=%s", serviceDefinition.getId())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -262,7 +263,8 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.expectBody()
|
||||
.jsonPath("$.description").isNotEmpty()
|
||||
.consumeWith(result -> assertDescriptionContains(result,
|
||||
String.format("serviceInstanceId=%s, serviceDefinitionId=%s", SERVICE_INSTANCE_ID, serviceDefinition.getId())));
|
||||
String.format("serviceInstanceId=%s, serviceDefinitionId=%s", SERVICE_INSTANCE_ID,
|
||||
serviceDefinition.getId())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -440,11 +442,11 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.build());
|
||||
|
||||
client.delete().uri(buildDeleteUrl())
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectBody()
|
||||
.json("{}");
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectBody()
|
||||
.json("{}");
|
||||
|
||||
DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
@@ -476,7 +478,8 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.expectStatus().isEqualTo(HttpStatus.BAD_REQUEST)
|
||||
.expectBody()
|
||||
.jsonPath("$.description").isNotEmpty()
|
||||
.consumeWith(result -> assertDescriptionContains(result, String.format("id=%s", serviceDefinition.getId())));
|
||||
.consumeWith(
|
||||
result -> assertDescriptionContains(result, String.format("id=%s", serviceDefinition.getId())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -568,16 +571,16 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
setupCatalogService();
|
||||
|
||||
setupServiceInstanceService(UpdateServiceInstanceResponse.builder()
|
||||
.build());
|
||||
.build());
|
||||
|
||||
client.patch().uri(buildCreateUpdateUrl())
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(updateRequestBodyWithPlan)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectBody()
|
||||
.json("{}");
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(updateRequestBodyWithPlan)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectBody()
|
||||
.json("{}");
|
||||
|
||||
UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
@@ -639,7 +642,8 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)
|
||||
.expectBody()
|
||||
.jsonPath("$.description").isNotEmpty()
|
||||
.consumeWith(result -> assertDescriptionContains(result, String.format("id=%s", serviceDefinition.getId())));
|
||||
.consumeWith(
|
||||
result -> assertDescriptionContains(result, String.format("id=%s", serviceDefinition.getId())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -111,4 +111,5 @@ public class ApiVersionInterceptorIntegrationTest {
|
||||
.setControllerAdvice(ServiceBrokerWebMvcExceptionHandler.class)
|
||||
.setMessageConverters(new MappingJackson2HttpMessageConverter()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,4 +94,5 @@ public class ApiVersionInterceptorTest {
|
||||
ApiVersionInterceptor interceptor = new ApiVersionInterceptor(brokerApiVersion);
|
||||
assertThat(interceptor.preHandle(request, response, null)).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,7 +92,8 @@ public class ApiVersionWebMvcAutoConfigurationTest {
|
||||
@Test
|
||||
public void apiVersionBeansAreCreatedFromCustomVersionProperty() {
|
||||
webApplicationContextRunner()
|
||||
.withUserConfiguration(ServicesConfiguration.class, CustomBrokerApiVersionConfigurationFromProperty.class)
|
||||
.withUserConfiguration(ServicesConfiguration.class,
|
||||
CustomBrokerApiVersionConfigurationFromProperty.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).getBean(BrokerApiVersion.class)
|
||||
.hasFieldOrPropertyWithValue("apiVersion", "42.321");
|
||||
@@ -104,7 +105,8 @@ public class ApiVersionWebMvcAutoConfigurationTest {
|
||||
@Test
|
||||
public void apiVersionBeansAreCreatedFromCustomVersionBeanOverridesProperty() {
|
||||
webApplicationContextRunner()
|
||||
.withUserConfiguration(ServicesConfiguration.class, CustomBrokerApiVersionConfigurationFromBeanAndProperty.class)
|
||||
.withUserConfiguration(ServicesConfiguration.class,
|
||||
CustomBrokerApiVersionConfigurationFromBeanAndProperty.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).getBean(BrokerApiVersion.class)
|
||||
.hasFieldOrPropertyWithValue("apiVersion", "99.999");
|
||||
@@ -127,18 +129,22 @@ public class ApiVersionWebMvcAutoConfigurationTest {
|
||||
|
||||
@Configuration
|
||||
public static class ServicesConfiguration {
|
||||
|
||||
@Bean
|
||||
public ServiceInstanceService serviceInstanceService() {
|
||||
return new TestServiceInstanceService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class CustomBrokerApiVersionConfigurationFromBean {
|
||||
|
||||
@Bean
|
||||
public BrokerApiVersion version() {
|
||||
return new BrokerApiVersion(API_VERSION_CURRENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -150,10 +156,12 @@ public class ApiVersionWebMvcAutoConfigurationTest {
|
||||
@Configuration
|
||||
@PropertySource("classpath:apiversion.properties")
|
||||
public static class CustomBrokerApiVersionConfigurationFromBeanAndProperty {
|
||||
|
||||
@Bean
|
||||
public BrokerApiVersion version() {
|
||||
return new BrokerApiVersion("99.999");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class BasePathDoubleIntegrationTest extends AbstractBasePathWebApplicatio
|
||||
public void noBasePathNotFound() throws Exception {
|
||||
assertNotFound("");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noBasePathWithPlatformIdNotFound() throws Exception {
|
||||
assertNotFound("/123");
|
||||
@@ -47,4 +47,5 @@ public class BasePathDoubleIntegrationTest extends AbstractBasePathWebApplicatio
|
||||
public void basePathWithAdditionalSegmentsNotFound() throws Exception {
|
||||
assertNotFound("/api/broker/123/456");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,21 +20,22 @@ package org.springframework.cloud.servicebroker.autoconfigure.web.servlet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class BasePathEmptyIntegrationTest extends AbstractBasePathWebApplicationIntegrationTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void noBasePathFound() throws Exception {
|
||||
assertFound("", "null");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noBasePathWithPlatformIdFound() throws Exception {
|
||||
assertFound("/123", "123");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void alternativeDoublePathNotFound() throws Exception {
|
||||
assertNotFound("/api/broker");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alternativeTriplePathNotFound() throws Exception {
|
||||
assertNotFound("/api/broker/123");
|
||||
@@ -44,4 +45,5 @@ public class BasePathEmptyIntegrationTest extends AbstractBasePathWebApplication
|
||||
public void alternativeQuadruplePathNotFound() throws Exception {
|
||||
assertNotFound("/api/broker/123/456");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ public class BasePathSimpleIntegrationTest extends AbstractBasePathWebApplicatio
|
||||
public void noBasePathNotFound() throws Exception {
|
||||
assertNotFound("");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void alternativePathNotFound() throws Exception {
|
||||
assertNotFound("/123");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void basePathWithPrefixSegmentNotFound() throws Exception {
|
||||
assertNotFound("/api/broker");
|
||||
|
||||
@@ -109,9 +109,12 @@ public class CatalogControllerIntegrationTest {
|
||||
List<Plan> plans = serviceDefinition.getPlans();
|
||||
Schemas schemas = plans.get(1).getSchemas();
|
||||
|
||||
Map<String, Object> createServiceInstanceSchema = schemas.getServiceInstanceSchema().getCreateMethodSchema().getParameters();
|
||||
Map<String, Object> updateServiceInstanceSchema = schemas.getServiceInstanceSchema().getUpdateMethodSchema().getParameters();
|
||||
Map<String, Object> createServiceBindingSchema = schemas.getServiceBindingSchema().getCreateMethodSchema().getParameters();
|
||||
Map<String, Object> createServiceInstanceSchema = schemas.getServiceInstanceSchema().getCreateMethodSchema()
|
||||
.getParameters();
|
||||
Map<String, Object> updateServiceInstanceSchema = schemas.getServiceInstanceSchema().getUpdateMethodSchema()
|
||||
.getParameters();
|
||||
Map<String, Object> createServiceBindingSchema = schemas.getServiceBindingSchema().getCreateMethodSchema()
|
||||
.getParameters();
|
||||
|
||||
ResultActions resultActions = this.mockMvc.perform(asyncDispatch(mvcResult));
|
||||
|
||||
@@ -130,20 +133,32 @@ public class CatalogControllerIntegrationTest {
|
||||
))
|
||||
.andExpect(jsonPath("$.services[*].metadata.features[*]", contains(features.get(0), features.get(1))))
|
||||
.andExpect(jsonPath("$.services[*].plans[*]", hasSize(3)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].id", containsInAnyOrder(plans.get(0).getId(), plans.get(1).getId(), plans.get(2).getId())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].name", containsInAnyOrder(plans.get(0).getName(), plans.get(1).getName(), plans.get(2).getName())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].description", containsInAnyOrder(plans.get(0).getDescription(), plans.get(1).getDescription(), plans.get(2).getDescription())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].id",
|
||||
containsInAnyOrder(plans.get(0).getId(), plans.get(1).getId(), plans.get(2).getId())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].name",
|
||||
containsInAnyOrder(plans.get(0).getName(), plans.get(1).getName(), plans.get(2).getName())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].description",
|
||||
containsInAnyOrder(plans.get(0).getDescription(), plans.get(1).getDescription(),
|
||||
plans.get(2).getDescription())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].metadata", contains(plans.get(1).getMetadata())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].bindable", hasSize(1)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].bindable", contains(plans.get(1).isBindable())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].free", containsInAnyOrder(plans.get(0).isFree(), plans.get(1).isFree(), plans.get(2).isFree())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].plan_updateable", contains(plans.get(1).isPlanUpdateable())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].maximum_polling_duration", contains(plans.get(1).getMaximumPollingDuration())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].schemas.service_instance.create.parameters", contains(createServiceInstanceSchema)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].schemas.service_instance.update.parameters", contains(updateServiceInstanceSchema)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].schemas.service_binding.create.parameters", contains(createServiceBindingSchema)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].maintenance_info.version", contains(plans.get(0).getMaintenanceInfo().getVersion())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].maintenance_info.description", contains(plans.get(0).getMaintenanceInfo().getDescription())));
|
||||
.andExpect(jsonPath("$.services[*].plans[*].free",
|
||||
containsInAnyOrder(plans.get(0).isFree(), plans.get(1).isFree(), plans.get(2).isFree())))
|
||||
.andExpect(
|
||||
jsonPath("$.services[*].plans[*].plan_updateable", contains(plans.get(1).isPlanUpdateable())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].maximum_polling_duration",
|
||||
contains(plans.get(1).getMaximumPollingDuration())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].schemas.service_instance.create.parameters",
|
||||
contains(createServiceInstanceSchema)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].schemas.service_instance.update.parameters",
|
||||
contains(updateServiceInstanceSchema)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].schemas.service_binding.create.parameters",
|
||||
contains(createServiceBindingSchema)))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].maintenance_info.version",
|
||||
contains(plans.get(0).getMaintenanceInfo().getVersion())))
|
||||
.andExpect(jsonPath("$.services[*].plans[*].maintenance_info.description",
|
||||
contains(plans.get(0).getMaintenanceInfo().getDescription())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ import static org.hamcrest.core.Is.is;
|
||||
import static org.hamcrest.core.StringContains.containsString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.doThrow;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.springframework.cloud.servicebroker.model.ServiceBrokerRequest.API_INFO_LOCATION_HEADER;
|
||||
import static org.springframework.cloud.servicebroker.model.ServiceBrokerRequest.ORIGINATING_IDENTITY_HEADER;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
|
||||
@@ -122,7 +122,7 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
.andReturn();
|
||||
|
||||
mockMvc.perform(asyncDispatch(mvcResult))
|
||||
.andExpect(status().isCreated());
|
||||
.andExpect(status().isCreated());
|
||||
|
||||
CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
@@ -279,7 +279,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
public void createBindingWithUnknownServiceInstanceIdFails() throws Exception {
|
||||
setupCatalogService();
|
||||
|
||||
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
.willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl())
|
||||
@@ -314,7 +315,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
public void createBindingWithDuplicateIdFails() throws Exception {
|
||||
setupCatalogService();
|
||||
|
||||
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
given(serviceInstanceBindingService
|
||||
.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class)))
|
||||
.willThrow(new ServiceInstanceBindingExistsException(SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID));
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl())
|
||||
@@ -514,8 +516,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
.andReturn();
|
||||
|
||||
mockMvc.perform(asyncDispatch(mvcResult))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("{}"));
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("{}"));
|
||||
|
||||
then(serviceInstanceBindingService)
|
||||
.should()
|
||||
@@ -532,7 +534,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
setupCatalogService();
|
||||
|
||||
doThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID))
|
||||
.when(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
|
||||
.when(serviceInstanceBindingService)
|
||||
.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl())
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -549,7 +552,8 @@ public class ServiceInstanceBindingControllerIntegrationTest extends AbstractSer
|
||||
setupCatalogService();
|
||||
|
||||
doThrow(new ServiceInstanceBindingDoesNotExistException(SERVICE_INSTANCE_BINDING_ID))
|
||||
.when(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
|
||||
.when(serviceInstanceBindingService)
|
||||
.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl())
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
|
||||
@@ -255,7 +255,7 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.andReturn();
|
||||
|
||||
mockMvc.perform(asyncDispatch(mvcResult))
|
||||
.andExpect(status().isCreated());
|
||||
.andExpect(status().isCreated());
|
||||
|
||||
CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
@@ -388,7 +388,7 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
@Test
|
||||
public void getServiceInstanceSucceeds() throws Exception {
|
||||
setupServiceInstanceService(GetServiceInstanceResponse.builder()
|
||||
.build());
|
||||
.build());
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(get(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, false))
|
||||
.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
|
||||
@@ -504,8 +504,8 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.andReturn();
|
||||
|
||||
mockMvc.perform(asyncDispatch(mvcResult))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("{}"));
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("{}"));
|
||||
|
||||
DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
@@ -646,8 +646,8 @@ public class ServiceInstanceControllerIntegrationTest extends AbstractServiceIns
|
||||
.andReturn();
|
||||
|
||||
mockMvc.perform(asyncDispatch(mvcResult))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("{}"));
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("{}"));
|
||||
|
||||
UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
|
||||
assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
|
||||
|
||||
@@ -16,22 +16,24 @@
|
||||
|
||||
package org.springframework.cloud.servicebroker.annotation;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@RestController
|
||||
@RequestMapping("${spring.cloud.openservicebroker.base-path:}")
|
||||
public @interface ServiceBrokerRestController {
|
||||
|
||||
@AliasFor(annotation = RestController.class)
|
||||
String value() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Annotations to support configuring Service Brokers
|
||||
*/
|
||||
package org.springframework.cloud.servicebroker.annotation;
|
||||
package org.springframework.cloud.servicebroker.annotation;
|
||||
|
||||
@@ -56,6 +56,7 @@ public class BaseController {
|
||||
|
||||
/**
|
||||
* Construct a new {@link BaseController}
|
||||
*
|
||||
* @param catalogService the catalog service
|
||||
*/
|
||||
public BaseController(CatalogService catalogService) {
|
||||
@@ -64,6 +65,7 @@ public class BaseController {
|
||||
|
||||
/**
|
||||
* Sets common headers for the request
|
||||
*
|
||||
* @param request the request in which to set the headers
|
||||
* @param platformInstanceId the platform instance ID
|
||||
* @param apiInfoLocation location of the API info endpoint of the platform instance
|
||||
@@ -71,7 +73,7 @@ public class BaseController {
|
||||
* @return the request with the applied headers
|
||||
*/
|
||||
protected Mono<ServiceBrokerRequest> configureCommonRequestFields(ServiceBrokerRequest request, String platformInstanceId,
|
||||
String apiInfoLocation, String originatingIdentityString) {
|
||||
String apiInfoLocation, String originatingIdentityString) {
|
||||
request.setPlatformInstanceId(platformInstanceId);
|
||||
request.setApiInfoLocation(apiInfoLocation);
|
||||
request.setOriginatingIdentity(parseOriginatingIdentity(originatingIdentityString));
|
||||
@@ -80,6 +82,7 @@ public class BaseController {
|
||||
|
||||
/**
|
||||
* Sets common headers for the request
|
||||
*
|
||||
* @param request the request in which to set the headers
|
||||
* @param platformInstanceId the platform instance ID
|
||||
* @param apiInfoLocation location of the API info endpoint of the platform instance
|
||||
@@ -88,8 +91,7 @@ public class BaseController {
|
||||
* @return the request with the applied headers
|
||||
*/
|
||||
protected Mono<AsyncServiceBrokerRequest> configureCommonRequestFields(AsyncServiceBrokerRequest request, String platformInstanceId,
|
||||
String apiInfoLocation, String originatingIdentityString,
|
||||
boolean asyncAccepted) {
|
||||
String apiInfoLocation, String originatingIdentityString, boolean asyncAccepted) {
|
||||
request.setAsyncAccepted(asyncAccepted);
|
||||
return configureCommonRequestFields(request, platformInstanceId, apiInfoLocation, originatingIdentityString)
|
||||
.cast(AsyncServiceBrokerRequest.class);
|
||||
@@ -97,6 +99,7 @@ public class BaseController {
|
||||
|
||||
/**
|
||||
* Find the Service Definition for the provided ID. Emits an error if not found.
|
||||
*
|
||||
* @param serviceDefinitionId the service definition ID
|
||||
* @return the Service Definition
|
||||
*/
|
||||
@@ -107,6 +110,7 @@ public class BaseController {
|
||||
|
||||
/**
|
||||
* Find the Service Definition for the provided ID, or empty if not found.
|
||||
*
|
||||
* @param serviceDefinitionId the service definition ID
|
||||
* @return the Service Definition
|
||||
*/
|
||||
@@ -116,6 +120,7 @@ public class BaseController {
|
||||
|
||||
/**
|
||||
* Find the Plan for the Service Definition and Plan ID, or empty if not found.
|
||||
*
|
||||
* @param serviceDefinition the Service Definition
|
||||
* @param planId the plan ID
|
||||
* @return the Plan
|
||||
@@ -130,6 +135,7 @@ public class BaseController {
|
||||
|
||||
/**
|
||||
* Find the Plan for the Service Definition and Plan ID. Emits an error if not found.
|
||||
*
|
||||
* @param serviceDefinition the Service Definition
|
||||
* @param planId the plan ID
|
||||
* @return the Plan
|
||||
@@ -204,11 +210,12 @@ public class BaseController {
|
||||
|
||||
private Map<String, Object> readJsonFromString(String value) throws IOException {
|
||||
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
|
||||
return objectMapper.readValue(value, new TypeReference<Map<String,Object>>() {});
|
||||
return objectMapper.readValue(value, new TypeReference<Map<String, Object>>() {});
|
||||
}
|
||||
|
||||
/**
|
||||
* If an asynchronous request is received, then return HTTP 202 Accepted, otherwise HTTP 200 OK
|
||||
*
|
||||
* @param response the response
|
||||
* @return the HTTP status
|
||||
*/
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
/**
|
||||
* Provide endpoints for the catalog API.
|
||||
*
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#catalog-management">Open Service Broker API specification</a>
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
* @author Scott Frederick
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#catalog-management">Open
|
||||
* Service Broker API specification</a>
|
||||
*/
|
||||
@ServiceBrokerRestController
|
||||
public class CatalogController extends BaseController {
|
||||
|
||||
@@ -318,6 +318,7 @@ public abstract class ServiceBrokerExceptionHandler {
|
||||
|
||||
/**
|
||||
* Format an error message for the exception
|
||||
*
|
||||
* @param ex the exception
|
||||
* @return the error message
|
||||
*/
|
||||
@@ -328,6 +329,7 @@ public abstract class ServiceBrokerExceptionHandler {
|
||||
|
||||
/**
|
||||
* Format an error message for the exception
|
||||
*
|
||||
* @param ex the exception
|
||||
* @return the error message
|
||||
*/
|
||||
@@ -337,6 +339,7 @@ public abstract class ServiceBrokerExceptionHandler {
|
||||
|
||||
/**
|
||||
* Create an error message object
|
||||
*
|
||||
* @param message the text of the message
|
||||
* @return the error message
|
||||
*/
|
||||
@@ -346,6 +349,7 @@ public abstract class ServiceBrokerExceptionHandler {
|
||||
|
||||
/**
|
||||
* Creates an error message for binding errors
|
||||
*
|
||||
* @param ex the exception
|
||||
* @param result the binding result
|
||||
* @return the error message
|
||||
@@ -359,5 +363,4 @@ public abstract class ServiceBrokerExceptionHandler {
|
||||
return getErrorResponse(message.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,5 @@ public class ServiceBrokerWebMvcExceptionHandler extends ServiceBrokerExceptionH
|
||||
LOG.error(UNPROCESSABLE_REQUEST, ex);
|
||||
return getErrorResponse(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.cloud.servicebroker.controller;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -52,12 +53,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* Provide endpoints for the service bindings API.
|
||||
*
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#binding">Open Service Broker API specification</a>
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#binding">Open Service Broker
|
||||
* API specification</a>
|
||||
*/
|
||||
@ServiceBrokerRestController
|
||||
public class ServiceInstanceBindingController extends BaseController {
|
||||
@@ -116,13 +117,15 @@ public class ServiceInstanceBindingController extends BaseController {
|
||||
return request;
|
||||
}))
|
||||
.cast(AsyncServiceBrokerRequest.class)
|
||||
.flatMap(req -> configureCommonRequestFields(req, pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE),
|
||||
.flatMap(req -> configureCommonRequestFields(req,
|
||||
pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE),
|
||||
apiInfoLocation, originatingIdentityString, acceptsIncomplete))
|
||||
.cast(CreateServiceInstanceBindingRequest.class)
|
||||
.flatMap(req -> service.createServiceInstanceBinding(req)
|
||||
.doOnRequest(v -> LOG.debug("Creating a service instance binding: request={}", req))
|
||||
.doOnSuccess(response -> LOG.debug("Creating a service instance binding succeeded: serviceInstanceId={}, bindingId={}, response={}",
|
||||
serviceInstanceId, bindingId, response)))
|
||||
.doOnSuccess(response -> LOG
|
||||
.debug("Creating a service instance binding succeeded: serviceInstanceId={}, bindingId={}, response={}",
|
||||
serviceInstanceId, bindingId, response)))
|
||||
.map(response -> new ResponseEntity<>(response, getCreateResponseCode(response)))
|
||||
.switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.CREATED)));
|
||||
}
|
||||
@@ -166,7 +169,8 @@ public class ServiceInstanceBindingController extends BaseController {
|
||||
.build())
|
||||
.flatMap(req -> service.getServiceInstanceBinding(req)
|
||||
.doOnRequest(v -> LOG.debug("Getting a service instance binding: request={}", req))
|
||||
.doOnSuccess(response -> LOG.debug("Getting a service instance binding succeeded: bindingId={}", bindingId)))
|
||||
.doOnSuccess(response -> LOG
|
||||
.debug("Getting a service instance binding succeeded: bindingId={}", bindingId)))
|
||||
.map(response -> new ResponseEntity<>(response, HttpStatus.OK))
|
||||
.switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK)))
|
||||
.onErrorResume(e -> {
|
||||
@@ -214,13 +218,17 @@ public class ServiceInstanceBindingController extends BaseController {
|
||||
.originatingIdentity(parseOriginatingIdentity(originatingIdentityString))
|
||||
.build())
|
||||
.flatMap(request -> service.getLastOperation(request)
|
||||
.doOnRequest(v -> LOG.debug("Getting service instance binding last operation: request={}", request))
|
||||
.doOnSuccess(aVoid -> LOG.debug("Getting service instance binding last operation succeeded: serviceInstanceId={}, bindingId={}",
|
||||
serviceInstanceId, bindingId))
|
||||
.doOnRequest(
|
||||
v -> LOG.debug("Getting service instance binding last operation: request={}", request))
|
||||
.doOnSuccess(aVoid -> LOG
|
||||
.debug("Getting service instance binding last operation succeeded: serviceInstanceId={}, bindingId={}",
|
||||
serviceInstanceId, bindingId))
|
||||
.doOnError(e -> LOG.debug(e.getMessage(), e)))
|
||||
.flatMap(response -> Mono.just(response.getState().equals(OperationState.SUCCEEDED) && response.isDeleteOperation())
|
||||
.flatMap(response -> Mono
|
||||
.just(response.getState().equals(OperationState.SUCCEEDED) && response.isDeleteOperation())
|
||||
.flatMap(isSuccessfulDelete ->
|
||||
Mono.just(new ResponseEntity<>(response, isSuccessfulDelete ? HttpStatus.GONE : HttpStatus.OK))));
|
||||
Mono.just(new ResponseEntity<>(response,
|
||||
isSuccessfulDelete ? HttpStatus.GONE : HttpStatus.OK))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,13 +266,15 @@ public class ServiceInstanceBindingController extends BaseController {
|
||||
.planId(planId)
|
||||
.serviceDefinition(serviceDefinition)
|
||||
.asyncAccepted(acceptsIncomplete)
|
||||
.platformInstanceId(pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE))
|
||||
.platformInstanceId(
|
||||
pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE))
|
||||
.apiInfoLocation(apiInfoLocation)
|
||||
.originatingIdentity(parseOriginatingIdentity(originatingIdentityString))
|
||||
.build()))
|
||||
.flatMap(req -> service.deleteServiceInstanceBinding(req)
|
||||
.doOnRequest(v -> LOG.debug("Deleting a service instance binding: request={}", req))
|
||||
.doOnSuccess(aVoid -> LOG.debug("Deleting a service instance binding succeeded: bindingId={}", bindingId))
|
||||
.doOnSuccess(aVoid -> LOG
|
||||
.debug("Deleting a service instance binding succeeded: bindingId={}", bindingId))
|
||||
.doOnError(e -> LOG.debug(e.getMessage(), e)))
|
||||
.map(response -> new ResponseEntity<>(response, getAsyncResponseCode(response)))
|
||||
.switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK)))
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.cloud.servicebroker.controller;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -54,11 +55,11 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
/**
|
||||
* Provide endpoints for the service instances API.
|
||||
*
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#provisioning">Open Service Broker API specification</a>
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
* @author Scott Frederick
|
||||
* @author Roy Clarkson
|
||||
* @see <a href="https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#provisioning">Open Service
|
||||
* Broker API specification</a>
|
||||
*/
|
||||
@ServiceBrokerRestController
|
||||
public class ServiceInstanceController extends BaseController {
|
||||
@@ -112,7 +113,8 @@ public class ServiceInstanceController extends BaseController {
|
||||
req.setServiceDefinition(serviceDefinition);
|
||||
return req;
|
||||
}))
|
||||
.flatMap(req -> configureCommonRequestFields(req, pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation,
|
||||
.flatMap(req -> configureCommonRequestFields(req,
|
||||
pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation,
|
||||
originatingIdentityString, acceptsIncomplete))
|
||||
.cast(CreateServiceInstanceRequest.class)
|
||||
.flatMap(req -> service.createServiceInstance(req)
|
||||
@@ -160,8 +162,9 @@ public class ServiceInstanceController extends BaseController {
|
||||
.build())
|
||||
.flatMap(request -> service.getServiceInstance(request)
|
||||
.doOnRequest(v -> LOG.debug("Getting service instance: request={}", request))
|
||||
.doOnSuccess(response -> LOG.debug("Getting service instance succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response)))
|
||||
.doOnSuccess(response -> LOG
|
||||
.debug("Getting service instance succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response)))
|
||||
.map(response -> new ResponseEntity<>(response, HttpStatus.OK))
|
||||
.switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK)))
|
||||
.onErrorResume(e -> {
|
||||
@@ -206,11 +209,13 @@ public class ServiceInstanceController extends BaseController {
|
||||
.build())
|
||||
.flatMap(request -> service.getLastOperation(request)
|
||||
.doOnRequest(v -> LOG.debug("Getting service instance last operation: request={}", request))
|
||||
.doOnSuccess(response -> LOG.debug("Getting service instance last operation succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response))
|
||||
.doOnSuccess(response -> LOG
|
||||
.debug("Getting service instance last operation succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response))
|
||||
)
|
||||
.map(response -> {
|
||||
boolean isSuccessfulDelete = response.getState().equals(OperationState.SUCCEEDED) && response.isDeleteOperation();
|
||||
boolean isSuccessfulDelete = response.getState().equals(OperationState.SUCCEEDED) && response
|
||||
.isDeleteOperation();
|
||||
return new ResponseEntity<>(response, isSuccessfulDelete ? HttpStatus.GONE : HttpStatus.OK);
|
||||
});
|
||||
}
|
||||
@@ -245,14 +250,16 @@ public class ServiceInstanceController extends BaseController {
|
||||
.planId(planId)
|
||||
.serviceDefinition(serviceDefinition)
|
||||
.asyncAccepted(acceptsIncomplete)
|
||||
.platformInstanceId(pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE))
|
||||
.platformInstanceId(
|
||||
pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE))
|
||||
.apiInfoLocation(apiInfoLocation)
|
||||
.originatingIdentity(parseOriginatingIdentity(originatingIdentityString))
|
||||
.build()))
|
||||
.flatMap(request -> service.deleteServiceInstance(request)
|
||||
.doOnRequest(v -> LOG.debug("Deleting a service instance: request={}", request))
|
||||
.doOnSuccess(response -> LOG.debug("Deleting a service instance succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response))
|
||||
.doOnSuccess(response -> LOG
|
||||
.debug("Deleting a service instance succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response))
|
||||
.doOnError(e -> LOG.debug("Service instance does not exist: ", e)))
|
||||
.map(response -> new ResponseEntity<>(response, getAsyncResponseCode(response)))
|
||||
.switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK)))
|
||||
@@ -297,13 +304,15 @@ public class ServiceInstanceController extends BaseController {
|
||||
req.setServiceDefinition(serviceDefinition);
|
||||
return req;
|
||||
}))
|
||||
.flatMap(req -> configureCommonRequestFields(req, pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation,
|
||||
.flatMap(req -> configureCommonRequestFields(req,
|
||||
pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation,
|
||||
originatingIdentityString, acceptsIncomplete))
|
||||
.cast(UpdateServiceInstanceRequest.class)
|
||||
.flatMap(req -> service.updateServiceInstance(req)
|
||||
.doOnRequest(v -> LOG.debug("Updating a service instance: request={}", request))
|
||||
.doOnSuccess(response -> LOG.debug("Updating a service instance succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response)))
|
||||
.doOnSuccess(response -> LOG
|
||||
.debug("Updating a service instance succeeded: serviceInstanceId={}, response={}",
|
||||
serviceInstanceId, response)))
|
||||
.map(response -> new ResponseEntity<>(response, getAsyncResponseCode(response)))
|
||||
.switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK)));
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Provides Service Broker API endpoints
|
||||
*/
|
||||
package org.springframework.cloud.servicebroker.controller;
|
||||
package org.springframework.cloud.servicebroker.controller;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Provides a formatted message indicating that the service broker does not support the version of the
|
||||
* Open Service Broker API provided by the platform.
|
||||
* Provides a formatted message indicating that the service broker does not support the version of the Open Service
|
||||
* Broker API provided by the platform.
|
||||
*/
|
||||
public final class ServiceBrokerApiVersionErrorMessage {
|
||||
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the version of the API supported by the broker doesn't match the version
|
||||
* provided by the platform.
|
||||
* Thrown to indicate that the version of the API supported by the broker doesn't match the version provided by the
|
||||
* platform.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 412 PRECONDITION FAILED}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 412 PRECONDITION FAILED} being returned to the
|
||||
* platform.
|
||||
*/
|
||||
public class ServiceBrokerApiVersionException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = -6792404679608443775L;
|
||||
|
||||
/**
|
||||
@@ -47,4 +48,5 @@ public class ServiceBrokerApiVersionException extends ServiceBrokerException {
|
||||
public ServiceBrokerApiVersionException(String errorCode, String expectedVersion, String providedVersion) {
|
||||
super(errorCode, ServiceBrokerApiVersionErrorMessage.from(expectedVersion, providedVersion).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
* Thrown to indicate that the API version header is missing from the request.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 400 BAD REQUEST}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 400 BAD REQUEST} being returned to the
|
||||
* platform.
|
||||
*/
|
||||
public class ServiceBrokerApiVersionMissingException extends ServiceBrokerException {
|
||||
|
||||
@@ -45,4 +45,5 @@ public class ServiceBrokerApiVersionMissingException extends ServiceBrokerExcept
|
||||
public ServiceBrokerApiVersionMissingException(String errorCode, String expectedVersion) {
|
||||
super(errorCode, ServiceBrokerApiVersionErrorMessage.from(expectedVersion, "null").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,15 +18,20 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a service broker requires that the platform support asynchronous processing of operations.
|
||||
* This requires that the {@literal accepts_incomplete} request parameter be {@literal true} in requests
|
||||
* from the platform.
|
||||
*
|
||||
* This requires that the {@literal accepts_incomplete} request parameter be {@literal true} in requests from the
|
||||
* platform.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*/
|
||||
public class ServiceBrokerAsyncRequiredException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = -6116656797448174365L;
|
||||
|
||||
/**
|
||||
* Error code representing that asynchronous processing is required by the service broker
|
||||
*/
|
||||
public final static String ASYNC_REQUIRED_ERROR = "AsyncRequired";
|
||||
|
||||
/**
|
||||
@@ -37,4 +42,5 @@ public class ServiceBrokerAsyncRequiredException extends ServiceBrokerException
|
||||
public ServiceBrokerAsyncRequiredException(String message) {
|
||||
super(ASYNC_REQUIRED_ERROR, "Service broker requires async operations: " + message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,17 +17,22 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the service broker received a binding request without an application resource,
|
||||
* but only supports binding to applications.
|
||||
* Thrown to indicate that the service broker received a binding request without an application resource, but only
|
||||
* supports binding to applications.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class ServiceBrokerBindingRequiresAppException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = -5605297457258622988L;
|
||||
|
||||
/**
|
||||
* Error code representing that the service broker received a binding request without an application resource
|
||||
*/
|
||||
public final static String APP_REQUIRED_ERROR = "RequiresApp";
|
||||
|
||||
/**
|
||||
@@ -48,4 +53,5 @@ public class ServiceBrokerBindingRequiresAppException extends ServiceBrokerExcep
|
||||
public ServiceBrokerBindingRequiresAppException(String message, Throwable cause) {
|
||||
super(APP_REQUIRED_ERROR, message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,13 +20,18 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
* Thrown to indicate that the service broker received concurrent requests to modify a resource.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class ServiceBrokerConcurrencyException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = -2521415489841815405L;
|
||||
|
||||
/**
|
||||
* Error code indicating the service broker received concurrent requests to modify a resource
|
||||
*/
|
||||
public final static String CONCURRENCY_ERROR = "ConcurrencyError";
|
||||
|
||||
/**
|
||||
@@ -47,4 +52,5 @@ public class ServiceBrokerConcurrencyException extends ServiceBrokerException {
|
||||
public ServiceBrokerConcurrencyException(String message, Throwable cause) {
|
||||
super(CONCURRENCY_ERROR, message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a request to create a service instance or binding was received while
|
||||
* asynchronous creation of the identical service instance or binding is in progress.
|
||||
* Thrown to indicate that a request to create a service instance or binding was received while asynchronous creation of
|
||||
* the identical service instance or binding is in progress.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 202 ACCEPTED}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 202 ACCEPTED} being returned to the platform.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
@@ -62,4 +61,5 @@ public class ServiceBrokerCreateOperationInProgressException extends ServiceBrok
|
||||
private static String prependMessagePrefix(String operation) {
|
||||
return MESSAGE_PREFIX + ": operation=" + operation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a request to delete a service instance or binding was received while
|
||||
* asynchronous deletion of the identical service instance or binding is in progress.
|
||||
* Thrown to indicate that a request to delete a service instance or binding was received while asynchronous deletion of
|
||||
* the identical service instance or binding is in progress.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 202 ACCEPTED}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 202 ACCEPTED} being returned to the platform.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
@@ -62,4 +61,5 @@ public class ServiceBrokerDeleteOperationInProgressException extends ServiceBrok
|
||||
private static String prependMessagePrefix(String operation) {
|
||||
return MESSAGE_PREFIX + ": operation=" + operation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,18 +19,19 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
import org.springframework.cloud.servicebroker.model.error.ErrorMessage;
|
||||
|
||||
/**
|
||||
* Thrown to indicate underlying service broker errors (like connectivity to the service
|
||||
* being brokered) not covered by a more specific exception.
|
||||
* Thrown to indicate underlying service broker errors (like connectivity to the service being brokered) not covered by
|
||||
* a more specific exception.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 500 INTERNAL SERVER ERROR}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 500 INTERNAL SERVER ERROR} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
*/
|
||||
public class ServiceBrokerException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -5544859893499349135L;
|
||||
|
||||
private final ErrorMessage errorMessage;
|
||||
|
||||
/**
|
||||
@@ -90,4 +91,5 @@ public class ServiceBrokerException extends RuntimeException {
|
||||
public ErrorMessage getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that parameters passed in the originating identity header are not
|
||||
* understood by the service broker.
|
||||
* Thrown to indicate that parameters passed in the originating identity header are not understood by the service
|
||||
* broker.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code
|
||||
* {@literal 422 UNPROCESSABLE ENTITY} being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
@@ -56,4 +56,5 @@ public class ServiceBrokerInvalidOriginatingIdentityException
|
||||
private static String prependMessagePrefix(String message) {
|
||||
return MESSAGE_PREFIX + ": " + message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,13 +20,15 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
* Thrown to indicate that parameters passed in a create or update request are not understood by the service broker.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class ServiceBrokerInvalidParametersException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = 4719676639792071582L;
|
||||
|
||||
private static final String MESSAGE_PREFIX = "Service broker parameters are invalid";
|
||||
|
||||
/**
|
||||
@@ -81,4 +83,5 @@ public class ServiceBrokerInvalidParametersException extends ServiceBrokerExcept
|
||||
private static String prependMessagePrefix(String message) {
|
||||
return MESSAGE_PREFIX + ": " + message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,17 +17,18 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a request for a service instance or binding was received while
|
||||
* asynchronous creation of the service instance or binding is in progress.
|
||||
* Thrown to indicate that a request for a service instance or binding was received while asynchronous creation of the
|
||||
* service instance or binding is in progress.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 404 NOT FOUND}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 404 NOT FOUND} being returned to the platform.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class ServiceBrokerOperationInProgressException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = -1879753092397657116L;
|
||||
|
||||
private static final String MESSAGE_PREFIX = "Service broker operation is in progress " +
|
||||
"for the requested service instance or binding";
|
||||
|
||||
@@ -60,4 +61,5 @@ public class ServiceBrokerOperationInProgressException extends ServiceBrokerExce
|
||||
private static String prependMessagePrefix(String operation) {
|
||||
return MESSAGE_PREFIX + ": operation=" + operation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,17 +17,19 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a service broker is able to accept requests from the platform but is temporarily unable
|
||||
* to process those requests.
|
||||
* Thrown to indicate that a service broker is able to accept requests from the platform but is temporarily unable to
|
||||
* process those requests.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 503 SERVICE UNAVAILABLE}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 503 SERVICE UNAVAILABLE} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class ServiceBrokerUnavailableException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = -6387820141285204722L;
|
||||
|
||||
private static final String MESSAGE_PREFIX = "Service broker is temporarily unavailable";
|
||||
|
||||
/**
|
||||
@@ -82,4 +84,5 @@ public class ServiceBrokerUnavailableException extends ServiceBrokerException {
|
||||
private static String prependMessagePrefix(String message) {
|
||||
return MESSAGE_PREFIX + ": " + message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a request to update a service instance was received while
|
||||
* asynchronous updating of the identical service instance is in progress.
|
||||
* Thrown to indicate that a request to update a service instance was received while asynchronous updating of the
|
||||
* identical service instance is in progress.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 202 ACCEPTED}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 202 ACCEPTED} being returned to the platform.
|
||||
*
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
@@ -62,4 +61,5 @@ public class ServiceBrokerUpdateOperationInProgressException extends ServiceBrok
|
||||
private static String prependMessagePrefix(String operation) {
|
||||
return MESSAGE_PREFIX + ": operation=" + operation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a request includes a service definition ID that does not exist in the
|
||||
* service broker catalog.
|
||||
* Thrown to indicate that a request includes a service definition ID that does not exist in the service broker
|
||||
* catalog.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 400 BAD REQUEST}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 400 BAD REQUEST} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
*/
|
||||
@@ -40,8 +40,7 @@ public class ServiceDefinitionDoesNotExistException extends ServiceBrokerExcepti
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an exception with an error code and default message that includes the
|
||||
* provided service definition ID.
|
||||
* Construct an exception with an error code and default message that includes the provided service definition ID.
|
||||
*
|
||||
* @param errorCode a single word in camel case that uniquely identifies the error condition
|
||||
* @param serviceDefinitionId the service definition ID
|
||||
@@ -53,4 +52,5 @@ public class ServiceDefinitionDoesNotExistException extends ServiceBrokerExcepti
|
||||
private static String buildMessage(String serviceDefinitionId) {
|
||||
return "Service definition does not exist: id=" + serviceDefinitionId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a request includes a plan ID that does not exist in the
|
||||
* service broker catalog.
|
||||
* Thrown to indicate that a request includes a plan ID that does not exist in the service broker catalog.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 400 BAD REQUEST}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 400 BAD REQUEST} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author vvpishh2
|
||||
*/
|
||||
@@ -40,8 +39,7 @@ public class ServiceDefinitionPlanDoesNotExistException extends ServiceBrokerExc
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an exception with an error code and default message that includes the
|
||||
* provided plan ID.
|
||||
* Construct an exception with an error code and default message that includes the provided plan ID.
|
||||
*
|
||||
* @param errorCode a single word in camel case that uniquely identifies the error condition
|
||||
* @param planId the plan ID
|
||||
@@ -53,4 +51,5 @@ public class ServiceDefinitionPlanDoesNotExistException extends ServiceBrokerExc
|
||||
private static String buildMessage(String planId) {
|
||||
return "Service Definition Plan does not exist: id=" + planId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
* Thrown to indicate that a request includes a service binding ID that is not known to the service broker.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*/
|
||||
public class ServiceInstanceBindingDoesNotExistException extends ServiceBrokerException {
|
||||
|
||||
@@ -49,4 +49,5 @@ public class ServiceInstanceBindingDoesNotExistException extends ServiceBrokerEx
|
||||
private static String buildMessage(String bindingId) {
|
||||
return "Service binding does not exist: id=" + bindingId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a service binding create request was received for a binding that already exists
|
||||
* with parameters that are different from the existing binding.
|
||||
* Thrown to indicate that a service binding create request was received for a binding that already exists with
|
||||
* parameters that are different from the existing binding.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 409 CONFLICT}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 409 CONFLICT} being returned to the platform.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
*/
|
||||
@@ -56,4 +55,5 @@ public class ServiceInstanceBindingExistsException extends ServiceBrokerExceptio
|
||||
+ "serviceInstanceId=" + serviceInstanceId
|
||||
+ ", bindingId=" + bindingId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
* Thrown to indicate that a request includes a service instance ID that is not known to the service broker.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
*/
|
||||
@@ -39,8 +39,7 @@ public class ServiceInstanceDoesNotExistException extends ServiceBrokerException
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an exception with an error code and default message that includes the
|
||||
* provided service instance ID.
|
||||
* Construct an exception with an error code and default message that includes the provided service instance ID.
|
||||
*
|
||||
* @param errorCode a single word in camel case that uniquely identifies the error condition
|
||||
* @param serviceInstanceId the service instance ID
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a service instance create request was received for an instance that already exists
|
||||
* with parameters that are different from the existing instance.
|
||||
* Thrown to indicate that a service instance create request was received for an instance that already exists with
|
||||
* parameters that are different from the existing instance.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 409 CONFLICT}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 409 CONFLICT} being returned to the platform.
|
||||
*
|
||||
* @author sgreenberg@pivotal.io
|
||||
*/
|
||||
public class ServiceInstanceExistsException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = -914571358227517785L;
|
||||
|
||||
/**
|
||||
@@ -55,4 +55,5 @@ public class ServiceInstanceExistsException extends ServiceBrokerException {
|
||||
"serviceInstanceId=" + serviceInstanceId +
|
||||
", serviceDefinitionId=" + serviceDefinitionId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ package org.springframework.cloud.servicebroker.exception;
|
||||
* Thrown to indicate that a request to update a service instance can not be fulfilled by the service broker.
|
||||
*
|
||||
* <p>
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY}
|
||||
* being returned to the platform.
|
||||
* Throwing this exception will result in an HTTP status code {@literal 422 UNPROCESSABLE ENTITY} being returned to the
|
||||
* platform.
|
||||
*/
|
||||
public class ServiceInstanceUpdateNotSupportedException extends ServiceBrokerException {
|
||||
|
||||
private static final long serialVersionUID = 4719676639792071582L;
|
||||
|
||||
private static final String MESSAGE_PREFIX = "Service instance update not supported";
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Exceptions for Service Broker error conditions
|
||||
*/
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
package org.springframework.cloud.servicebroker.exception;
|
||||
|
||||
@@ -28,6 +28,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
*/
|
||||
public abstract class AsyncServiceBrokerRequest extends ServiceBrokerRequest {
|
||||
|
||||
/**
|
||||
* Async request parameter key
|
||||
*/
|
||||
public final static String ASYNC_REQUEST_PARAMETER = "accepts_incomplete";
|
||||
|
||||
@JsonIgnore //accepts_incomplete Osb field passed as query param in most subclasses
|
||||
@@ -49,14 +52,13 @@ public abstract class AsyncServiceBrokerRequest extends ServiceBrokerRequest {
|
||||
* @param originatingIdentity identity of the user that initiated the request from the platform
|
||||
*/
|
||||
protected AsyncServiceBrokerRequest(boolean asyncAccepted, String platformInstanceId,
|
||||
String apiInfoLocation, Context originatingIdentity) {
|
||||
String apiInfoLocation, Context originatingIdentity) {
|
||||
super(platformInstanceId, apiInfoLocation, originatingIdentity);
|
||||
this.asyncAccepted = asyncAccepted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value indicating whether the platform allows the broker to complete the request
|
||||
* asynchronously.
|
||||
* Get the value indicating whether the platform allows the broker to complete the request asynchronously.
|
||||
*
|
||||
* <p>
|
||||
* This value is set from the {@literal async_accepted} request parameter of the request from the platform.
|
||||
@@ -72,11 +74,11 @@ public abstract class AsyncServiceBrokerRequest extends ServiceBrokerRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is intended to be used internally only; use a {@literal builder} to construct an object of this
|
||||
* type and set all field values.
|
||||
* This method is intended to be used internally only; use a {@literal builder} to construct an object of this type
|
||||
* and set all field values.
|
||||
*
|
||||
* @param asyncAccepted the value indicating whether the platform allows the broker to complete the request
|
||||
* asynchronously
|
||||
* asynchronously
|
||||
*/
|
||||
public void setAsyncAccepted(boolean asyncAccepted) {
|
||||
this.asyncAccepted = asyncAccepted;
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AsyncServiceBrokerResponse {
|
||||
|
||||
/**
|
||||
* Create a new AsyncServiceBrokerResponse
|
||||
*
|
||||
* @param async is the operation asynchronous
|
||||
* @param operation description of the operation being performed
|
||||
* @throws IllegalArgumentException if operation length exceeds 10,000 characters
|
||||
|
||||
@@ -17,13 +17,23 @@
|
||||
package org.springframework.cloud.servicebroker.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* Object for configuring the version of the API supported by the service broker
|
||||
*/
|
||||
public class BrokerApiVersion {
|
||||
|
||||
/**
|
||||
* API Version header
|
||||
*/
|
||||
public final static String DEFAULT_API_VERSION_HEADER = "X-Broker-Api-Version";
|
||||
|
||||
/**
|
||||
* API Version value representing any version
|
||||
*/
|
||||
public final static String API_VERSION_ANY = "*";
|
||||
|
||||
/**
|
||||
* Current API Version supported by this library
|
||||
*/
|
||||
public final static String API_VERSION_CURRENT = "2.14";
|
||||
|
||||
private final String brokerApiVersionHeader;
|
||||
@@ -33,10 +43,10 @@ public class BrokerApiVersion {
|
||||
/**
|
||||
* Specify the name of the service broker API version header and the API version supported by the service broker.
|
||||
*
|
||||
* @param apiVersionHeader the name of the HTTP header field expected to contain the
|
||||
* service broker API version of the service broker client
|
||||
* @param apiVersion the version of the service broker API supported by the broker; a value of
|
||||
* {@literal null} or {@literal API_VERSION_ANY} will disable API version validation
|
||||
* @param apiVersionHeader the name of the HTTP header field expected to contain the service broker API version of
|
||||
* the service broker client
|
||||
* @param apiVersion the version of the service broker API supported by the broker; a value of {@literal null} or
|
||||
* {@literal API_VERSION_ANY} will disable API version validation
|
||||
*/
|
||||
public BrokerApiVersion(String apiVersionHeader, String apiVersion) {
|
||||
this.brokerApiVersionHeader = apiVersionHeader;
|
||||
@@ -46,8 +56,8 @@ public class BrokerApiVersion {
|
||||
/**
|
||||
* Specify the service broker API version supported by the service broker.
|
||||
*
|
||||
* @param apiVersion the version of the broker API supported by the broker; a value of {@literal null}
|
||||
* or {@literal API_VERSION_ANY} will disable API version validation
|
||||
* @param apiVersion the version of the broker API supported by the broker; a value of {@literal null} or
|
||||
* {@literal API_VERSION_ANY} will disable API version validation
|
||||
*/
|
||||
public BrokerApiVersion(String apiVersion) {
|
||||
this(DEFAULT_API_VERSION_HEADER, apiVersion);
|
||||
@@ -77,4 +87,5 @@ public class BrokerApiVersion {
|
||||
public String getBrokerApiVersionHeader() {
|
||||
return brokerApiVersionHeader;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,16 +37,34 @@ import org.springframework.util.StringUtils;
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public final class CloudFoundryContext extends Context {
|
||||
|
||||
/**
|
||||
* Cloud Foundry platform key
|
||||
*/
|
||||
public static final String CLOUD_FOUNDRY_PLATFORM = "cloudfoundry";
|
||||
|
||||
/**
|
||||
* Organization GUID key
|
||||
*/
|
||||
public static final String ORGANIZATION_GUID_KEY = "organizationGuid";
|
||||
|
||||
/**
|
||||
* Organization Name key
|
||||
*/
|
||||
public static final String ORGANIZATION_NAME_KEY = "organizationName";
|
||||
|
||||
/**
|
||||
* Space GUID key
|
||||
*/
|
||||
public static final String SPACE_GUID_KEY = "spaceGuid";
|
||||
|
||||
/**
|
||||
* Space Name key
|
||||
*/
|
||||
public static final String SPACE_NAME_KEY = "spaceName";
|
||||
|
||||
/**
|
||||
* Instance Name key
|
||||
*/
|
||||
public static final String INSTANCE_NAME_KEY = "instanceName";
|
||||
|
||||
private CloudFoundryContext() {
|
||||
@@ -55,6 +73,7 @@ public final class CloudFoundryContext extends Context {
|
||||
|
||||
/**
|
||||
* Create a new CloudFoundryContext
|
||||
*
|
||||
* @param organizationGuid the organization GUID
|
||||
* @param organizationName the organization name
|
||||
* @param spaceGuid the space GUID
|
||||
@@ -63,7 +82,7 @@ public final class CloudFoundryContext extends Context {
|
||||
* @param properties additional properties
|
||||
*/
|
||||
public CloudFoundryContext(String organizationGuid, String organizationName, String spaceGuid, String spaceName,
|
||||
String instanceName, Map<String, Object> properties) {
|
||||
String instanceName, Map<String, Object> properties) {
|
||||
super(CLOUD_FOUNDRY_PLATFORM, properties);
|
||||
if (StringUtils.hasText(organizationGuid)) {
|
||||
setOrganizationGuid(organizationGuid);
|
||||
@@ -82,12 +101,13 @@ public final class CloudFoundryContext extends Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Avoid polluting the serialized context with duplicated keys
|
||||
/**
|
||||
* Avoid polluting the serialized context with duplicated keys
|
||||
*
|
||||
* @return a map of properties
|
||||
*/
|
||||
*/
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getSerializableProperties() {
|
||||
public Map<String, Object> getSerializableProperties() {
|
||||
HashMap<String, Object> properties = new HashMap<>(super.getProperties());
|
||||
properties.remove(ORGANIZATION_GUID_KEY);
|
||||
properties.remove(ORGANIZATION_NAME_KEY);
|
||||
@@ -180,7 +200,7 @@ public final class CloudFoundryContext extends Context {
|
||||
/**
|
||||
* Provides a fluent API for constructing a {@link CloudFoundryContext}
|
||||
*/
|
||||
public static class CloudFoundryContextBuilder extends ContextBaseBuilder<CloudFoundryContext, CloudFoundryContextBuilder> {
|
||||
public static final class CloudFoundryContextBuilder extends ContextBaseBuilder<CloudFoundryContext, CloudFoundryContextBuilder> {
|
||||
|
||||
private String organizationGuid;
|
||||
|
||||
@@ -261,5 +281,7 @@ public final class CloudFoundryContext extends Context {
|
||||
return new CloudFoundryContext(organizationGuid, organizationName, spaceGuid, spaceName, instanceName,
|
||||
properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,10 +38,13 @@ import org.springframework.util.CollectionUtils;
|
||||
property = Context.PLATFORM_KEY, visible = true, defaultImpl = PlatformContext.class)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = CloudFoundryContext.class, name = CloudFoundryContext.CLOUD_FOUNDRY_PLATFORM),
|
||||
@JsonSubTypes.Type(value = KubernetesContext.class, name = KubernetesContext.KUBERNETES_PLATFORM),
|
||||
@JsonSubTypes.Type(value = KubernetesContext.class, name = KubernetesContext.KUBERNETES_PLATFORM)
|
||||
})
|
||||
public class Context {
|
||||
|
||||
/**
|
||||
* Platform key
|
||||
*/
|
||||
public static final String PLATFORM_KEY = "platform";
|
||||
|
||||
protected final String platform;
|
||||
@@ -58,6 +61,7 @@ public class Context {
|
||||
|
||||
/**
|
||||
* Create a new Context
|
||||
*
|
||||
* @param platform the name of the platform
|
||||
* @param properties collection of properties
|
||||
*/
|
||||
@@ -99,6 +103,7 @@ public class Context {
|
||||
|
||||
/**
|
||||
* Get the String value of a property in the context with the given key.
|
||||
*
|
||||
* @param key the key of the property to retrieve
|
||||
* @return the value of the property, or {@literal null} if the key is not present in the request
|
||||
*/
|
||||
@@ -169,6 +174,7 @@ public class Context {
|
||||
|
||||
/**
|
||||
* Construct a builder
|
||||
*
|
||||
* @return the builder
|
||||
*/
|
||||
protected abstract B createBuilder();
|
||||
@@ -185,8 +191,8 @@ public class Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a set of properties from the provided {@literal Map} to the context properties
|
||||
* as would be provided in the request from the platform.
|
||||
* Add a set of properties from the provided {@literal Map} to the context properties as would be provided in
|
||||
* the request from the platform.
|
||||
*
|
||||
* @param properties the properties to add
|
||||
* @return the builder
|
||||
@@ -216,5 +222,7 @@ public class Context {
|
||||
* @return the newly constructed {@link Context} implementation
|
||||
*/
|
||||
public abstract R build();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user