Fix configuration for PMD rule check in build. Address rule violations.
This commit is contained in:
16
build.gradle
16
build.gradle
@@ -158,6 +158,14 @@ configure(allprojects) {
|
||||
}
|
||||
}
|
||||
|
||||
pmd {
|
||||
ruleSetFiles = files("${project.rootDir}/ci/config/pmdRuleSet.xml")
|
||||
}
|
||||
|
||||
pmdTest {
|
||||
ruleSetFiles = files("${project.rootDir}/ci/config/pmdTestRuleSet.xml")
|
||||
}
|
||||
|
||||
artifactory {
|
||||
contextUrl = 'https://repo.spring.io'
|
||||
publish {
|
||||
@@ -306,14 +314,6 @@ configure(rootProject) {
|
||||
}
|
||||
}
|
||||
|
||||
pmd {
|
||||
ruleSetFiles = files("${project.rootDir}/ci/config/pmdRuleSet.xml")
|
||||
}
|
||||
|
||||
pmdTest {
|
||||
ruleSetFiles = files("${project.rootDir}/ci/config/pmdTestRuleSet.xml")
|
||||
}
|
||||
|
||||
task codeCoverageReport(type: JacocoReport) {
|
||||
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
|
||||
|
||||
|
||||
@@ -6,11 +6,23 @@
|
||||
|
||||
<rule ref="rulesets/java/basic.xml"/>
|
||||
<rule ref="rulesets/java/braces.xml"/>
|
||||
<rule ref="rulesets/java/codesize.xml"/>
|
||||
<rule ref="rulesets/java/design.xml"/>
|
||||
<rule ref="rulesets/java/codesize.xml">
|
||||
<exclude name="TooManyMethods"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/design.xml">
|
||||
<exclude name="UseUtilityClass"/>
|
||||
<exclude name="AccessorMethodGeneration"/>
|
||||
<exclude name="UncommentedEmptyConstructor"/>
|
||||
<exclude name="UncommentedEmptyMethodBody"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/empty.xml"/>
|
||||
<rule ref="rulesets/java/finalizers.xml"/>
|
||||
<rule ref="rulesets/java/naming.xml">
|
||||
<exclude name="ShortVariable" />
|
||||
<exclude name="LongVariable" />
|
||||
<exclude name="ShortMethodName" />
|
||||
<exclude name="ShortClassName" />
|
||||
<exclude name="AbstractNaming" />
|
||||
<exclude name="AvoidFieldNameMatchingMethodName" />
|
||||
</rule>
|
||||
<rule ref="rulesets/java/imports.xml"/>
|
||||
@@ -19,7 +31,10 @@
|
||||
<property name="maximumStaticImports" value="0"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/optimizations.xml"/>
|
||||
<rule ref="rulesets/java/optimizations.xml">
|
||||
<exclude name="LocalVariableCouldBeFinal"/>
|
||||
<exclude name="MethodArgumentCouldBeFinal"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/strictexception.xml"/>
|
||||
<rule ref="rulesets/java/strings.xml"/>
|
||||
<rule ref="rulesets/java/typeresolution.xml"/>
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<rule ref="rulesets/java/naming.xml">
|
||||
<exclude name="LongVariable" />
|
||||
<exclude name="ShortVariable" />
|
||||
<exclude name="ShortMethodName" />
|
||||
<exclude name="AbstractNaming"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/optimizations.xml">
|
||||
@@ -56,6 +57,7 @@
|
||||
<exclude name="MethodArgumentCouldBeFinal"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/strictexception.xml">
|
||||
<exclude name="AvoidThrowingRawExceptionTypes"/>
|
||||
<exclude name="SignatureDeclareThrowsException"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/strings.xml">
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.cloud.appbroker.acceptance;
|
||||
|
||||
class BrokerProperties {
|
||||
|
||||
private String[] properties;
|
||||
private final String[] properties;
|
||||
|
||||
BrokerProperties(String[] properties) {
|
||||
BrokerProperties(String... properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@EnableConfigurationProperties(AcceptanceTestProperties.class)
|
||||
class CloudFoundryAcceptanceTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp(BrokerProperties brokerProperties) {
|
||||
initializeBroker(brokerProperties.getProperties());
|
||||
}
|
||||
|
||||
private static final String SAMPLE_BROKER_APP_NAME = "sample-broker";
|
||||
private static final String SERVICE_BROKER_NAME = "sample-broker-name";
|
||||
private static final String SERVICE_NAME = "example";
|
||||
@@ -62,12 +57,17 @@ class CloudFoundryAcceptanceTest {
|
||||
@Autowired
|
||||
private AcceptanceTestProperties acceptanceTestProperties;
|
||||
|
||||
@BeforeEach
|
||||
void setUp(BrokerProperties brokerProperties) {
|
||||
initializeBroker(brokerProperties.getProperties());
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
blockingSubscribe(cleanup());
|
||||
}
|
||||
|
||||
void initializeBroker(String[] backingAppProperties) {
|
||||
private void initializeBroker(String... backingAppProperties) {
|
||||
|
||||
blockingSubscribe(cloudFoundryService
|
||||
.getOrCreateDefaultOrganization()
|
||||
|
||||
@@ -60,9 +60,9 @@ public class CloudFoundryService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CloudFoundryService.class);
|
||||
|
||||
private CloudFoundryOperations cloudFoundryOperations;
|
||||
private CloudFoundryProperties cloudFoundryProperties;
|
||||
private CloudFoundryClient cloudFoundryClient;
|
||||
private final CloudFoundryOperations cloudFoundryOperations;
|
||||
private final CloudFoundryProperties cloudFoundryProperties;
|
||||
private final CloudFoundryClient cloudFoundryClient;
|
||||
|
||||
@Autowired
|
||||
public CloudFoundryService(CloudFoundryOperations cloudFoundryOperations,
|
||||
@@ -94,7 +94,7 @@ public class CloudFoundryService {
|
||||
.build())));
|
||||
}
|
||||
|
||||
public Mono<String> getApplicationRoute(String appName) {
|
||||
private Mono<String> getApplicationRoute(String appName) {
|
||||
return loggingMono(
|
||||
cloudFoundryOperations
|
||||
.applications()
|
||||
@@ -105,7 +105,7 @@ public class CloudFoundryService {
|
||||
.map(url -> "https://" + url));
|
||||
}
|
||||
|
||||
public Mono<Void> pushAppBroker(String appName, Path appPath, String[] backingAppProperties) {
|
||||
public Mono<Void> pushAppBroker(String appName, Path appPath, String... backingAppProperties) {
|
||||
return loggingMono(
|
||||
cloudFoundryOperations
|
||||
.applications()
|
||||
@@ -282,13 +282,15 @@ public class CloudFoundryService {
|
||||
return catalogVariables;
|
||||
}
|
||||
|
||||
private Map<String, String> backingAppEnvironmentVariables(String[] backingAppProperties) {
|
||||
private Map<String, String> backingAppEnvironmentVariables(String... backingAppProperties) {
|
||||
Map<String, String> backingAppVariables = new HashMap<>();
|
||||
for (String appProperty : backingAppProperties) {
|
||||
final String[] appPropertyKeyValue = appProperty.split("=");
|
||||
if (appPropertyKeyValue.length != 2) {
|
||||
throw new RuntimeException(format("Backing app property '%s' is incorrectly formatted", Arrays.toString(appPropertyKeyValue)));
|
||||
} else backingAppVariables.put(appPropertyKeyValue[0], appPropertyKeyValue[1]);
|
||||
if (appPropertyKeyValue.length == 2) {
|
||||
backingAppVariables.put(appPropertyKeyValue[0], appPropertyKeyValue[1]);
|
||||
} else {
|
||||
throw new IllegalArgumentException(format("Backing app property '%s' is incorrectly formatted", Arrays.toString(appPropertyKeyValue)));
|
||||
}
|
||||
}
|
||||
return backingAppVariables;
|
||||
}
|
||||
@@ -296,7 +298,9 @@ public class CloudFoundryService {
|
||||
private <T> Mono<T> loggingMono(Mono<T> publisher) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
return publisher.log();
|
||||
} else return publisher;
|
||||
} else {
|
||||
return publisher;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class AppBrokerAutoConfiguration {
|
||||
@Bean
|
||||
@ConfigurationProperties(PROPERTY_PREFIX + ".services")
|
||||
public BrokeredServices brokeredServices() {
|
||||
return new BrokeredServices();
|
||||
return BrokeredServices.builder().build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -22,9 +22,7 @@ import org.cloudfoundry.reactor.ProxyConfiguration;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import static org.springframework.cloud.appbroker.autoconfigure.CloudFoundryProperties.PROPERTY_PREFIX;
|
||||
|
||||
@ConfigurationProperties(PROPERTY_PREFIX)
|
||||
@ConfigurationProperties(CloudFoundryProperties.PROPERTY_PREFIX)
|
||||
public class CloudFoundryProperties {
|
||||
|
||||
static final String PROPERTY_PREFIX = "spring.cloud.appbroker.deployer.cloudfoundry";
|
||||
|
||||
@@ -38,30 +38,30 @@ public class BackingApplication {
|
||||
public BackingApplication(BackingApplication backingApplicationToCopy) {
|
||||
this.name = backingApplicationToCopy.name;
|
||||
this.path = backingApplicationToCopy.path;
|
||||
this.properties = backingApplicationToCopy.properties != null
|
||||
? new HashMap<>(backingApplicationToCopy.properties)
|
||||
: new HashMap<>();
|
||||
this.environment = backingApplicationToCopy.environment != null
|
||||
? new HashMap<>(backingApplicationToCopy.environment)
|
||||
: new HashMap<>();
|
||||
this.services = backingApplicationToCopy.services != null
|
||||
? new ArrayList<>(backingApplicationToCopy.services)
|
||||
: new ArrayList<>();
|
||||
this.parametersTransformers = backingApplicationToCopy.parametersTransformers != null
|
||||
? new ArrayList<>(backingApplicationToCopy.parametersTransformers)
|
||||
: new ArrayList<>();
|
||||
this.credentialProviders = backingApplicationToCopy.credentialProviders != null
|
||||
? new ArrayList<>(backingApplicationToCopy.credentialProviders)
|
||||
: new ArrayList<>();
|
||||
this.properties = backingApplicationToCopy.properties == null
|
||||
? new HashMap<>()
|
||||
: new HashMap<>(backingApplicationToCopy.properties);
|
||||
this.environment = backingApplicationToCopy.environment == null
|
||||
? new HashMap<>()
|
||||
: new HashMap<>(backingApplicationToCopy.environment);
|
||||
this.services = backingApplicationToCopy.services == null
|
||||
? new ArrayList<>()
|
||||
: new ArrayList<>(backingApplicationToCopy.services);
|
||||
this.parametersTransformers = backingApplicationToCopy.parametersTransformers == null
|
||||
? new ArrayList<>()
|
||||
: new ArrayList<>(backingApplicationToCopy.parametersTransformers);
|
||||
this.credentialProviders = backingApplicationToCopy.credentialProviders == null
|
||||
? new ArrayList<>()
|
||||
: new ArrayList<>(backingApplicationToCopy.credentialProviders);
|
||||
}
|
||||
|
||||
private BackingApplication() {
|
||||
}
|
||||
|
||||
private BackingApplication(String name, String path, Map<String, String> properties,
|
||||
Map<String, String> environment, List<String> services,
|
||||
List<ParametersTransformerSpec> parametersTransformers,
|
||||
List<CredentialProviderSpec> credentialProviders) {
|
||||
BackingApplication(String name, String path, Map<String, String> properties,
|
||||
Map<String, String> environment, List<String> services,
|
||||
List<ParametersTransformerSpec> parametersTransformers,
|
||||
List<CredentialProviderSpec> credentialProviders) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.properties = properties;
|
||||
@@ -141,8 +141,12 @@ public class BackingApplication {
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof BackingApplication)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof BackingApplication)) {
|
||||
return false;
|
||||
}
|
||||
BackingApplication that = (BackingApplication) o;
|
||||
return Objects.equals(name, that.name) &&
|
||||
Objects.equals(path, that.path) &&
|
||||
@@ -187,11 +191,11 @@ public class BackingApplication {
|
||||
|
||||
private String name;
|
||||
private String path;
|
||||
private Map<String, String> properties = new HashMap<>();
|
||||
private Map<String, String> environment = new HashMap<>();
|
||||
private List<String> services = new ArrayList<>();
|
||||
private List<ParametersTransformerSpec> parameterTransformers = new ArrayList<>();
|
||||
private List<CredentialProviderSpec> credentialProviders = new ArrayList<>();
|
||||
private final Map<String, String> properties = new HashMap<>();
|
||||
private final Map<String, String> environment = new HashMap<>();
|
||||
private final List<String> services = new ArrayList<>();
|
||||
private final List<ParametersTransformerSpec> parameterTransformers = new ArrayList<>();
|
||||
private final List<CredentialProviderSpec> credentialProviders = new ArrayList<>();
|
||||
|
||||
BackingApplicationBuilder() {
|
||||
}
|
||||
|
||||
@@ -22,7 +22,11 @@ import java.util.List;
|
||||
public class BackingApplications extends ArrayList<BackingApplication> {
|
||||
private static final long serialVersionUID = 159473836238657105L;
|
||||
|
||||
public BackingApplications() {
|
||||
private BackingApplications() {
|
||||
}
|
||||
|
||||
BackingApplications(List<BackingApplication> backingApplications) {
|
||||
super.addAll(backingApplications);
|
||||
}
|
||||
|
||||
public BackingApplications(BackingApplications backingApplicationsToCopy) {
|
||||
@@ -30,16 +34,12 @@ public class BackingApplications extends ArrayList<BackingApplication> {
|
||||
this.add(new BackingApplication(backingApplicationToCopy)));
|
||||
}
|
||||
|
||||
private BackingApplications(List<BackingApplication> backingApplications) {
|
||||
super.addAll(backingApplications);
|
||||
}
|
||||
|
||||
public static BackingApplicationsBuilder builder() {
|
||||
return new BackingApplicationsBuilder();
|
||||
}
|
||||
|
||||
public static class BackingApplicationsBuilder {
|
||||
private List<BackingApplication> backingApplications = new ArrayList<>();
|
||||
private final List<BackingApplication> backingApplications = new ArrayList<>();
|
||||
|
||||
public BackingApplicationsBuilder backingApplication(BackingApplication backingApplication) {
|
||||
this.backingApplications.add(backingApplication);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class BrokeredService {
|
||||
private BrokeredService() {
|
||||
}
|
||||
|
||||
private BrokeredService(String serviceName, String planName, BackingApplications apps) {
|
||||
BrokeredService(String serviceName, String planName, BackingApplications apps) {
|
||||
this.serviceName = serviceName;
|
||||
this.planName = planName;
|
||||
this.apps = apps;
|
||||
@@ -62,8 +62,12 @@ public class BrokeredService {
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof BrokeredService)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof BrokeredService)) {
|
||||
return false;
|
||||
}
|
||||
BrokeredService that = (BrokeredService) o;
|
||||
return Objects.equals(serviceName, that.serviceName) &&
|
||||
Objects.equals(planName, that.planName) &&
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.util.List;
|
||||
public class BrokeredServices extends ArrayList<BrokeredService> {
|
||||
private static final long serialVersionUID = 6303127383252611352L;
|
||||
|
||||
public BrokeredServices() {
|
||||
private BrokeredServices() {
|
||||
}
|
||||
|
||||
private BrokeredServices(List<BrokeredService> brokeredServices) {
|
||||
BrokeredServices(List<BrokeredService> brokeredServices) {
|
||||
super.addAll(brokeredServices);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BrokeredServices extends ArrayList<BrokeredService> {
|
||||
}
|
||||
|
||||
public static class BrokeredServicesBuilder {
|
||||
private List<BrokeredService> brokeredServices = new ArrayList<>();
|
||||
private final List<BrokeredService> brokeredServices = new ArrayList<>();
|
||||
|
||||
public BrokeredServicesBuilder service(BrokeredService brokeredService) {
|
||||
this.brokeredServices.add(brokeredService);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CredentialProviderSpec {
|
||||
private CredentialProviderSpec() {
|
||||
}
|
||||
|
||||
private CredentialProviderSpec(String name, Map<String, Object> args) {
|
||||
CredentialProviderSpec(String name, Map<String, Object> args) {
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
}
|
||||
@@ -53,9 +53,9 @@ public class CredentialProviderSpec {
|
||||
|
||||
public static class CredentialProviderSpecBuilder {
|
||||
private String name;
|
||||
private Map<String, Object> args = new LinkedHashMap<>();
|
||||
private final Map<String, Object> args = new LinkedHashMap<>();
|
||||
|
||||
private CredentialProviderSpecBuilder() {
|
||||
CredentialProviderSpecBuilder() {
|
||||
}
|
||||
|
||||
public CredentialProviderSpecBuilder name(String name) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DeployerClient {
|
||||
|
||||
private final Logger log = Loggers.getLogger(DeployerClient.class);
|
||||
|
||||
private AppDeployer appDeployer;
|
||||
private final AppDeployer appDeployer;
|
||||
|
||||
public DeployerClient(AppDeployer appDeployer) {
|
||||
this.appDeployer = appDeployer;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ParametersTransformerSpec {
|
||||
private ParametersTransformerSpec() {
|
||||
}
|
||||
|
||||
private ParametersTransformerSpec(String name, Map<String, Object> args) {
|
||||
ParametersTransformerSpec(String name, Map<String, Object> args) {
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
}
|
||||
@@ -53,9 +53,9 @@ public class ParametersTransformerSpec {
|
||||
|
||||
public static class ParametersTransformerSpecBuilder {
|
||||
private String name;
|
||||
private Map<String, Object> args = new LinkedHashMap<>();
|
||||
private final Map<String, Object> args = new LinkedHashMap<>();
|
||||
|
||||
private ParametersTransformerSpecBuilder() {
|
||||
ParametersTransformerSpecBuilder() {
|
||||
}
|
||||
|
||||
public ParametersTransformerSpecBuilder name(String name) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExtensionLocator<T> {
|
||||
private final HashMap<String, ExtensionFactory<T, ?>> factoriesByName = new HashMap<>();
|
||||
private final Map<String, ExtensionFactory<T, ?>> factoriesByName = new HashMap<>();
|
||||
|
||||
public ExtensionLocator(List<? extends ExtensionFactory<T, ?>> factories) {
|
||||
factories.forEach(parametersTransformer ->
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SimpleCredentialGenerator implements CredentialGenerator {
|
||||
builder.append(SPECIAL_CHARACTERS);
|
||||
}
|
||||
|
||||
if (builder.toString().length() == 0) {
|
||||
if (builder.length() == 0) {
|
||||
builder.append(UPPERCASE_ALPHA)
|
||||
.append(LOWERCASE_ALPHA)
|
||||
.append(DIGITS)
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SpringSecurityBasicAuthCredentialProviderFactory extends
|
||||
static final String SPRING_SECURITY_USER_NAME = "security.user.name";
|
||||
static final String SPRING_SECURITY_USER_PASSWORD = "security.user.password";
|
||||
|
||||
private CredentialGenerator credentialGenerator;
|
||||
private final CredentialGenerator credentialGenerator;
|
||||
|
||||
public SpringSecurityBasicAuthCredentialProviderFactory(CredentialGenerator credentialGenerator) {
|
||||
super(Config.class);
|
||||
|
||||
@@ -25,7 +25,10 @@ import org.springframework.aop.support.AopUtils;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ConfigurationBeanUtils {
|
||||
public final class ConfigurationBeanUtils {
|
||||
|
||||
private ConfigurationBeanUtils() {
|
||||
}
|
||||
|
||||
public static <T> T instantiate(Class<T> cls) {
|
||||
return org.springframework.beans.BeanUtils.instantiateClass(cls);
|
||||
@@ -50,10 +53,10 @@ public abstract class ConfigurationBeanUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked","PMD.AvoidCatchingGenericException"})
|
||||
private static <T> T getTargetObject(Object candidate) {
|
||||
try {
|
||||
if (AopUtils.isAopProxy(candidate) && (candidate instanceof Advised)) {
|
||||
if (AopUtils.isAopProxy(candidate) && candidate instanceof Advised) {
|
||||
return (T) ((Advised) candidate).getTargetSource().getTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class KebabCasePropertyBeanIntrospector implements BeanIntrospector {
|
||||
*/
|
||||
private String camelCasePropertyName(final Method m) {
|
||||
final String methodName = m.getName().substring(WRITE_METHOD_PREFIX.length());
|
||||
return (methodName.length() > 1) ?
|
||||
return methodName.length() > 1 ?
|
||||
Introspector.decapitalize(methodName) :
|
||||
methodName.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class KebabCasePropertyBeanIntrospector implements BeanIntrospector {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (char c : methodName.toCharArray()) {
|
||||
if (Character.isUpperCase(c)) {
|
||||
builder.append("-").append(Character.toLowerCase(c));
|
||||
builder.append('-').append(Character.toLowerCase(c));
|
||||
} else {
|
||||
builder.append(c);
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
public class WorkflowServiceInstanceService implements ServiceInstanceService {
|
||||
private final Logger log = Loggers.getLogger(WorkflowServiceInstanceService.class);
|
||||
|
||||
private List<CreateServiceInstanceWorkflow> createServiceInstanceWorkflows;
|
||||
private final List<CreateServiceInstanceWorkflow> createServiceInstanceWorkflows;
|
||||
|
||||
private List<DeleteServiceInstanceWorkflow> deleteServiceInstanceWorkflows;
|
||||
private final List<DeleteServiceInstanceWorkflow> deleteServiceInstanceWorkflows;
|
||||
|
||||
private List<UpdateServiceInstanceWorkflow> updateServiceInstanceWorkflows;
|
||||
private final List<UpdateServiceInstanceWorkflow> updateServiceInstanceWorkflows;
|
||||
|
||||
private ServiceInstanceStateRepository stateRepository;
|
||||
private final ServiceInstanceStateRepository stateRepository;
|
||||
|
||||
public WorkflowServiceInstanceService(ServiceInstanceStateRepository serviceInstanceStateRepository,
|
||||
List<CreateServiceInstanceWorkflow> createServiceInstanceWorkflows,
|
||||
|
||||
@@ -25,9 +25,9 @@ import org.springframework.cloud.servicebroker.model.instance.OperationState;
|
||||
*/
|
||||
public class ServiceInstanceState {
|
||||
|
||||
private OperationState operationState;
|
||||
private final OperationState operationState;
|
||||
|
||||
private String description;
|
||||
private final String description;
|
||||
|
||||
//TODO: consider a time stamp property
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ConfigurationBeanUtilsTest {
|
||||
|
||||
private TestProperties targetObject = new TestProperties();
|
||||
private Map<String, Object> properties = new HashMap<>();
|
||||
private final TestProperties targetObject = new TestProperties();
|
||||
private final Map<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
void populateWithCamelCaseProperties() {
|
||||
@@ -68,13 +68,13 @@ class ConfigurationBeanUtilsTest {
|
||||
private void assertValuesPopulated(TestProperties targetObject) {
|
||||
assertThat(targetObject.getStringValue()).isEqualTo("value");
|
||||
assertThat(targetObject.getIntValue()).isEqualTo(41);
|
||||
assertThat(targetObject.getBooleanValue()).isEqualTo(true);
|
||||
assertThat(targetObject.isBooleanValue()).isEqualTo(true);
|
||||
}
|
||||
|
||||
private void assertValuesNotPopulated(TestProperties targetObject) {
|
||||
assertThat(targetObject.getStringValue()).isNull();
|
||||
assertThat(targetObject.getIntValue()).isEqualTo(0);
|
||||
assertThat(targetObject.getBooleanValue()).isEqualTo(false);
|
||||
assertThat(targetObject.isBooleanValue()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -99,7 +99,7 @@ class ConfigurationBeanUtilsTest {
|
||||
this.intValue = intValue;
|
||||
}
|
||||
|
||||
boolean getBooleanValue() {
|
||||
boolean isBooleanValue() {
|
||||
return booleanValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ class CredentialProviderServiceTest {
|
||||
}
|
||||
|
||||
public class TestFactory extends CredentialProviderFactory<Object> {
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
TestFactory(String name) {
|
||||
this.name = name;
|
||||
@@ -132,13 +132,13 @@ class CredentialProviderServiceTest {
|
||||
return new CredentialProvider() {
|
||||
@Override
|
||||
public Mono<BackingApplication> addCredentials(BackingApplication backingApplication, String serviceInstanceGuid) {
|
||||
backingApplication.addEnvironment(name + "-added", "done");
|
||||
backingApplication.addEnvironment(getName() + "-added", "done");
|
||||
return Mono.just(backingApplication);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<BackingApplication> deleteCredentials(BackingApplication backingApplication, String serviceInstanceGuid) {
|
||||
backingApplication.addEnvironment(name + "-deleted", "done");
|
||||
backingApplication.addEnvironment(getName() + "-deleted", "done");
|
||||
return Mono.just(backingApplication);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ class ParametersTransformationServiceTest {
|
||||
}
|
||||
|
||||
public static class TestFactory extends ParametersTransformerFactory<Config> {
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private Map<String, Object> actualParameters;
|
||||
private Config actualConfig;
|
||||
@@ -188,7 +188,7 @@ class ParametersTransformationServiceTest {
|
||||
private String arg1;
|
||||
private Integer arg2;
|
||||
|
||||
Config() {
|
||||
private Config() {
|
||||
}
|
||||
|
||||
Config(String arg1, Integer arg2) {
|
||||
@@ -214,8 +214,12 @@ class ParametersTransformationServiceTest {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Config)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Config)) {
|
||||
return false;
|
||||
}
|
||||
Config config = (Config) o;
|
||||
return Objects.equals(arg2, config.arg2) &&
|
||||
Objects.equals(arg1, config.arg1);
|
||||
|
||||
@@ -166,7 +166,7 @@ class AppDeploymentCreateServiceInstanceWorkflowTest {
|
||||
.name(planName)
|
||||
.build())
|
||||
.build())
|
||||
.parameters(parameters != null ? parameters : new HashMap<>())
|
||||
.parameters(parameters == null ? new HashMap<>() : parameters)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class AppDeploymentUpdateServiceInstanceWorkflowTest {
|
||||
.name(planName)
|
||||
.build())
|
||||
.build())
|
||||
.parameters(parameters != null ? parameters : new HashMap<>())
|
||||
.parameters(parameters == null ? new HashMap<>() : parameters)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import org.cloudfoundry.operations.applications.PushApplicationManifestRequest;
|
||||
import org.cloudfoundry.operations.applications.Route;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.appbroker.deployer.DeploymentProperties;
|
||||
import org.springframework.cloud.appbroker.deployer.util.ByteSizeUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import reactor.core.Exceptions;
|
||||
@@ -59,26 +60,10 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.springframework.cloud.appbroker.deployer.DeploymentProperties.COUNT_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.DeploymentProperties.DISK_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.DeploymentProperties.GROUP_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.DeploymentProperties.MEMORY_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.BUILDPACK_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.DOMAIN_PROPERTY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.HEALTHCHECK_HTTP_ENDPOINT_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.HEALTHCHECK_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.HEALTHCHECK_TIMEOUT_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.HOST_PROPERTY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.JAVA_OPTS_PROPERTY_KEY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.NO_ROUTE_PROPERTY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.ROUTES_PROPERTY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.ROUTE_PATH_PROPERTY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.ROUTE_PROPERTY;
|
||||
import static org.springframework.cloud.appbroker.deployer.cloudfoundry.CloudFoundryDeploymentProperties.USE_SPRING_APPLICATION_JSON_KEY;
|
||||
|
||||
@SuppressWarnings("PMD.GodClass")
|
||||
public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CloudFoundryAppDeployer.class);
|
||||
private final Logger logger = LoggerFactory.getLogger(CloudFoundryAppDeployer.class);
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
@@ -175,10 +160,10 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
|
||||
manifest.routes(routes);
|
||||
}
|
||||
|
||||
if (getDockerImage(appResource) != null) {
|
||||
manifest.docker(Docker.builder().image(getDockerImage(appResource)).build());
|
||||
} else {
|
||||
if (getDockerImage(appResource) == null) {
|
||||
manifest.buildpack(buildpack(deploymentProperties));
|
||||
} else {
|
||||
manifest.docker(Docker.builder().image(getDockerImage(appResource)).build());
|
||||
}
|
||||
return manifest.build();
|
||||
}
|
||||
@@ -228,7 +213,7 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
|
||||
envVariables.put("JAVA_OPTS", javaOpts(environment));
|
||||
}
|
||||
|
||||
String group = environment.get(GROUP_PROPERTY_KEY);
|
||||
String group = environment.get(DeploymentProperties.GROUP_PROPERTY_KEY);
|
||||
if (StringUtils.hasText(group)) {
|
||||
envVariables.put("SPRING_CLOUD_APPLICATION_GROUP", group);
|
||||
}
|
||||
@@ -240,16 +225,17 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
|
||||
}
|
||||
|
||||
private Map<String, String> getApplicationEnvironment(Map<String, String> environment) {
|
||||
Map<String, String> applicationProperties = getSanitizedApplicationEnvironment(environment);
|
||||
Map<String, String> applicationEnvironment = getSanitizedApplicationEnvironment(environment);
|
||||
|
||||
if (!useSpringApplicationJson(environment)) {
|
||||
return applicationProperties;
|
||||
return applicationEnvironment;
|
||||
}
|
||||
|
||||
try {
|
||||
return Collections.singletonMap("SPRING_APPLICATION_JSON", OBJECT_MAPPER.writeValueAsString(applicationProperties));
|
||||
return Collections.singletonMap("SPRING_APPLICATION_JSON",
|
||||
OBJECT_MAPPER.writeValueAsString(applicationEnvironment));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalArgumentException("Error writing environment to SPRING_APPLICATION_JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,18 +252,18 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
|
||||
}
|
||||
|
||||
private boolean useSpringApplicationJson(Map<String, String> environment) {
|
||||
return Optional.ofNullable(environment.get(USE_SPRING_APPLICATION_JSON_KEY))
|
||||
return Optional.ofNullable(environment.get(CloudFoundryDeploymentProperties.USE_SPRING_APPLICATION_JSON_KEY))
|
||||
.map(Boolean::valueOf)
|
||||
.orElse(this.defaultDeploymentProperties.isUseSpringApplicationJson());
|
||||
}
|
||||
|
||||
private String domain(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(DOMAIN_PROPERTY))
|
||||
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.DOMAIN_PROPERTY))
|
||||
.orElse(this.defaultDeploymentProperties.getDomain());
|
||||
}
|
||||
|
||||
private ApplicationHealthCheck healthCheck(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(HEALTHCHECK_PROPERTY_KEY))
|
||||
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.HEALTHCHECK_PROPERTY_KEY))
|
||||
.map(this::toApplicationHealthCheck)
|
||||
.orElse(this.defaultDeploymentProperties.getHealthCheck());
|
||||
}
|
||||
@@ -292,30 +278,30 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
|
||||
}
|
||||
|
||||
private String healthCheckEndpoint(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(HEALTHCHECK_HTTP_ENDPOINT_PROPERTY_KEY))
|
||||
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.HEALTHCHECK_HTTP_ENDPOINT_PROPERTY_KEY))
|
||||
.orElse(this.defaultDeploymentProperties.getHealthCheckHttpEndpoint());
|
||||
}
|
||||
|
||||
private Integer healthCheckTimeout(Map<String, String> properties) {
|
||||
String timeoutString = properties
|
||||
.getOrDefault(HEALTHCHECK_TIMEOUT_PROPERTY_KEY, this.defaultDeploymentProperties.getHealthCheckTimeout());
|
||||
.getOrDefault(CloudFoundryDeploymentProperties.HEALTHCHECK_TIMEOUT_PROPERTY_KEY, this.defaultDeploymentProperties.getHealthCheckTimeout());
|
||||
return Integer.parseInt(timeoutString);
|
||||
}
|
||||
|
||||
private int instances(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(COUNT_PROPERTY_KEY))
|
||||
return Optional.ofNullable(properties.get(DeploymentProperties.COUNT_PROPERTY_KEY))
|
||||
.map(Integer::parseInt)
|
||||
.orElse(this.defaultDeploymentProperties.getInstances());
|
||||
}
|
||||
|
||||
private String host(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(HOST_PROPERTY))
|
||||
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.HOST_PROPERTY))
|
||||
.orElse(this.defaultDeploymentProperties.getHost());
|
||||
}
|
||||
|
||||
private String routePath(Map<String, String> properties) {
|
||||
String routePath = properties.get(ROUTE_PATH_PROPERTY);
|
||||
if (StringUtils.hasText(routePath) && !routePath.startsWith("/")) {
|
||||
String routePath = properties.get(CloudFoundryDeploymentProperties.ROUTE_PATH_PROPERTY);
|
||||
if (StringUtils.hasText(routePath) && routePath.charAt(0) != '/') {
|
||||
throw new IllegalArgumentException(
|
||||
"Cloud Foundry routes must start with \"/\". Route passed = [" + routePath + "].");
|
||||
}
|
||||
@@ -323,41 +309,41 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
|
||||
}
|
||||
|
||||
private String route(Map<String, String> properties) {
|
||||
return properties.get(ROUTE_PROPERTY);
|
||||
return properties.get(CloudFoundryDeploymentProperties.ROUTE_PROPERTY);
|
||||
}
|
||||
|
||||
private Set<String> routes(Map<String, String> properties) {
|
||||
Set<String> routes = new HashSet<>();
|
||||
routes.addAll(this.defaultDeploymentProperties.getRoutes());
|
||||
routes.addAll(StringUtils.commaDelimitedListToSet(properties.get(ROUTES_PROPERTY)));
|
||||
routes.addAll(StringUtils.commaDelimitedListToSet(properties.get(CloudFoundryDeploymentProperties.ROUTES_PROPERTY)));
|
||||
return routes;
|
||||
}
|
||||
|
||||
private Boolean toggleNoRoute(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(NO_ROUTE_PROPERTY))
|
||||
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.NO_ROUTE_PROPERTY))
|
||||
.map(Boolean::valueOf)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private int memory(Map<String, String> properties) {
|
||||
String withUnit = properties
|
||||
.getOrDefault(MEMORY_PROPERTY_KEY, this.defaultDeploymentProperties.getMemory());
|
||||
.getOrDefault(DeploymentProperties.MEMORY_PROPERTY_KEY, this.defaultDeploymentProperties.getMemory());
|
||||
return (int) ByteSizeUtils.parseToMebibytes(withUnit);
|
||||
}
|
||||
|
||||
private int diskQuota(Map<String, String> properties) {
|
||||
String withUnit = properties
|
||||
.getOrDefault(DISK_PROPERTY_KEY, this.defaultDeploymentProperties.getDisk());
|
||||
.getOrDefault(DeploymentProperties.DISK_PROPERTY_KEY, this.defaultDeploymentProperties.getDisk());
|
||||
return (int) ByteSizeUtils.parseToMebibytes(withUnit);
|
||||
}
|
||||
|
||||
private String buildpack(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(BUILDPACK_PROPERTY_KEY))
|
||||
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.BUILDPACK_PROPERTY_KEY))
|
||||
.orElse(this.defaultDeploymentProperties.getBuildpack());
|
||||
}
|
||||
|
||||
private String javaOpts(Map<String, String> properties) {
|
||||
return Optional.ofNullable(properties.get(JAVA_OPTS_PROPERTY_KEY))
|
||||
return Optional.ofNullable(properties.get(CloudFoundryDeploymentProperties.JAVA_OPTS_PROPERTY_KEY))
|
||||
.orElse(this.defaultDeploymentProperties.getJavaOpts());
|
||||
}
|
||||
|
||||
@@ -395,10 +381,10 @@ public class CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware
|
||||
*/
|
||||
private Path getApplication(Resource resource) {
|
||||
try {
|
||||
if (!resource.getURI().toString().startsWith("docker:")) {
|
||||
return resource.getFile().toPath();
|
||||
} else {
|
||||
if (resource.getURI().toString().startsWith("docker:")) {
|
||||
return null;
|
||||
} else {
|
||||
return resource.getFile().toPath();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw Exceptions.propagate(e);
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Set;
|
||||
* @author Greg Turnquist
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings({"unused", "PMD.TooManyFields"})
|
||||
public class CloudFoundryDeploymentProperties {
|
||||
static final String HEALTHCHECK_PROPERTY_KEY = "health-check";
|
||||
|
||||
@@ -60,7 +60,7 @@ public class CloudFoundryDeploymentProperties {
|
||||
/**
|
||||
* The host name to use as part of the route. Defaults to hostname derived by Cloud Foundry.
|
||||
*/
|
||||
private String host = null;
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* The domain to use when mapping routes for applications.
|
||||
|
||||
@@ -23,18 +23,18 @@ import java.util.Map;
|
||||
|
||||
public class DeployApplicationRequest {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private String path;
|
||||
private final String path;
|
||||
|
||||
private Map<String, String> properties;
|
||||
private final Map<String, String> properties;
|
||||
|
||||
private Map<String, String> environment;
|
||||
private final Map<String, String> environment;
|
||||
|
||||
private List<String> services;
|
||||
private final List<String> services;
|
||||
|
||||
private DeployApplicationRequest(String name, String path, Map<String, String> properties,
|
||||
Map<String, String> environment, List<String> services) {
|
||||
DeployApplicationRequest(String name, String path, Map<String, String> properties,
|
||||
Map<String, String> environment, List<String> services) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.properties = properties;
|
||||
@@ -72,14 +72,13 @@ public class DeployApplicationRequest {
|
||||
|
||||
private String path;
|
||||
|
||||
private Map<String, String> properties = new HashMap<>();
|
||||
private final Map<String, String> properties = new HashMap<>();
|
||||
|
||||
private Map<String, String> environment = new HashMap<>();
|
||||
private final Map<String, String> environment = new HashMap<>();
|
||||
|
||||
private List<String> services = new ArrayList<>();
|
||||
private final List<String> services = new ArrayList<>();
|
||||
|
||||
DeployApplicationRequestBuilder() {
|
||||
|
||||
}
|
||||
|
||||
public DeployApplicationRequestBuilder name(String name) {
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.cloud.appbroker.deployer;
|
||||
|
||||
public class DeployApplicationResponse {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private DeployApplicationResponse(String name) {
|
||||
DeployApplicationResponse(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,25 +18,25 @@ package org.springframework.cloud.appbroker.deployer;
|
||||
|
||||
import org.springframework.cloud.appbroker.deployer.util.ByteSizeUtils;
|
||||
|
||||
public interface DeploymentProperties {
|
||||
public class DeploymentProperties {
|
||||
/**
|
||||
* The deployment property for the count (number of app instances).
|
||||
* If not provided, a deployer should assume 1 instance.
|
||||
*/
|
||||
String COUNT_PROPERTY_KEY = "count";
|
||||
public static final String COUNT_PROPERTY_KEY = "count";
|
||||
|
||||
/**
|
||||
* The deployment property for the group to which an app belongs.
|
||||
* If not provided, a deployer should assume no group.
|
||||
*/
|
||||
String GROUP_PROPERTY_KEY = "group";
|
||||
public static final String GROUP_PROPERTY_KEY = "group";
|
||||
|
||||
/**
|
||||
* The deployment property that indicates if each app instance should have an index value
|
||||
* within a sequence from 0 to N-1, where N is the value of the {@value #COUNT_PROPERTY_KEY}
|
||||
* property. If not provided, a deployer should assume app instance indexing is not necessary.
|
||||
*/
|
||||
String INDEXED_PROPERTY_KEY = "indexed";
|
||||
public static final String INDEXED_PROPERTY_KEY = "indexed";
|
||||
|
||||
/**
|
||||
* The property to be set at each instance level to specify the sequence number
|
||||
@@ -46,7 +46,7 @@ public interface DeploymentProperties {
|
||||
*
|
||||
* @see #INDEXED_PROPERTY_KEY
|
||||
*/
|
||||
String INSTANCE_INDEX_PROPERTY_KEY = "INSTANCE_INDEX";
|
||||
public static final String INSTANCE_INDEX_PROPERTY_KEY = "INSTANCE_INDEX";
|
||||
|
||||
/**
|
||||
* The deployment property for the memory setting for the container that will run the app.
|
||||
@@ -60,7 +60,7 @@ public interface DeploymentProperties {
|
||||
*
|
||||
* @see ByteSizeUtils
|
||||
*/
|
||||
String MEMORY_PROPERTY_KEY = "memory";
|
||||
public static final String MEMORY_PROPERTY_KEY = "memory";
|
||||
|
||||
/**
|
||||
* The deployment property for the disk setting for the container that will run the app.
|
||||
@@ -74,7 +74,7 @@ public interface DeploymentProperties {
|
||||
*
|
||||
* @see ByteSizeUtils
|
||||
*/
|
||||
String DISK_PROPERTY_KEY = "disk";
|
||||
public static final String DISK_PROPERTY_KEY = "disk";
|
||||
|
||||
/**
|
||||
* The deployment property for the cpu setting for the container that will run the app.
|
||||
@@ -82,5 +82,5 @@ public interface DeploymentProperties {
|
||||
* support setting cpu and will ignore this setting. Other platforms may require whole numbers and might
|
||||
* round up. Exactly how this property affects the deployments will vary between implementations.
|
||||
*/
|
||||
String CPU_PROPERTY_KEY = "cpu";
|
||||
public static final String CPU_PROPERTY_KEY = "cpu";
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.cloud.appbroker.deployer;
|
||||
|
||||
public class UndeployApplicationRequest {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private UndeployApplicationRequest(String name) {
|
||||
UndeployApplicationRequest(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.cloud.appbroker.deployer;
|
||||
|
||||
public class UndeployApplicationResponse {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private UndeployApplicationResponse(String name) {
|
||||
UndeployApplicationResponse(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,19 +24,18 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Eric Bottard
|
||||
*/
|
||||
public class ByteSizeUtils {
|
||||
|
||||
private ByteSizeUtils() {
|
||||
|
||||
}
|
||||
public final class ByteSizeUtils {
|
||||
|
||||
private static final Pattern SIZE_PATTERN = Pattern.compile("(?<amount>\\d+)(?<unit>(m|g)?)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private ByteSizeUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of mebibytes (1024*1024) denoted by the given text, where an optional case-insensitive unit of
|
||||
* 'm' or 'g' can be used to mean mebi- or gebi- bytes, respectively. Lack of unit assumes mebibytes.
|
||||
*/
|
||||
public static long parseToMebibytes(String text) {
|
||||
public static long parseToMebibytes(String text) {
|
||||
Matcher matcher = SIZE_PATTERN.matcher(text);
|
||||
if (!matcher.matches()) {
|
||||
throw new IllegalArgumentException(String.format("Could not parse '%s' as a byte size." +
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.cloud.appbroker.sample;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -122,7 +124,7 @@ class CreateInstanceWithCustomCreationParametersComponentTest extends WiremockCo
|
||||
objectMapper.readValue(parameters.get("firstKey").toString(), CustomInputParameters.class);
|
||||
customOutputEnvironmentParameters.put("otherKey", customInputParameters.getSecondKey());
|
||||
customOutputEnvironmentParameters.put("otherLabel", customInputParameters.getLabel());
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Collections.singletonMap("otherNestedKey", customOutputEnvironmentParameters.toString());
|
||||
@@ -130,12 +132,12 @@ class CreateInstanceWithCustomCreationParametersComponentTest extends WiremockCo
|
||||
}
|
||||
|
||||
static class CustomInputParameters {
|
||||
private CustomInputParameters() {
|
||||
}
|
||||
|
||||
private String secondKey;
|
||||
private String label;
|
||||
|
||||
private CustomInputParameters() {
|
||||
}
|
||||
|
||||
String getSecondKey() {
|
||||
return secondKey;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class CloudControllerStubFixture extends WiremockStubFixture {
|
||||
stubCheckAppState(appName);
|
||||
}
|
||||
|
||||
private void stubCreateAppMetadata(String appName, ContentPattern<?>[] appMetadataPatterns) {
|
||||
private void stubCreateAppMetadata(String appName, ContentPattern<?>... appMetadataPatterns) {
|
||||
MappingBuilder mappingBuilder = post(urlEqualTo("/v2/apps"))
|
||||
.withRequestBody(matchingJsonPath("$.[?(@.name == '" + appName + "')]"));
|
||||
for (ContentPattern<?> appMetadataPattern : appMetadataPatterns) {
|
||||
@@ -159,7 +159,7 @@ public class CloudControllerStubFixture extends WiremockStubFixture {
|
||||
replace("@guid", appGuid(appName))))));
|
||||
}
|
||||
|
||||
private void stubUpdateAppMetadata(String appName, ContentPattern<?>[] appMetadataPatterns) {
|
||||
private void stubUpdateAppMetadata(String appName, ContentPattern<?>... appMetadataPatterns) {
|
||||
MappingBuilder mappingBuilder = put(urlEqualTo("/v2/apps/" + appGuid(appName)))
|
||||
.withRequestBody(matchingJsonPath("$.[?(@.name == '" + appName + "')]"));
|
||||
for (ContentPattern<?> appMetadataPattern : appMetadataPatterns) {
|
||||
|
||||
@@ -41,9 +41,6 @@ public class WiremockServerFixture {
|
||||
@Value("${wiremock.cloudfoundry.api-url:}")
|
||||
private String cfApiUrl;
|
||||
|
||||
@Value("${wiremock.cloudfoundry.access-token:an.access.token}")
|
||||
private String accessToken;
|
||||
|
||||
private WireMockServer wiremockServer;
|
||||
|
||||
public void startWiremock() {
|
||||
|
||||
Reference in New Issue
Block a user