From 2bc32b9615dca9465d33e37d79c788b8fcec4351 Mon Sep 17 00:00:00 2001 From: Mihail Tusa Date: Thu, 27 Jun 2019 12:18:02 +0300 Subject: [PATCH 1/3] Couchbase - in-house cleanup, maintenance Signed off by Tusa Mihai: tusa.mihai@gmail.com --- pom.xml | 6 ++ .../entities/constants/Constants.java | 45 ++++++------- .../entities/couchbase/AuthType.java | 7 +- .../entities/couchbase/BucketType.java | 7 +- .../entities/couchbase/ClusterUri.java | 4 +- .../couchbase/ConflictResolutionType.java | 7 +- .../entities/couchbase/EvictionPolicy.java | 7 +- .../entities/couchbase/NodesUri.java | 5 +- .../entities/couchbase/RecoveryType.java | 7 +- .../entities/couchbase/SuffixUri.java | 3 +- .../entities/couchbase/ViewsUri.java | 5 +- .../entities/inputs/BucketInputs.java | 28 ++++---- .../entities/inputs/ClusterInputs.java | 6 +- .../entities/inputs/CommonInputs.java | 4 +- .../couchbase/entities/inputs/NodeInputs.java | 6 +- .../couchbase/execute/CouchbaseService.java | 34 +++++++--- .../factory/HttpClientInputsBuilder.java | 20 ++++-- .../factory/InputsWrapperBuilder.java | 33 ++++++---- .../couchbase/factory/PayloadBuilder.java | 2 - .../factory/buckets/BucketHeadersBuilder.java | 6 -- .../factory/buckets/BucketsHelper.java | 17 +++-- .../factory/buckets/BucketsUriFactory.java | 2 - .../cluster/ClusterHeadersBuilder.java | 8 +-- .../factory/cluster/ClusterHelper.java | 6 +- .../factory/cluster/ClusterUriFactory.java | 3 +- .../couchbase/factory/nodes/NodesHelper.java | 6 +- .../content/couchbase/utils/InputsUtil.java | 66 +++++++++++++------ .../couchbase/validators/Validators.java | 46 ++++++------- .../execute/CouchbaseServiceTest.java | 40 +++++------ .../couchbase/utils/InputsUtilTest.java | 12 ++-- 30 files changed, 246 insertions(+), 202 deletions(-) diff --git a/pom.xml b/pom.xml index 5ea2c8f..55cd6cb 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ 1.6 0.1.73 0.0.6 + 0.10.0 1.10.19 1.7.4 @@ -117,6 +118,11 @@ commons-validator ${commons-validator.version} + + io.vavr + vavr + ${io-vavr.version} + junit junit diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java b/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java index 8ff42df..51f0c45 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java @@ -34,20 +34,14 @@ private Constants() { // prevent instantiation } - public static class Api { + public class Api { public static final String BUCKETS = "buckets"; public static final String CLUSTER = "cluster"; public static final String NODES = "nodes"; public static final String VIEWS = "views"; } - public static class HttpClientInputsValues { - public static final String ALL_TYPE_HEADER = "Accept:application/json, text/plain, */*"; - public static final String FORM_URL_ENCODED = "application/x-www-form-urlencoded; charset=UTF-8"; - public static final String X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1 = "X-memcachekv-Store-Client-Specification-Version:0.1"; - } - - public static class BucketActions { + public class BucketActions { public static final String CREATE_OR_EDIT_BUCKET = "CreateOrEditBucket"; public static final String DELETE_BUCKET = "DeleteBucket"; public static final String GET_ALL_BUCKETS = "GetAllBuckets"; @@ -55,7 +49,7 @@ public static class BucketActions { public static final String GET_BUCKET_STATISTICS = "GetBucketStatistics"; } - public static class ClusterActions { + public class ClusterActions { public static final String GET_AUTO_FAILOVER_SETTINGS = "GetAutoFailOverSettings"; public static final String GET_CLUSTER_DETAILS = "GetClusterDetails"; public static final String GET_CLUSTER_INFO = "GetClusterInfo"; @@ -63,17 +57,7 @@ public static class ClusterActions { public static final String REBALANCING_NODES = "RebalancingNodes"; } - public static class NodeActions { - public static final String FAIL_OVER_NODE = "FailOverNode"; - public static final String GRACEFUL_FAIL_OVER_NODE = "GracefulFailOverNode"; - public static final String SET_RECOVERY_TYPE = "SetRecoveryType"; - } - - public static class ViewsActions { - public static final String GET_DESIGN_DOCS_INFO = "GetDesignDocsInfo"; - } - - public static class ErrorMessages { + public class ErrorMessages { public static final String CONSTRAINS_ERROR_MESSAGE = "The value doesn't meet conditions for general purpose usage. " + "See operation inputs description section for details."; public static final String UNKNOWN_BUILDER_TYPE = "Unknown builder type."; @@ -83,7 +67,13 @@ public static class ErrorMessages { "authType, proxyPort and/or saslPassword doesn't meet conditions for general purpose usage."; } - public static class Miscellaneous { + public class HttpClientInputsValues { + public static final String ALL_TYPE_HEADER = "Accept:application/json, text/plain, */*"; + public static final String FORM_URL_ENCODED = "application/x-www-form-urlencoded; charset=UTF-8"; + public static final String X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1 = "X-memcachekv-Store-Client-Specification-Version:0.1"; + } + + public class Miscellaneous { public static final String ALLOW_ALL = "allow_all"; public static final String AMPERSAND = "&"; public static final String AT = "@"; @@ -94,7 +84,13 @@ public static class Miscellaneous { public static final String SLASH = "/"; } - public static class Values { + public class NodeActions { + public static final String FAIL_OVER_NODE = "FailOverNode"; + public static final String GRACEFUL_FAIL_OVER_NODE = "GracefulFailOverNode"; + public static final String SET_RECOVERY_TYPE = "SetRecoveryType"; + } + + public class Values { public static final int COUCHBASE_DEFAULT_PROXY_PORT = 11215; public static final int DEFAULT_REPLICA_NUMBER = 1; public static final int DEFAULT_THREADS_NUMBER = 2; @@ -103,5 +99,10 @@ public static class Values { public static final int MAXIMUM_THREADS_NUMBER = 8; public static final int MINIMUM_RAM_QUOTA_AMOUNT = 100; public static final int MINIMUM_THREADS_NUMBER = 2; + public static final int THREADS_NUMBER = 10; + } + + public class ViewsActions { + public static final String GET_DESIGN_DOCS_INFO = "GetDesignDocsInfo"; } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/AuthType.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/AuthType.java index 277bef3..9e5617d 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/AuthType.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/AuthType.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Optional; -import static io.cloudslang.content.couchbase.utils.InputsUtil.getEnumValues; +import static io.cloudslang.content.couchbase.utils.InputsUtil.buildErrorMessage; import static java.lang.String.format; import static java.util.Arrays.stream; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -44,8 +44,7 @@ public enum AuthType { private static final Map AUTH_TYPE_MAP = new HashMap<>(); static { - stream(values()) - .forEach(authType -> AUTH_TYPE_MAP.put(authType.name().toLowerCase(), authType.getValue())); + stream(values()).forEach(entry -> AUTH_TYPE_MAP.put(entry.name().toLowerCase(), entry.getValue())); } private final String value; @@ -63,6 +62,6 @@ public static String getAuthTypeValue(String input) { Optional .ofNullable(AUTH_TYPE_MAP.get(input)) .orElseThrow(() -> new RuntimeException(format("Invalid Couchbase bucket authorization type value: '%s'. Valid values: '%s'.", - input, getEnumValues(AuthType.class)))); + input, buildErrorMessage(AuthType.class)))); } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/BucketType.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/BucketType.java index eca378f..840f0a4 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/BucketType.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/BucketType.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Optional; -import static io.cloudslang.content.couchbase.utils.InputsUtil.getEnumValues; +import static io.cloudslang.content.couchbase.utils.InputsUtil.buildErrorMessage; import static java.lang.String.format; import static java.util.Arrays.stream; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -44,8 +44,7 @@ public enum BucketType { private static final Map BUCKET_TYPE_MAP = new HashMap<>(); static { - stream(values()) - .forEach(bucketType -> BUCKET_TYPE_MAP.put(bucketType.name().toLowerCase(), bucketType.getValue())); + stream(values()).forEach(entry -> BUCKET_TYPE_MAP.put(entry.name().toLowerCase(), entry.getValue())); } private final String value; @@ -63,6 +62,6 @@ public static String getBucketTypeValue(String input) { Optional .ofNullable(BUCKET_TYPE_MAP.get(input)) .orElseThrow(() -> new RuntimeException(format("Invalid Couchbase bucket type value: '%s'. Valid values: '%s'.", - input, getEnumValues(BucketType.class)))); + input, buildErrorMessage(BucketType.class)))); } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ClusterUri.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ClusterUri.java index e526fa7..b88b89a 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ClusterUri.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ClusterUri.java @@ -32,8 +32,7 @@ public enum ClusterUri { private static final Map CLUSTER_URI_MAP = new HashMap<>(); static { - stream(values()) - .forEach(clusterUri -> CLUSTER_URI_MAP.put(clusterUri.getKey(), clusterUri.getValue())); + stream(values()).forEach(entry -> CLUSTER_URI_MAP.put(entry.getKey(), entry.getValue())); } ClusterUri(String key, String value) { @@ -41,7 +40,6 @@ public enum ClusterUri { this.value = value; } - @SuppressWarnings("ConstantConditions") public static String getValue(String input) { return Optional .ofNullable(CLUSTER_URI_MAP.get(input)) diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ConflictResolutionType.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ConflictResolutionType.java index 74e0c05..aee665a 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ConflictResolutionType.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ConflictResolutionType.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Optional; -import static io.cloudslang.content.couchbase.utils.InputsUtil.getEnumValues; +import static io.cloudslang.content.couchbase.utils.InputsUtil.buildErrorMessage; import static java.lang.String.format; import static java.util.Arrays.stream; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -44,8 +44,7 @@ public enum ConflictResolutionType { private static final Map CONFLICT_RESOLUTION_TYPE_MAP = new HashMap<>(); static { - stream(values()) - .forEach(bucketType -> CONFLICT_RESOLUTION_TYPE_MAP.put(bucketType.name().toLowerCase(), bucketType.getValue())); + stream(values()).forEach(entry -> CONFLICT_RESOLUTION_TYPE_MAP.put(entry.name().toLowerCase(), entry.getValue())); } private final String value; @@ -63,6 +62,6 @@ public static String getConflictResolutionTypeValue(String input) { Optional .ofNullable(CONFLICT_RESOLUTION_TYPE_MAP.get(input)) .orElseThrow(() -> new RuntimeException(format("Invalid Couchbase conflict resolution type value: '%s'. Valid values: '%s'.", - input, getEnumValues(ConflictResolutionType.class)))); + input, buildErrorMessage(ConflictResolutionType.class)))); } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/EvictionPolicy.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/EvictionPolicy.java index 1d7e0a7..ee0136c 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/EvictionPolicy.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/EvictionPolicy.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Optional; -import static io.cloudslang.content.couchbase.utils.InputsUtil.getEnumValues; +import static io.cloudslang.content.couchbase.utils.InputsUtil.buildErrorMessage; import static java.lang.String.format; import static java.util.Arrays.stream; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -44,8 +44,7 @@ public enum EvictionPolicy { private static final Map EVICTION_POLICY_MAP = new HashMap<>(); static { - stream(values()) - .forEach(bucketType -> EVICTION_POLICY_MAP.put(bucketType.name().toLowerCase(), bucketType.getValue())); + stream(values()).forEach(entry -> EVICTION_POLICY_MAP.put(entry.name().toLowerCase(), entry.getValue())); } private final String value; @@ -63,6 +62,6 @@ public static String getEvictionPolicyValue(String input) { Optional .ofNullable(EVICTION_POLICY_MAP.get(input)) .orElseThrow(() -> new RuntimeException(format("Invalid Couchbase conflict resolution type value: '%s'. Valid values: '%s'.", - input, getEnumValues(ConflictResolutionType.class)))); + input, buildErrorMessage(ConflictResolutionType.class)))); } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/NodesUri.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/NodesUri.java index 5386938..75137a6 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/NodesUri.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/NodesUri.java @@ -46,8 +46,7 @@ public enum NodesUri { private static final Map NODES_URI_MAP = new HashMap<>(); static { - stream(values()) - .forEach(nodeUri -> NODES_URI_MAP.put(nodeUri.getKey(), nodeUri.getNodesUriValue())); + stream(values()).forEach(entry -> NODES_URI_MAP.put(entry.getKey(), entry.getValue())); } NodesUri(String key, String value) { @@ -65,7 +64,7 @@ private String getKey() { return key; } - private String getNodesUriValue() { + private String getValue() { return value; } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/RecoveryType.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/RecoveryType.java index 23d2907..8d1bc0e 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/RecoveryType.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/RecoveryType.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Optional; -import static io.cloudslang.content.couchbase.utils.InputsUtil.getEnumValues; +import static io.cloudslang.content.couchbase.utils.InputsUtil.buildErrorMessage; import static java.lang.String.format; import static java.util.Arrays.stream; @@ -43,8 +43,7 @@ public enum RecoveryType { private static final Map RECOVERY_TYPE_MAP = new HashMap<>(); static { - stream(values()) - .forEach(recoveryType -> RECOVERY_TYPE_MAP.put(recoveryType.name().toLowerCase(), recoveryType.getValue())); + stream(values()).forEach(entry -> RECOVERY_TYPE_MAP.put(entry.name().toLowerCase(), entry.getValue())); } private final String value; @@ -61,6 +60,6 @@ public static String getRecoveryTypeValue(String input) { return Optional .ofNullable(RECOVERY_TYPE_MAP.get(input)) .orElseThrow(() -> new RuntimeException(format("Invalid Couchbase node recovery type value: '%s'. Valid values: '%s'.", - input, getEnumValues(RecoveryType.class)))); + input, buildErrorMessage(RecoveryType.class)))); } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/SuffixUri.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/SuffixUri.java index 7d32425..bd26409 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/SuffixUri.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/SuffixUri.java @@ -47,8 +47,7 @@ public enum SuffixUri { private static final Map SUFFIX_URI_MAP = new HashMap<>(); static { - stream(values()) - .forEach(suffixUri -> SUFFIX_URI_MAP.put(suffixUri.getKey(), suffixUri.getSuffixUriValue())); + stream(values()).forEach(entry -> SUFFIX_URI_MAP.put(entry.getKey(), entry.getSuffixUriValue())); } SuffixUri(String key, String value) { diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ViewsUri.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ViewsUri.java index b51d768..a0e6685 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ViewsUri.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ViewsUri.java @@ -44,8 +44,7 @@ public enum ViewsUri { private static final Map VIEWS_URI_MAP = new HashMap<>(); static { - stream(values()) - .forEach(viewsUri -> VIEWS_URI_MAP.put(viewsUri.getKey(), viewsUri.getViewsUriValue())); + stream(values()).forEach(entry -> VIEWS_URI_MAP.put(entry.getKey(), entry.getValue())); } ViewsUri(String key, String value) { @@ -63,7 +62,7 @@ private String getKey() { return key; } - private String getViewsUriValue() { + private String getValue() { return value; } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/BucketInputs.java b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/BucketInputs.java index 7579923..657912d 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/BucketInputs.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/BucketInputs.java @@ -62,7 +62,7 @@ public class BucketInputs { private final Integer replicaNumber; private final Integer threadsNumber; - private BucketInputs(BucketInputs.Builder builder) { + private BucketInputs(Builder builder) { this.authType = builder.authType; this.bucketName = builder.bucketName; this.bucketType = builder.bucketType; @@ -151,67 +151,67 @@ public BucketInputs build() { return new BucketInputs(this); } - public BucketInputs.Builder withAuthType(String input) { + public Builder withAuthType(String input) { authType = getAuthTypeValue(input); return this; } - public BucketInputs.Builder withBucketName(String input) { + public Builder withBucketName(String input) { bucketName = input; return this; } - public BucketInputs.Builder withBucketType(String input) { + public Builder withBucketType(String input) { bucketType = getBucketTypeValue(input); return this; } - public BucketInputs.Builder withConflictResolutionType(String input) { + public Builder withConflictResolutionType(String input) { conflictResolutionType = getConflictResolutionTypeValue(input); return this; } - public BucketInputs.Builder withEvictionPolicy(String input) { + public Builder withEvictionPolicy(String input) { evictionPolicy = getEvictionPolicyValue(input); return this; } - public BucketInputs.Builder withFlushEnabled(String input) { + public Builder withFlushEnabled(String input) { flushEnabled = getEnabledString(input, false); return this; } - public BucketInputs.Builder withParallelDBAndViewCompaction(String input) { + public Builder withParallelDBAndViewCompaction(String input) { parallelDBAndViewCompaction = valueOf(getEnforcedBooleanCondition(input, FALSE)); return this; } - public BucketInputs.Builder withReplicaIndex(String input) { + public Builder withReplicaIndex(String input) { replicaIndex = getEnabledString(input, true); return this; } - public BucketInputs.Builder withProxyPort(String input) { + public Builder withProxyPort(String input) { proxyPort = getValidPort(input); return this; } - public BucketInputs.Builder withRamQuotaMB(String input) { + public Builder withRamQuotaMB(String input) { ramQuotaMB = getValidIntValue(input, MINIMUM_RAM_QUOTA_AMOUNT, null, MINIMUM_RAM_QUOTA_AMOUNT); return this; } - public BucketInputs.Builder withReplicaNumber(String input) { + public Builder withReplicaNumber(String input) { replicaNumber = getValidIntValue(input, INIT_INDEX, MAXIMUM_REPLICA_NUMBER, DEFAULT_REPLICA_NUMBER); return this; } - public BucketInputs.Builder withSaslPassword(String input) { + public Builder withSaslPassword(String input) { saslPassword = input; return this; } - public BucketInputs.Builder withThreadsNumber(String input) { + public Builder withThreadsNumber(String input) { threadsNumber = getValidIntValue(input, MINIMUM_THREADS_NUMBER, MAXIMUM_THREADS_NUMBER, DEFAULT_THREADS_NUMBER); return this; } diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/ClusterInputs.java b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/ClusterInputs.java index ab74a98..b2e3f3b 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/ClusterInputs.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/ClusterInputs.java @@ -32,7 +32,7 @@ public class ClusterInputs { private final String ejectedNodes; private final String knownNodes; - private ClusterInputs(ClusterInputs.Builder builder) { + private ClusterInputs(Builder builder) { this.ejectedNodes = builder.ejectedNodes; this.knownNodes = builder.knownNodes; } @@ -53,12 +53,12 @@ public ClusterInputs build() { return new ClusterInputs(this); } - public ClusterInputs.Builder withEjectedNodes(String inputValue) { + public Builder withEjectedNodes(String inputValue) { ejectedNodes = inputValue; return this; } - public ClusterInputs.Builder withKnownNodes(String inputValue) { + public Builder withKnownNodes(String inputValue) { knownNodes = inputValue; return this; } diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/CommonInputs.java b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/CommonInputs.java index 2ed0cda..6393455 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/CommonInputs.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/CommonInputs.java @@ -25,7 +25,7 @@ package io.cloudslang.content.couchbase.entities.inputs; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.COMMA; -import static io.cloudslang.content.couchbase.utils.InputsUtil.getInputWithDefaultValue; +import static org.apache.commons.lang3.StringUtils.defaultIfBlank; /** * Created by Mihai Tusa @@ -86,7 +86,7 @@ public Builder withEndpoint(String inputValue) { } public Builder withDelimiter(String inputValue) { - delimiter = getInputWithDefaultValue(inputValue, COMMA); + delimiter = defaultIfBlank(inputValue, COMMA); return this; } } diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/NodeInputs.java b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/NodeInputs.java index 01b09fc..5fdbb3b 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/NodeInputs.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/NodeInputs.java @@ -35,7 +35,7 @@ public class NodeInputs { private final String internalNodeIpAddress; private final String recoveryType; - private NodeInputs(NodeInputs.Builder builder) { + private NodeInputs(Builder builder) { this.internalNodeIpAddress = builder.internalNodeIpAddress; this.recoveryType = builder.recoveryType; } @@ -56,12 +56,12 @@ public NodeInputs build() { return new NodeInputs(this); } - public NodeInputs.Builder withInternalNodeIpAddress(String inputValue) { + public Builder withInternalNodeIpAddress(String inputValue) { internalNodeIpAddress = getValidInternalNodeIpAddress(inputValue); return this; } - public NodeInputs.Builder withRecoveryType(String inputValue) { + public Builder withRecoveryType(String inputValue) { recoveryType = getRecoveryTypeValue(inputValue); return this; } diff --git a/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java b/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java index d26a7d6..463a7d5 100644 --- a/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java +++ b/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java @@ -28,30 +28,44 @@ import io.cloudslang.content.couchbase.entities.inputs.InputsWrapper; import io.cloudslang.content.httpclient.CSHttpClient; import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.utils.OutputUtilities; +import io.vavr.control.Try; -import java.net.MalformedURLException; import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; -import static io.cloudslang.content.couchbase.factory.HeadersBuilder.buildHeaders; +import static io.cloudslang.content.couchbase.entities.constants.Constants.Values.THREADS_NUMBER; import static io.cloudslang.content.couchbase.factory.InputsWrapperBuilder.buildWrapper; -import static io.cloudslang.content.couchbase.factory.PayloadBuilder.buildPayload; -import static io.cloudslang.content.couchbase.utils.InputsUtil.buildUrl; +import static io.cloudslang.content.couchbase.utils.InputsUtil.setupApiCall; +import static java.util.concurrent.Executors.newFixedThreadPool; /** * Created by Mihai Tusa * 3/26/2017. */ public class CouchbaseService { + private final ExecutorService executorService = newFixedThreadPool(THREADS_NUMBER); + @SafeVarargs - public final Map execute(HttpClientInputs httpClientInputs, CommonInputs commonInputs, T... builders) - throws MalformedURLException { + public final Map execute(HttpClientInputs httpClientInputs, CommonInputs commonInputs, T... builders) { InputsWrapper wrapper = buildWrapper(httpClientInputs, commonInputs, builders); - httpClientInputs.setUrl(buildUrl(wrapper)); + return Try + .of(() -> { + setupApiCall(httpClientInputs, wrapper); - buildHeaders(wrapper); - buildPayload(wrapper); + return asyncCall(httpClientInputs); + }) + .onFailure(OutputUtilities::getFailureResultsMap) + .get(); + } - return new CSHttpClient().execute(httpClientInputs); + private Map asyncCall(HttpClientInputs httpClientInputs) throws InterruptedException, ExecutionException { + return CompletableFuture + .supplyAsync(() -> new CSHttpClient().execute(httpClientInputs), executorService) + .exceptionally(OutputUtilities::getFailureResultsMap) + .get(); } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java index 40bb579..598af53 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java @@ -24,19 +24,24 @@ package io.cloudslang.content.couchbase.factory; import io.cloudslang.content.httpclient.HttpClientInputs; +import org.apache.commons.lang3.StringUtils; + +import java.util.Optional; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.ALLOW_ALL; import static io.cloudslang.content.couchbase.validators.Validators.areBothValuesPresent; -import static io.cloudslang.content.couchbase.validators.Validators.getValidOrDefaultValue; import static io.cloudslang.content.httpclient.build.auth.AuthTypes.BASIC; import static io.cloudslang.content.utils.NumberUtilities.isValidInt; import static java.lang.Boolean.FALSE; +import static java.lang.Integer.MAX_VALUE; import static java.lang.Integer.parseInt; import static java.lang.String.valueOf; import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Arrays.stream; import static org.apache.commons.lang3.StringUtils.isNotBlank; public class HttpClientInputsBuilder { + private static final String[] x509HostnameVerifierValidValuesArray = new String[]{"allow_all", "browser_compatible", "strict"}; private static final HttpClientInputs httpClientInputs = new HttpClientInputs(); @@ -194,21 +199,28 @@ public Builder withUseCookies(String inputValue) { } public Builder withConnectTimeout(String inputValue) { - this.connectTimeout = valueOf(isValidInt(inputValue, 0, Integer.MAX_VALUE) ? parseInt(inputValue) : 0); + this.connectTimeout = valueOf(isValidInt(inputValue, 0, MAX_VALUE) ? parseInt(inputValue) : 0); httpClientInputs.setConnectTimeout(connectTimeout); return this; } public Builder withSocketTimeout(String inputValue) { - this.socketTimeout = valueOf(isValidInt(inputValue, 0, Integer.MAX_VALUE) ? parseInt(inputValue) : 0); + this.socketTimeout = valueOf(isValidInt(inputValue, 0, MAX_VALUE) ? parseInt(inputValue) : 0); httpClientInputs.setSocketTimeout(socketTimeout); return this; } public Builder withX509HostnameVerifier(String inputValue) { - this.x509HostnameVerifier = getValidOrDefaultValue(inputValue, ALLOW_ALL, new String[]{"allow_all", "browser_compatible", "strict"}); + this.x509HostnameVerifier = Optional + .ofNullable(inputValue) + .filter(StringUtils::isNotEmpty) + .filter(any -> stream(x509HostnameVerifierValidValuesArray) + .anyMatch(filter -> filter.contains(inputValue))) + .map(s -> inputValue) + .orElse(ALLOW_ALL); + httpClientInputs.setX509HostnameVerifier(x509HostnameVerifier); return this; diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java index 54a2429..02e2a09 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java @@ -31,6 +31,8 @@ import io.cloudslang.content.couchbase.entities.inputs.NodeInputs; import io.cloudslang.content.httpclient.HttpClientInputs; +import java.util.Optional; + import static io.cloudslang.content.couchbase.entities.constants.Constants.ErrorMessages.UNKNOWN_BUILDER_TYPE; import static io.cloudslang.content.couchbase.entities.constants.Constants.Values.INIT_INDEX; @@ -50,20 +52,25 @@ public static InputsWrapper buildWrapper(HttpClientInputs httpClientInputs, .withCommonInputs(commonInputs) .build(); - if (builders.length > INIT_INDEX) { - for (T builder : builders) { - if (builder instanceof BucketInputs) { - wrapper.setBucketInputs((BucketInputs) builder); - } else if (builder instanceof ClusterInputs) { - wrapper.setClusterInputs((ClusterInputs) builder); - } else if (builder instanceof NodeInputs) { - wrapper.setNodeInputs((NodeInputs) builder); - } else { - throw new RuntimeException(UNKNOWN_BUILDER_TYPE); - } - } - } + Optional + .ofNullable(builders) + .filter(f -> builders.length > INIT_INDEX) + .ifPresent(set -> setOnlyValidBuilderTypes(wrapper, builders)); return wrapper; } + + private static void setOnlyValidBuilderTypes(InputsWrapper wrapper, T[] builders) { + for (T builder : builders) { + if (builder instanceof BucketInputs) { + wrapper.setBucketInputs((BucketInputs) builder); + } else if (builder instanceof ClusterInputs) { + wrapper.setClusterInputs((ClusterInputs) builder); + } else if (builder instanceof NodeInputs) { + wrapper.setNodeInputs((NodeInputs) builder); + } else { + throw new RuntimeException(UNKNOWN_BUILDER_TYPE); + } + } + } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/PayloadBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/PayloadBuilder.java index 0020e66..a749568 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/PayloadBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/PayloadBuilder.java @@ -52,8 +52,6 @@ public static void buildPayload(InputsWrapper wrapper) { wrapper.getHttpClientInputs().setBody(new BucketsHelper().getCreateBucketPayload(wrapper)); break; case FAIL_OVER_NODE: - wrapper.getHttpClientInputs().setBody(new NodesHelper().getFailOverNodePayloadString(wrapper)); - break; case GRACEFUL_FAIL_OVER_NODE: wrapper.getHttpClientInputs().setBody(new NodesHelper().getFailOverNodePayloadString(wrapper)); break; diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketHeadersBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketHeadersBuilder.java index f9a3d03..d7b6e92 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketHeadersBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketHeadersBuilder.java @@ -51,13 +51,7 @@ public static void setBucketHeaders(InputsWrapper wrapper) { wrapper.getHttpClientInputs().setContentType(FORM_URL_ENCODED); break; case GET_ALL_BUCKETS: - wrapper.getHttpClientInputs().setHeaders(X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1); - wrapper.getHttpClientInputs().setContentType(APPLICATION_JSON.getMimeType()); - break; case GET_BUCKET: - wrapper.getHttpClientInputs().setHeaders(X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1); - wrapper.getHttpClientInputs().setContentType(APPLICATION_JSON.getMimeType()); - break; case GET_BUCKET_STATISTICS: wrapper.getHttpClientInputs().setHeaders(X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1); wrapper.getHttpClientInputs().setContentType(APPLICATION_JSON.getMimeType()); diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java index 0d84335..28c74c0 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java @@ -28,7 +28,9 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; +import static io.cloudslang.content.couchbase.entities.constants.Constants.ErrorMessages.INPUTS_COMBINATION_ERROR_MESSAGE; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.AMPERSAND; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.EQUAL; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKET_TYPE; @@ -41,9 +43,9 @@ import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.REPLICA_NUMBER; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.SASL_PASSWORD; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.THREADS_NUMBER; +import static io.cloudslang.content.couchbase.entities.couchbase.AuthType.SASL; import static io.cloudslang.content.couchbase.utils.InputsUtil.getPayloadString; import static io.cloudslang.content.couchbase.utils.InputsUtil.setOptionalMapEntry; -import static io.cloudslang.content.couchbase.validators.Validators.validateAuthType; import static io.cloudslang.content.httpclient.HttpClientInputs.AUTH_TYPE; import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; import static java.lang.String.valueOf; @@ -57,10 +59,10 @@ public class BucketsHelper { private static final String NAME = "name"; public String getCreateBucketPayload(InputsWrapper wrapper) { - return getPayloadString(getPayloadMap(wrapper), EQUAL, AMPERSAND, true); + return getPayloadString(buildPayloadMap(wrapper), EQUAL, AMPERSAND, true); } - private Map getPayloadMap(InputsWrapper wrapper) { + private Map buildPayloadMap(InputsWrapper wrapper) { Map payloadMap = new HashMap<>(); setOptionalMapEntry(payloadMap, PROXY_PORT, valueOf(wrapper.getBucketInputs().getProxyPort()), @@ -68,7 +70,14 @@ private Map getPayloadMap(InputsWrapper wrapper) { setOptionalMapEntry(payloadMap, SASL_PASSWORD, wrapper.getBucketInputs().getSaslPassword(), isNotBlank(wrapper.getBucketInputs().getSaslPassword())); - validateAuthType(payloadMap, wrapper.getBucketInputs().getAuthType()); + String authType = wrapper.getBucketInputs().getAuthType(); + + Optional + .of(authType) + .filter(f -> SASL.getValue().equals(authType) && !payloadMap.containsKey(SASL_PASSWORD)) + .ifPresent(err -> { + throw new RuntimeException(INPUTS_COMBINATION_ERROR_MESSAGE); + }); payloadMap.put(AUTH_TYPE, wrapper.getBucketInputs().getAuthType()); payloadMap.put(BUCKET_TYPE, wrapper.getBucketInputs().getBucketType()); diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java index c4a0233..17ba188 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java @@ -45,9 +45,7 @@ public static String getBucketsUriValue(InputsWrapper wrapper) { String action = wrapper.getCommonInputs().getAction(); switch (action) { case GET_BUCKET: - return BUCKETS + SLASH + wrapper.getBucketInputs().getBucketName(); case GET_BUCKET_STATISTICS: - return BUCKETS + SLASH + wrapper.getBucketInputs().getBucketName(); case DELETE_BUCKET: return BUCKETS + SLASH + wrapper.getBucketInputs().getBucketName(); default: diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHeadersBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHeadersBuilder.java index 160a0cd..e677452 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHeadersBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHeadersBuilder.java @@ -51,14 +51,8 @@ public static void setClusterHeaders(InputsWrapper wrapper) { wrapper.getHttpClientInputs().setContentType(FORM_URL_ENCODED); break; case GET_CLUSTER_DETAILS: - wrapper.getHttpClientInputs().setHeaders(X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1); - wrapper.getHttpClientInputs().setContentType(APPLICATION_JSON.getMimeType()); - break; - case GET_CLUSTER_INFO: - wrapper.getHttpClientInputs().setHeaders(X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1); - wrapper.getHttpClientInputs().setContentType(APPLICATION_JSON.getMimeType()); - break; case GET_DESTINATION_CLUSTER_REFERENCE: + case GET_CLUSTER_INFO: wrapper.getHttpClientInputs().setHeaders(X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1); wrapper.getHttpClientInputs().setContentType(APPLICATION_JSON.getMimeType()); break; diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHelper.java b/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHelper.java index 4d70d0b..54a11f5 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHelper.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterHelper.java @@ -36,7 +36,7 @@ import static io.cloudslang.content.couchbase.utils.InputsUtil.getPayloadString; import static io.cloudslang.content.couchbase.utils.InputsUtil.setOptionalMapEntry; import static io.cloudslang.content.couchbase.validators.Validators.validateNotBothBlankInputs; -import static io.cloudslang.content.couchbase.validators.Validators.validateRebalancingNodesPayloadInputs; +import static io.cloudslang.content.couchbase.validators.Validators.validateRebalancedNodesPayloadInputs; import static org.apache.commons.lang3.StringUtils.isNotBlank; /** @@ -54,8 +54,8 @@ private Map getPayloadMap(InputsWrapper wrapper) { validateNotBothBlankInputs(ejectedNodesString, knownNodesString, EJECTED_NODES, KNOWN_NODES); String delimiter = wrapper.getCommonInputs().getDelimiter(); - validateRebalancingNodesPayloadInputs(ejectedNodesString, delimiter); - validateRebalancingNodesPayloadInputs(knownNodesString, delimiter); + validateRebalancedNodesPayloadInputs(ejectedNodesString, delimiter); + validateRebalancedNodesPayloadInputs(knownNodesString, delimiter); Map payloadMap = new HashMap<>(); setOptionalMapEntry(payloadMap, EJECTED_NODES, wrapper.getClusterInputs().getEjectedNodes(), diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterUriFactory.java b/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterUriFactory.java index 232ce77..8253a75 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterUriFactory.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/cluster/ClusterUriFactory.java @@ -58,11 +58,10 @@ public static String getClusterUriValue(InputsWrapper wrapper) { case GET_AUTO_FAILOVER_SETTINGS: return SETTINGS.getValue() + AUTO_FAILOVER.getValue(); case GET_CLUSTER_DETAILS: + case GET_DESTINATION_CLUSTER_REFERENCE: return POOLS.getValue() + DEFAULT.getValue(); case GET_CLUSTER_INFO: return POOLS.getValue(); - case GET_DESTINATION_CLUSTER_REFERENCE: - return POOLS.getValue() + DEFAULT.getValue(); case REBALANCING_NODES: return CONTROLLER.getValue(); default: diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/nodes/NodesHelper.java b/src/main/java/io/cloudslang/content/couchbase/factory/nodes/NodesHelper.java index 591c593..e7336ab 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/nodes/NodesHelper.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/nodes/NodesHelper.java @@ -45,14 +45,14 @@ public class NodesHelper { private static final String RECOVERY_TYPE = "recoveryType"; public String getFailOverNodePayloadString(InputsWrapper wrapper) { - return getPayloadString(getPayloadMap(wrapper), EQUAL, EMPTY, false); + return getPayloadString(buildPayloadMap(wrapper), EQUAL, EMPTY, false); } public String getRecoveryTypePayloadString(InputsWrapper wrapper) { - return getPayloadString(getPayloadMap(wrapper), EQUAL, AMPERSAND, true); + return getPayloadString(buildPayloadMap(wrapper), EQUAL, AMPERSAND, true); } - private Map getPayloadMap(InputsWrapper wrapper) { + private Map buildPayloadMap(InputsWrapper wrapper) { Map payloadMap = new HashMap<>(); payloadMap.put(OTP_NODE, wrapper.getNodeInputs().getInternalNodeIpAddress()); diff --git a/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java b/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java index 59a6826..7ba4072 100644 --- a/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java +++ b/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java @@ -31,18 +31,24 @@ import io.cloudslang.content.couchbase.entities.couchbase.EvictionPolicy; import io.cloudslang.content.couchbase.entities.couchbase.RecoveryType; import io.cloudslang.content.couchbase.entities.inputs.InputsWrapper; +import io.cloudslang.content.httpclient.HttpClientInputs; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import java.net.MalformedURLException; +import java.net.URL; import java.util.Map; +import java.util.Optional; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.BLANK_SPACE; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.COMMA; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.SLASH; import static io.cloudslang.content.couchbase.entities.constants.Constants.Values.INIT_INDEX; import static io.cloudslang.content.couchbase.entities.couchbase.SuffixUri.getSuffixUriValue; +import static io.cloudslang.content.couchbase.factory.HeadersBuilder.buildHeaders; +import static io.cloudslang.content.couchbase.factory.PayloadBuilder.buildPayload; import static io.cloudslang.content.couchbase.factory.UriFactory.getUri; -import static io.cloudslang.content.couchbase.validators.Validators.getValidUrl; +import static io.cloudslang.content.couchbase.validators.Validators.isValidBoolean; import static io.cloudslang.content.utils.NumberUtilities.isValidInt; import static java.lang.Boolean.parseBoolean; import static java.lang.Integer.parseInt; @@ -63,43 +69,56 @@ private InputsUtil() { // prevent instantiation } - public static String buildUrl(InputsWrapper wrapper) throws MalformedURLException { - return getValidUrl(wrapper.getCommonInputs().getEndpoint()) + getUri(wrapper); + public static void setupApiCall(HttpClientInputs httpClientInputs, InputsWrapper wrapper) throws MalformedURLException { + httpClientInputs.setUrl(buildUrl(wrapper)); + + buildHeaders(wrapper); + buildPayload(wrapper); } public static String appendTo(String prefix, String suffix, String action) { - return isBlank(suffix) ? prefix : prefix + SLASH + suffix + getSuffixUriValue(action); + return Optional + .ofNullable(suffix) + .filter(StringUtils::isNotEmpty) + .map(s -> prefix + SLASH + suffix + getSuffixUriValue(action)) + .orElse(prefix); } public static String getPayloadString(Map payloadMap, String separator, String suffix, boolean deleteLastChar) { - return payloadMap.isEmpty() ? EMPTY : buildPayloadString(payloadMap, separator, suffix, deleteLastChar); + return Optional + .of(payloadMap) + .filter(f -> !payloadMap.isEmpty()) + .map(s -> buildPayloadString(payloadMap, separator, suffix, deleteLastChar)) + .orElse(EMPTY); } public static String getEnabledString(String input, boolean enforcedBoolean) { return getEnforcedBooleanCondition(input, enforcedBoolean) ? valueOf(1) : valueOf(INIT_INDEX); } - public static String getInputWithDefaultValue(String input, String defaultValue) { - return isBlank(input) ? defaultValue : input; - } - public static String[] getStringsArray(String input, String delimiter) { - return isBlank(input) ? null : split(input, delimiter); + return Optional + .ofNullable(input) + .filter(StringUtils::isNotEmpty) + .map(a -> split(input, delimiter)) + .orElse(null); } public static int getIntegerWithinValidRange(String input, Integer minAllowed, Integer maxAllowed) { - if (isValidInt(input, minAllowed, maxAllowed, true, true)) { - return parseInt(input); - } - - throw new RuntimeException(format("The provided value: %s is not within valid range. See operation inputs description section for details.", input)); + return Optional + .of(input) + .filter(f -> isValidInt(input, minAllowed, maxAllowed, true, true)) + .map(i -> parseInt(input)) + .orElseThrow(() -> new RuntimeException(format("The provided value: %s is not within valid range. " + + "See operation inputs description section for details.", input))); } public static int getIntegerAboveMinimum(String input, Integer minAllowed) { try { int validInt = parseInt(input); if (validInt < minAllowed) { - throw new RuntimeException(format("The provided value: %s is bellow minimum allowed. See operation inputs description section for details.", input)); + throw new RuntimeException(format("The provided value: %s is bellow minimum allowed. " + + "See operation inputs description section for details.", input)); } return validInt; @@ -122,11 +141,10 @@ public static int getIntegerAboveMinimum(String input, Integer minAllowed) { */ public static boolean getEnforcedBooleanCondition(String input, boolean enforcedBoolean) { return enforcedBoolean ? - !isBlank(input) && stream(new String[]{"true", "false"}) - .anyMatch(b -> b.equalsIgnoreCase(input)) == parseBoolean(input) : parseBoolean(input); + !isBlank(input) && isValidBoolean(input) == parseBoolean(input) : parseBoolean(input); } - public static > String getEnumValues(Class inputEnum) { + public static > String buildErrorMessage(Class inputEnum) { StringBuilder sb = new StringBuilder(); stream(inputEnum.getEnumConstants()) .forEach(enumValue -> { @@ -145,7 +163,11 @@ public static > String getEnumValues(Class inputEnum) { } }); - return isBlank(sb.toString()) ? EMPTY : sb.deleteCharAt(sb.length() - 2).toString().trim(); + return Optional + .of(sb.toString()) + .filter(StringUtils::isNotEmpty) + .map(s -> sb.deleteCharAt(sb.length() - 2).toString().trim()) + .orElse(EMPTY); } public static void setOptionalMapEntry(Map inputMap, String key, String value, boolean condition) { @@ -161,4 +183,8 @@ private static String buildPayloadString(Map payloadMap, String return deleteLastChar ? sb.deleteCharAt(sb.length() - 1).toString() : sb.toString(); } + + private static String buildUrl(InputsWrapper wrapper) throws MalformedURLException { + return new URL(wrapper.getCommonInputs().getEndpoint() + getUri(wrapper)).toString(); + } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/validators/Validators.java b/src/main/java/io/cloudslang/content/couchbase/validators/Validators.java index b0c4f37..f855bb7 100644 --- a/src/main/java/io/cloudslang/content/couchbase/validators/Validators.java +++ b/src/main/java/io/cloudslang/content/couchbase/validators/Validators.java @@ -23,24 +23,21 @@ */ package io.cloudslang.content.couchbase.validators; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.validator.routines.InetAddressValidator; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; +import java.util.Optional; import static io.cloudslang.content.couchbase.entities.constants.Constants.ErrorMessages.CONSTRAINS_ERROR_MESSAGE; -import static io.cloudslang.content.couchbase.entities.constants.Constants.ErrorMessages.INPUTS_COMBINATION_ERROR_MESSAGE; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.AT; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.PORT_REGEX; import static io.cloudslang.content.couchbase.entities.constants.Constants.Values.COUCHBASE_DEFAULT_PROXY_PORT; -import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.SASL_PASSWORD; -import static io.cloudslang.content.couchbase.entities.couchbase.AuthType.SASL; import static io.cloudslang.content.couchbase.utils.InputsUtil.getIntegerAboveMinimum; import static io.cloudslang.content.couchbase.utils.InputsUtil.getIntegerWithinValidRange; import static io.cloudslang.content.couchbase.utils.InputsUtil.getStringsArray; import static java.lang.Integer.parseInt; import static java.lang.String.format; +import static java.util.Arrays.asList; import static java.util.Arrays.stream; import static java.util.regex.Pattern.compile; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -68,8 +65,14 @@ public static int getValidPort(String input) { } public static int getValidIntValue(String input, Integer minAllowed, Integer maxAllowed, Integer defaultValue) { - return isBlank(input) ? defaultValue : maxAllowed == null ? - getIntegerAboveMinimum(input, minAllowed) : getIntegerWithinValidRange(input, minAllowed, maxAllowed); + return Optional + .ofNullable(input) + .filter(StringUtils::isNotEmpty) + .map(i -> Optional + .ofNullable(maxAllowed) + .map(inner -> getIntegerWithinValidRange(input, minAllowed, maxAllowed)) + .orElse(getIntegerAboveMinimum(input, minAllowed))) + .orElse(defaultValue); } public static String getValidInternalNodeIpAddress(String input) { @@ -85,27 +88,20 @@ public static void validateNotBothBlankInputs(String value1, String value2, Stri } } - public static void validateRebalancingNodesPayloadInputs(String input, String delimiter) { + public static void validateRebalancedNodesPayloadInputs(String input, String delimiter) { String[] nodesArray = getStringsArray(input, delimiter); - if (nodesArray != null) { - for (String node : nodesArray) { - validateClusterInternalNodeFormat(node); - } - } - } - - public static void validateAuthType(Map getPayloadMap, String authType) { - if (SASL.getValue().equals(authType) && !getPayloadMap.containsKey(SASL_PASSWORD)) { - throw new RuntimeException(INPUTS_COMBINATION_ERROR_MESSAGE); - } - } - public static String getValidOrDefaultValue(String input, String defaultValue, String[] validValues) { - return isNotBlank(input) && stream(validValues).anyMatch(filter -> filter.contains(input)) ? input : defaultValue; + Optional + .ofNullable(nodesArray) + .ifPresent(validate -> stream(nodesArray) + .forEach(Validators::validateClusterInternalNodeFormat)); } - public static String getValidUrl(String input) throws MalformedURLException { - return new URL(input).toString(); + public static boolean isValidBoolean(String parameter) { + return Optional + .ofNullable(parameter) + .map(b -> asList(new String[]{"true", "false"}).contains(parameter)) + .orElse(false); } private static void validateClusterInternalNodeFormat(String input) { diff --git a/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java b/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java index 8527f60..129e063 100644 --- a/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java +++ b/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java @@ -64,7 +64,7 @@ @PrepareForTest({CSHttpClient.class, CouchbaseService.class}) public class CouchbaseServiceTest { @Rule - public ExpectedException exception = ExpectedException.none(); + public final ExpectedException exception = ExpectedException.none(); @Mock private CSHttpClient csHttpClientMock; @@ -80,7 +80,7 @@ public void init() throws Exception { } @Test - public void testCreateOrEditBucket() throws MalformedURLException { + public void testCreateOrEditBucket() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "POST"); @@ -122,7 +122,7 @@ public void testCreateOrEditBucket() throws MalformedURLException { } @Test - public void testCreateOrEditBucketWithoutSaslPassword() throws MalformedURLException { + public void testCreateOrEditBucketWithoutSaslPassword() { setExpectedExceptions(RuntimeException.class, exception, "The combination of values supplied for inputs: " + "authType, proxyPort and/or saslPassword doesn't meet conditions for general purpose usage."); @@ -151,7 +151,7 @@ public void testCreateOrEditBucketWithoutSaslPassword() throws MalformedURLExcep } @Test - public void testDeleteBucket() throws MalformedURLException { + public void testDeleteBucket() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "DELETE"); @@ -167,7 +167,7 @@ public void testDeleteBucket() throws MalformedURLException { } @Test - public void testGetAllBuckets() throws MalformedURLException { + public void testGetAllBuckets() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); @@ -183,7 +183,7 @@ public void testGetAllBuckets() throws MalformedURLException { } @Test - public void testGetAutoFailOverSettings() throws MalformedURLException { + public void testGetAutoFailOverSettings() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); @@ -198,7 +198,7 @@ public void testGetAutoFailOverSettings() throws MalformedURLException { } @Test - public void testGetBucket() throws MalformedURLException { + public void testGetBucket() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); @@ -215,7 +215,7 @@ public void testGetBucket() throws MalformedURLException { } @Test - public void testGetBucketStatistics() throws MalformedURLException { + public void testGetBucketStatistics() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); @@ -232,7 +232,7 @@ public void testGetBucketStatistics() throws MalformedURLException { } @Test - public void testGetClusterDetails() throws MalformedURLException { + public void testGetClusterDetails() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); @@ -248,7 +248,7 @@ public void testGetClusterDetails() throws MalformedURLException { } @Test - public void testGetClusterInfo() throws MalformedURLException { + public void testGetClusterInfo() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); @@ -264,7 +264,7 @@ public void testGetClusterInfo() throws MalformedURLException { } @Test - public void testGetDesignDocsInfo() throws MalformedURLException { + public void testGetDesignDocsInfo() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); @@ -280,7 +280,7 @@ public void testGetDesignDocsInfo() throws MalformedURLException { } @Test - public void testFailOverNodeSuccess() throws MalformedURLException { + public void testFailOverNodeSuccess() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "POST"); @@ -297,7 +297,7 @@ public void testFailOverNodeSuccess() throws MalformedURLException { } @Test - public void testGracefulFailOverNodeSuccess() throws MalformedURLException { + public void testGracefulFailOverNodeSuccess() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "POST"); @@ -314,7 +314,7 @@ public void testGracefulFailOverNodeSuccess() throws MalformedURLException { } @Test - public void testRebalancingNodes() throws MalformedURLException { + public void testRebalancingNodes() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "POST"); @@ -342,7 +342,7 @@ public void testRebalancingNodes() throws MalformedURLException { } @Test - public void testSetRecoveryTypes() throws MalformedURLException { + public void testSetRecoveryTypes() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "POST"); @@ -361,7 +361,7 @@ public void testSetRecoveryTypes() throws MalformedURLException { } @Test - public void testFailOverNodeNoIPv4Address() throws MalformedURLException { + public void testFailOverNodeNoIPv4Address() { setExpectedExceptions(RuntimeException.class, exception, "The value of: [ blah blah blah ] input as part " + "of: [ns_2@ blah blah blah ] input must be a valid IPv4 address."); @@ -373,7 +373,7 @@ public void testFailOverNodeNoIPv4Address() throws MalformedURLException { } @Test - public void testFailOverNodeInvalidInternalNodeIpAddress() throws MalformedURLException { + public void testFailOverNodeInvalidInternalNodeIpAddress() { setExpectedExceptions(RuntimeException.class, exception, "The provided value for: " + "[ anything here but not [at] symbol ] input must be a valid Couchbase internal node format."); @@ -385,7 +385,7 @@ public void testFailOverNodeInvalidInternalNodeIpAddress() throws MalformedURLEx } @Test - public void testUnknownApi() throws MalformedURLException { + public void testUnknownApi() { setExpectedExceptions(RuntimeException.class, exception, "Unsupported Couchbase API."); httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", @@ -400,7 +400,7 @@ public void testUnknownApi() throws MalformedURLException { } @Test - public void testUnknownBuilderType() throws MalformedURLException { + public void testUnknownBuilderType() { setExpectedExceptions(RuntimeException.class, exception, "Unknown builder type."); httpClientInputs = getHttpClientInputs("someUser", "credentials", "proxy.example.com", "8080", @@ -415,7 +415,7 @@ public void testUnknownBuilderType() throws MalformedURLException { } @Test - public void testGetDestinationClusterReference() throws MalformedURLException { + public void testGetDestinationClusterReference() { httpClientInputs = getHttpClientInputs("anonymous", "credentials", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GET"); CommonInputs commonInputs = getCommonInputs("GetDestinationClusterReference", "cluster", "http://somewhere.couchbase.com:8091"); diff --git a/src/test/java/io/cloudslang/content/couchbase/utils/InputsUtilTest.java b/src/test/java/io/cloudslang/content/couchbase/utils/InputsUtilTest.java index 61850db..037424c 100644 --- a/src/test/java/io/cloudslang/content/couchbase/utils/InputsUtilTest.java +++ b/src/test/java/io/cloudslang/content/couchbase/utils/InputsUtilTest.java @@ -34,7 +34,7 @@ import java.util.HashMap; -import static io.cloudslang.content.couchbase.utils.InputsUtil.getEnumValues; +import static io.cloudslang.content.couchbase.utils.InputsUtil.buildErrorMessage; import static io.cloudslang.content.couchbase.utils.InputsUtil.getPayloadString; import static io.cloudslang.content.couchbase.validators.Validators.getValidIntValue; import static io.cloudslang.content.couchbase.validators.Validators.getValidPort; @@ -48,32 +48,32 @@ */ public class InputsUtilTest { @Rule - public ExpectedException exception = ExpectedException.none(); + public final ExpectedException exception = ExpectedException.none(); @Test public void testGetEnumValidAuthTypeValuesString() { - String toTest = getEnumValues(AuthType.class); + String toTest = buildErrorMessage(AuthType.class); assertEquals("none, sasl", toTest); } @Test public void testGetEnumValidBucketTypeValuesString() { - String toTest = getEnumValues(BucketType.class); + String toTest = buildErrorMessage(BucketType.class); assertEquals("couchbase, membase", toTest); } @Test public void testGetEnumValidConflictResolutionTypeValuesString() { - String toTest = getEnumValues(ConflictResolutionType.class); + String toTest = buildErrorMessage(ConflictResolutionType.class); assertEquals("lww, seqno", toTest); } @Test public void testGetEnumValidEvictionPolicyValuesString() { - String toTest = getEnumValues(EvictionPolicy.class); + String toTest = buildErrorMessage(EvictionPolicy.class); assertEquals("fullEviction, valueOnly", toTest); } From 6b4222daa0d79dc4b27d72f83d560eb2a6de35d5 Mon Sep 17 00:00:00 2001 From: Mihail Tusa Date: Thu, 27 Jun 2019 15:50:04 +0300 Subject: [PATCH 2/3] Couchbase - Added FlushBucket operation Signed off by Tusa Mihai: tusa.mihai@gmail.com --- .../actions/buckets/CreateOrEditBucket.java | 2 +- .../actions/buckets/DeleteBucket.java | 2 +- .../actions/buckets/FlushBucket.java | 188 ++++++++++++++++++ .../actions/buckets/GetAllBuckets.java | 2 +- .../couchbase/actions/buckets/GetBucket.java | 2 +- .../actions/buckets/GetBucketStatistics.java | 2 +- .../cluster/GetAutoFailOverSettings.java | 2 +- .../actions/cluster/GetClusterDetails.java | 2 +- .../actions/cluster/GetClusterInfo.java | 2 +- .../actions/cluster/RebalancingNodes.java | 2 +- .../couchbase/actions/nodes/FailOverNode.java | 2 +- .../actions/nodes/GracefulFailOverNode.java | 2 +- .../actions/nodes/SetRecoveryType.java | 2 +- .../actions/views/GetDesignDocsInfo.java | 2 +- .../xdcr/GetDestinationClusterReference.java | 2 +- .../entities/constants/Constants.java | 1 + .../entities/couchbase/ApiUriSuffix.java | 1 + .../factory/HttpClientInputsBuilder.java | 76 ++++--- .../factory/buckets/BucketsUriFactory.java | 5 + .../execute/CouchbaseServiceTest.java | 19 +- 20 files changed, 275 insertions(+), 43 deletions(-) create mode 100644 src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java index 7d59400..2105fee 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java @@ -264,7 +264,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(CREATE_OR_EDIT_BUCKET) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java index 653736b..f1ef424 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java @@ -193,7 +193,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpDelete.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpDelete.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(DELETE_BUCKET) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java new file mode 100644 index 0000000..c7b5466 --- /dev/null +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java @@ -0,0 +1,188 @@ +package io.cloudslang.content.couchbase.actions.buckets; + +import com.hp.oo.sdk.content.annotations.Action; +import com.hp.oo.sdk.content.annotations.Output; +import com.hp.oo.sdk.content.annotations.Param; +import com.hp.oo.sdk.content.annotations.Response; +import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; +import com.hp.oo.sdk.content.plugin.ActionMetadata.ResponseType; +import io.cloudslang.content.constants.ReturnCodes; +import io.cloudslang.content.couchbase.entities.inputs.BucketInputs; +import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; +import io.cloudslang.content.couchbase.execute.CouchbaseService; +import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; +import io.cloudslang.content.httpclient.HttpClientInputs; +import org.apache.http.client.methods.HttpPost; + +import java.util.Map; + +import static io.cloudslang.content.constants.OutputNames.EXCEPTION; +import static io.cloudslang.content.constants.OutputNames.RETURN_CODE; +import static io.cloudslang.content.constants.OutputNames.RETURN_RESULT; +import static io.cloudslang.content.constants.ResponseNames.FAILURE; +import static io.cloudslang.content.constants.ResponseNames.SUCCESS; +import static io.cloudslang.content.couchbase.entities.constants.Constants.Api.BUCKETS; +import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.FLUSH_BUCKET; +import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKET_NAME; +import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; +import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; + +public class FlushBucket { + /** + * Empties the contents of the specified bucket, deleting all stored data.. + * https://docs.couchbase.com/server/4.6/rest-api/rest-bucket-flush.html + *

+ * Note: + * 1. The Flush Bucket operation succeeds only if flush was configured either during the initial bucket setup or after + * the bucket settings have been changed. + * 2. Parameters and payload data are ignored, but the request must including the authorization header if the system + * has been secured. + * 3. The flush request may lead to significant disk activity as the data in the bucket is deleted from the database. + * The high disk utilization may affect the performance of your server until the data has been successfully deleted. + * 4. The flush request is not transmitted over XDCR replication configurations. The remote bucket is not flushed. + *

+ * Warning: It is recommended that the flush capability is not used in production systems as it irreversibly deletes + * every document in the bucket. Even for use cases where this is the desired behaviour, flushing is not recommended + * as it is a very disruptive process. You can control and limit the ability to flush individual buckets by setting + * the flushEnabled parameter on a bucket in the Couchbase Web Console. + * + * @param endpoint Endpoint to which request will be sent. A valid endpoint will be formatted as it shows in + * bellow example. + * Example: "http://somewhere.couchbase.com:8091" + * @param username Username used in basic authentication. + * @param password Password associated with "username" input to be used in basic authentication. + * @param proxyHost Optional - proxy server used to connect to Couchbase API. If empty no proxy will be used. + * @param proxyPort Optional - proxy server port. You must either specify values for both proxyHost and + * proxyPort inputs or leave them both empty. + * @param proxyUsername Optional - proxy server user name. + * @param proxyPassword Optional - proxy server password associated with the proxyUsername input value. + * @param trustAllRoots Optional - specifies whether to enable weak security over SSL/TSL. A certificate is + * trusted even if no trusted certification authority issued it. + * Valid values: "true", "false" + * Default value: "true" + * @param x509HostnameVerifier Optional - specifies the way the server hostname must match a domain name in the subject's + * Common Name (CN) or subjectAltName field of the X.509 certificate. Set this to "allow_all" + * to skip any checking. For the value "browser_compatible" the hostname verifier works + * the same way as Curl and Firefox. The hostname must match either the first CN, or any + * of the subject-alts. A wildcard can occur in the CN, and in any of the subject-alts. + * The only difference between "browser_compatible" and "strict" is that a wildcard (such + * as "*.foo.com") with "browser_compatible" matches all subdomains, including "a.b.foo.com". + * Valid values: "strict", "browser_compatible", "allow_all" + * Default value: "allow_all" + * @param trustKeystore Optional - pathname of the Java TrustStore file. This contains certificates from other + * parties that you expect to communicate with, or from Certificate Authorities that you + * trust to identify other parties. If the protocol (specified by the "url") is not "https" + * or if trustAllRoots is "true" this input is ignored. + * Default value: ../java/lib/security/cacerts + * Format: Java KeyStore (JKS) + * @param trustPassword Optional - password associated with the TrustStore file. If trustAllRoots is "false" + * and trustKeystore is empty, trustPassword default will be supplied. + * Default value: "changeit" + * @param keystore Optional - pathname of the Java KeyStore file. You only need this if the server requires + * client authentication. If the protocol (specified by the "url") is not "https" or if + * trustAllRoots is "true" this input is ignored. + * Format: Java KeyStore (JKS) + * Default value: ../java/lib/security/cacerts. + * @param keystorePassword Optional - password associated with the KeyStore file. If trustAllRoots is "false" and + * keystore is empty, keystorePassword default will be supplied. + * Default value: "changeit" + * @param connectTimeout Optional - time to wait for a connection to be established, in seconds. A timeout value + * of "0" represents an infinite timeout. + * Default value: "0" + * @param socketTimeout Optional - timeout for waiting for data (a maximum period inactivity between two + * consecutive data packets), in seconds. A socketTimeout value of "0" represents an + * infinite timeout. + * Default value: "0" + * @param useCookies Optional - specifies whether to enable cookie tracking or not. Cookies are stored between + * consecutive calls in a serializable session object therefore they will be available on + * a branch level. If you specify a non-boolean value, the default value is used. + * Valid values: "true", "false" + * Default value: "true" + * @param keepAlive Optional - specifies whether to create a shared connection that will be used in subsequent + * calls. If keepAlive is "false", the already open connection will be used and after + * execution it will close it. + * Valid values: "true", "false" + * Default value: "true" + * @param bucketName Name of the bucket to be deleted + * @return A map with strings as keys and strings as values that contains: outcome of the action (or failure message + * and the exception if there is one), returnCode of the operation and the ID of the request + */ + @Action(name = "Flush Bucket", + outputs = { + @Output(RETURN_CODE), + @Output(RETURN_RESULT), + @Output(EXCEPTION) + }, + responses = { + @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, + matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), + @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, + matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) + }) + public Map execute(@Param(value = ENDPOINT, required = true) String endpoint, + @Param(value = USERNAME, required = true) String username, + @Param(value = PASSWORD, required = true, encrypted = true) String password, + @Param(value = PROXY_HOST) String proxyHost, + @Param(value = PROXY_PORT) String proxyPort, + @Param(value = PROXY_USERNAME) String proxyUsername, + @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, + @Param(value = TRUST_ALL_ROOTS) String trustAllRoots, + @Param(value = X509_HOSTNAME_VERIFIER) String x509HostnameVerifier, + @Param(value = TRUST_KEYSTORE) String trustKeystore, + @Param(value = TRUST_PASSWORD, encrypted = true) String trustPassword, + @Param(value = KEYSTORE) String keystore, + @Param(value = KEYSTORE_PASSWORD, encrypted = true) String keystorePassword, + @Param(value = CONNECT_TIMEOUT) String connectTimeout, + @Param(value = SOCKET_TIMEOUT) String socketTimeout, + @Param(value = USE_COOKIES) String useCookies, + @Param(value = KEEP_ALIVE) String keepAlive, + @Param(value = BUCKET_NAME, required = true) String bucketName) { + try { + final HttpClientInputsBuilder httpClientInputsBuilder = new HttpClientInputsBuilder.Builder() + .withUsername(username) + .withPassword(password) + .withTrustAllRoots(trustAllRoots) + .withX509HostnameVerifier(x509HostnameVerifier) + .withTrustKeystore(trustKeystore) + .withTrustPassword(trustPassword) + .withKeystore(keystore) + .withKeystorePassword(keystorePassword) + .withConnectTimeout(connectTimeout) + .withSocketTimeout(socketTimeout) + .withUseCookies(useCookies) + .withKeepAlive(keepAlive) + .build(); + + final HttpClientInputs httpClientInputs = httpClientInputsBuilder + .buildHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + + final CommonInputs commonInputs = new CommonInputs.Builder() + .withAction(FLUSH_BUCKET) + .withApi(BUCKETS) + .withEndpoint(endpoint) + .build(); + + final BucketInputs bucketInputs = new BucketInputs.Builder().withBucketName(bucketName).build(); + + return new CouchbaseService().execute(httpClientInputs, commonInputs, bucketInputs); + } catch (Exception exception) { + return getFailureResultsMap(exception); + } + } +} diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java index 7857b4e..1d3f417 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java @@ -180,7 +180,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_ALL_BUCKETS) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java index 4147a7d..efe0b17 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java @@ -184,7 +184,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_BUCKET) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java index 288e5fa..f8cae07 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java @@ -184,7 +184,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_BUCKET_STATISTICS) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java index e1f9d22..3012814 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java @@ -176,7 +176,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_AUTO_FAILOVER_SETTINGS) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java index 7791613..849da85 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java @@ -180,7 +180,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_CLUSTER_DETAILS) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java index 9f99119..786dd62 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java @@ -180,7 +180,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_CLUSTER_INFO) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java index 1e799f4..8fef70c 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java @@ -194,7 +194,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(REBALANCING_NODES) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java index 39c668e..3ffebd3 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java @@ -187,7 +187,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(FAIL_OVER_NODE) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java index 1f7c3e1..b3b5766 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java @@ -186,7 +186,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GRACEFUL_FAIL_OVER_NODE) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java index 9ba37ab..4913380 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java @@ -193,7 +193,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpPost.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(SET_RECOVERY_TYPE) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java b/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java index 2d39c11..0bf5feb 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java @@ -184,7 +184,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_DESIGN_DOCS_INFO) diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java b/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java index 2ba11a8..59920cf 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java @@ -194,7 +194,7 @@ public Map execute(@Param(value = ENDPOINT, required = true) Str .build(); final HttpClientInputs httpClientInputs = httpClientInputsBuilder - .getHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(HttpGet.METHOD_NAME, proxyHost, proxyPort, proxyUsername, proxyPassword); final CommonInputs commonInputs = new CommonInputs.Builder() .withAction(GET_DESTINATION_CLUSTER_REFERENCE) diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java b/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java index 51f0c45..1d1d98f 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java @@ -44,6 +44,7 @@ public class Api { public class BucketActions { public static final String CREATE_OR_EDIT_BUCKET = "CreateOrEditBucket"; public static final String DELETE_BUCKET = "DeleteBucket"; + public static final String FLUSH_BUCKET = "FlushBucket"; public static final String GET_ALL_BUCKETS = "GetAllBuckets"; public static final String GET_BUCKET = "GetBucket"; public static final String GET_BUCKET_STATISTICS = "GetBucketStatistics"; diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ApiUriSuffix.java b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ApiUriSuffix.java index 3d446f9..dcb951b 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ApiUriSuffix.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/couchbase/ApiUriSuffix.java @@ -27,6 +27,7 @@ public enum ApiUriSuffix { ADD_NODE("/addNode"), AUTO_FAILOVER("/autoFailover"), DEFAULT("/default"), + DO_FLUSH("/doFlush"), DO_JOIN_CLUSTER("/doJoinCluster"), EJECT_NODE_ENTRY("/ejectNodeentry"), SELF("/self"), diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java index 598af53..6dcfd5e 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java @@ -38,7 +38,6 @@ import static java.lang.String.valueOf; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.stream; -import static org.apache.commons.lang3.StringUtils.isNotBlank; public class HttpClientInputsBuilder { private static final String[] x509HostnameVerifierValidValuesArray = new String[]{"allow_all", "browser_compatible", "strict"}; @@ -125,22 +124,27 @@ public String getKeepAlive() { return keepAlive; } - public HttpClientInputs getHttpClientInputs(String methodName, String proxyHost, String proxyPort, String proxyUsername, - String proxyPassword) { + public HttpClientInputs buildHttpClientInputs(String methodName, String proxyHost, String proxyPort, + String proxyUsername, String proxyPassword) { httpClientInputs.setMethod(methodName); - if (isNotBlank(proxyUsername)) { - httpClientInputs.setProxyUsername(proxyUsername); - } + Optional + .ofNullable(proxyUsername) + .filter(StringUtils::isNotEmpty) + .ifPresent(set -> httpClientInputs.setProxyUsername(proxyUsername)); - if (areBothValuesPresent(proxyUsername, proxyPassword)) { - httpClientInputs.setProxyPassword(proxyPassword); - } + Optional + .ofNullable(proxyPassword) + .filter(f -> areBothValuesPresent(proxyUsername, proxyPassword)) + .ifPresent(set -> httpClientInputs.setProxyPassword(proxyPassword)); - if (areBothValuesPresent(proxyHost, proxyPort)) { - httpClientInputs.setProxyHost(proxyHost); - httpClientInputs.setProxyPort(proxyPort); - } + Optional + .ofNullable(proxyHost) + .filter(f -> areBothValuesPresent(proxyHost, proxyPort)) + .ifPresent(set -> { + httpClientInputs.setProxyHost(proxyHost); + httpClientInputs.setProxyPort(proxyPort); + }); return httpClientInputs; } @@ -199,14 +203,24 @@ public Builder withUseCookies(String inputValue) { } public Builder withConnectTimeout(String inputValue) { - this.connectTimeout = valueOf(isValidInt(inputValue, 0, MAX_VALUE) ? parseInt(inputValue) : 0); + this.connectTimeout = valueOf(Optional + .ofNullable(inputValue) + .filter(f -> isValidInt(inputValue, 0, MAX_VALUE)) + .map(i -> parseInt(inputValue)) + .orElse(0)); + httpClientInputs.setConnectTimeout(connectTimeout); return this; } public Builder withSocketTimeout(String inputValue) { - this.socketTimeout = valueOf(isValidInt(inputValue, 0, MAX_VALUE) ? parseInt(inputValue) : 0); + this.socketTimeout = valueOf(Optional + .ofNullable(inputValue) + .filter(f -> isValidInt(inputValue, 0, MAX_VALUE)) + .map(i -> parseInt(inputValue)) + .orElse(0)); + httpClientInputs.setSocketTimeout(socketTimeout); return this; @@ -228,36 +242,44 @@ public Builder withX509HostnameVerifier(String inputValue) { public Builder withTrustKeystore(String inputValue) { this.trustKeystore = inputValue; - if (isNotBlank(trustKeystore)) { - httpClientInputs.setTrustKeystore(trustKeystore); - } + + Optional + .ofNullable(trustKeystore) + .filter(StringUtils::isNotEmpty) + .ifPresent(set -> httpClientInputs.setTrustKeystore(trustKeystore)); return this; } public Builder withTrustPassword(String inputValue) { this.trustPassword = inputValue; - if (isNotBlank(trustPassword)) { - httpClientInputs.setTrustPassword(trustPassword); - } + + Optional + .ofNullable(trustPassword) + .filter(StringUtils::isNotEmpty) + .ifPresent(set -> httpClientInputs.setTrustPassword(trustPassword)); return this; } public Builder withKeystore(String inputValue) { this.keystore = inputValue; - if (isNotBlank(keystore)) { - httpClientInputs.setKeystore(keystore); - } + + Optional + .ofNullable(keystore) + .filter(StringUtils::isNotEmpty) + .ifPresent(set -> httpClientInputs.setKeystore(keystore)); return this; } public Builder withKeystorePassword(String inputValue) { this.keystorePassword = inputValue; - if (isNotBlank(keystorePassword)) { - httpClientInputs.setKeystorePassword(keystorePassword); - } + + Optional + .ofNullable(keystorePassword) + .filter(StringUtils::isNotEmpty) + .ifPresent(set -> httpClientInputs.setKeystorePassword(keystorePassword)); return this; } diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java index 17ba188..ec663db 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsUriFactory.java @@ -27,10 +27,13 @@ import io.cloudslang.content.couchbase.entities.inputs.InputsWrapper; import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.DELETE_BUCKET; +import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.FLUSH_BUCKET; import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.GET_BUCKET; import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.GET_BUCKET_STATISTICS; import static io.cloudslang.content.couchbase.entities.constants.Constants.Miscellaneous.SLASH; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKETS; +import static io.cloudslang.content.couchbase.entities.couchbase.ApiUriSuffix.DO_FLUSH; +import static io.cloudslang.content.couchbase.entities.couchbase.CouchbaseApi.CONTROLLER; /** * Created by Mihai Tusa @@ -48,6 +51,8 @@ public static String getBucketsUriValue(InputsWrapper wrapper) { case GET_BUCKET_STATISTICS: case DELETE_BUCKET: return BUCKETS + SLASH + wrapper.getBucketInputs().getBucketName(); + case FLUSH_BUCKET: + return BUCKETS + SLASH + wrapper.getBucketInputs().getBucketName() + CONTROLLER.getValue() + DO_FLUSH.getValue(); default: return BUCKETS; } diff --git a/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java b/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java index 129e063..31a1c8a 100644 --- a/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java +++ b/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java @@ -40,7 +40,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import java.net.MalformedURLException; import java.util.HashMap; import static io.cloudslang.content.couchbase.utils.TestUtils.setExpectedExceptions; @@ -166,6 +165,22 @@ public void testDeleteBucket() { assertEquals("application/json", httpClientInputs.getContentType()); } + @Test + public void testFlushBucket() { + httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", + "", "", "", "", "", "", + "", "", "", "", "", "", "POST"); + CommonInputs commonInputs = getCommonInputs("FlushBucket", "buckets", "http://anywhere.couchbase.com:8091"); + BucketInputs bucketInputs = new BucketInputs.Builder().withBucketName("toBeFlushedBucket").build(); + toTest.execute(httpClientInputs, commonInputs, bucketInputs); + + verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(csHttpClientMock); + + assertEquals("http://anywhere.couchbase.com:8091/pools/default/buckets/toBeFlushedBucket/controller/doFlush", httpClientInputs.getUrl()); + assertEquals("application/json", httpClientInputs.getContentType()); + } + @Test public void testGetAllBuckets() { httpClientInputs = getHttpClientInputs("someUser", "credentials", "", "", @@ -467,7 +482,7 @@ private HttpClientInputs getHttpClientInputs(String username, String password, S .build(); return httpClientInputsBuilder - .getHttpClientInputs(method, proxyHost, proxyPort, proxyUsername, proxyPassword); + .buildHttpClientInputs(method, proxyHost, proxyPort, proxyUsername, proxyPassword); } } \ No newline at end of file From 763160647768921031a9c62201c6bc748bb7b4d3 Mon Sep 17 00:00:00 2001 From: Mihail Tusa Date: Tue, 20 Aug 2019 12:14:11 +0300 Subject: [PATCH 3/3] Fix project Signed off by Tusa Mihai: tusa.mihai@gmail.com --- pom.xml | 7 +- .../actions/buckets/CreateOrEditBucket.java | 36 ++++---- .../actions/buckets/DeleteBucket.java | 34 ++++---- .../actions/buckets/FlushBucket.java | 43 ++++++---- .../actions/buckets/GetAllBuckets.java | 34 ++++---- .../couchbase/actions/buckets/GetBucket.java | 34 ++++---- .../actions/buckets/GetBucketStatistics.java | 34 ++++---- .../cluster/GetAutoFailOverSettings.java | 34 ++++---- .../actions/cluster/GetClusterDetails.java | 34 ++++---- .../actions/cluster/GetClusterInfo.java | 34 ++++---- .../actions/cluster/RebalancingNodes.java | 34 ++++---- .../couchbase/actions/nodes/FailOverNode.java | 34 ++++---- .../actions/nodes/GracefulFailOverNode.java | 34 ++++---- .../actions/nodes/SetRecoveryType.java | 34 ++++---- .../actions/views/GetDesignDocsInfo.java | 34 ++++---- .../xdcr/GetDestinationClusterReference.java | 34 ++++---- .../entities/constants/Constants.java | 18 ++-- .../entities/inputs/InputsWrapper.java | 2 +- .../couchbase/execute/CouchbaseService.java | 6 +- .../factory/HttpClientInputsBuilder.java | 2 +- .../factory/InputsWrapperBuilder.java | 3 +- .../factory/buckets/BucketsHelper.java | 4 +- .../content/couchbase/utils/InputsUtil.java | 2 +- .../execute/CouchbaseServiceTest.java | 82 +++++++++---------- 24 files changed, 329 insertions(+), 318 deletions(-) diff --git a/pom.xml b/pom.xml index 55cd6cb..f8c9f59 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ 1.10.7 1.6 - 0.1.73 + 0.1.75 0.0.6 0.10.0 @@ -244,6 +244,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.1 1.8 1.8 @@ -259,8 +260,8 @@ org.apache.maven.plugins - maven-gpg-plugin - ${maven-gpg-plugin.version} + maven-compiler-plugin + 3.1 sign-artifacts diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java index 2105fee..610558a 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/CreateOrEditBucket.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import java.util.Map; @@ -59,23 +59,23 @@ import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.SASL_PASSWORD; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.THREADS_NUMBER; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.AUTH_TYPE; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.AUTH_TYPE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; import static org.apache.http.client.methods.HttpPost.METHOD_NAME; diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java index f1ef424..97d787d 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/DeleteBucket.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpDelete; import java.util.Map; @@ -49,22 +49,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.DELETE_BUCKET; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKET_NAME; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java index c7b5466..f843e00 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/FlushBucket.java @@ -1,3 +1,12 @@ +/* + * (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Apache License v2.0 which accompany this distribution. + * + * The Apache License is available at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ package io.cloudslang.content.couchbase.actions.buckets; import com.hp.oo.sdk.content.annotations.Action; @@ -11,7 +20,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpPost; import java.util.Map; @@ -25,22 +34,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.FLUSH_BUCKET; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKET_NAME; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; public class FlushBucket { diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java index 1d3f417..122c9a0 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetAllBuckets.java @@ -34,7 +34,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -47,22 +47,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.Api.BUCKETS; import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.GET_ALL_BUCKETS; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java index efe0b17..5575d6c 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucket.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -49,22 +49,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.GET_BUCKET; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKET_NAME; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java index f8cae07..6d0b414 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/buckets/GetBucketStatistics.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -49,22 +49,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.BucketActions.GET_BUCKET_STATISTICS; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKET_NAME; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java index 3012814..cb2f7ab 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetAutoFailOverSettings.java @@ -33,7 +33,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -46,22 +46,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.Api.CLUSTER; import static io.cloudslang.content.couchbase.entities.constants.Constants.ClusterActions.GET_AUTO_FAILOVER_SETTINGS; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; public class GetAutoFailOverSettings { diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java index 849da85..a9fdc59 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterDetails.java @@ -34,7 +34,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -47,22 +47,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.Api.CLUSTER; import static io.cloudslang.content.couchbase.entities.constants.Constants.ClusterActions.GET_CLUSTER_DETAILS; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java index 786dd62..06c6f67 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/GetClusterInfo.java @@ -34,7 +34,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -47,22 +47,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.Api.CLUSTER; import static io.cloudslang.content.couchbase.entities.constants.Constants.ClusterActions.GET_CLUSTER_INFO; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java index 8fef70c..31c1833 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/cluster/RebalancingNodes.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpPost; import java.util.Map; @@ -51,22 +51,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Inputs.ClusterInputs.KNOWN_NODES; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.DELIMITER; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java index 3ffebd3..bd6ae82 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/FailOverNode.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.NodeInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpPost; import java.util.Map; @@ -49,22 +49,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.NodeActions.FAIL_OVER_NODE; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; import static io.cloudslang.content.couchbase.entities.constants.Inputs.NodeInputs.INTERNAL_NODE_IP_ADDRESS; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java index b3b5766..d32afd6 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/GracefulFailOverNode.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.NodeInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpPost; import java.util.Map; @@ -49,22 +49,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.NodeActions.GRACEFUL_FAIL_OVER_NODE; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; import static io.cloudslang.content.couchbase.entities.constants.Inputs.NodeInputs.INTERNAL_NODE_IP_ADDRESS; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java index 4913380..c3a83a4 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/nodes/SetRecoveryType.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.NodeInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpPost; import java.util.Map; @@ -50,22 +50,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; import static io.cloudslang.content.couchbase.entities.constants.Inputs.NodeInputs.INTERNAL_NODE_IP_ADDRESS; import static io.cloudslang.content.couchbase.entities.constants.Inputs.NodeInputs.RECOVERY_TYPE; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java b/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java index 0bf5feb..196b50e 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/views/GetDesignDocsInfo.java @@ -35,7 +35,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -49,22 +49,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.ViewsActions.GET_DESIGN_DOCS_INFO; import static io.cloudslang.content.couchbase.entities.constants.Inputs.BucketInputs.BUCKET_NAME; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java b/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java index 59920cf..fb166d5 100644 --- a/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java +++ b/src/main/java/io/cloudslang/content/couchbase/actions/xdcr/GetDestinationClusterReference.java @@ -41,7 +41,7 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.execute.CouchbaseService; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.http.client.methods.HttpGet; import java.util.Map; @@ -57,22 +57,22 @@ import static io.cloudslang.content.couchbase.entities.constants.Constants.Api.CLUSTER; import static io.cloudslang.content.couchbase.entities.constants.Constants.ClusterActions.GET_DESTINATION_CLUSTER_REFERENCE; import static io.cloudslang.content.couchbase.entities.constants.Inputs.CommonInputs.ENDPOINT; -import static io.cloudslang.content.httpclient.HttpClientInputs.CONNECT_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEEP_ALIVE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.KEYSTORE_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_HOST; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.SOCKET_TIMEOUT; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_ALL_ROOTS; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_KEYSTORE; -import static io.cloudslang.content.httpclient.HttpClientInputs.TRUST_PASSWORD; -import static io.cloudslang.content.httpclient.HttpClientInputs.USERNAME; -import static io.cloudslang.content.httpclient.HttpClientInputs.USE_COOKIES; -import static io.cloudslang.content.httpclient.HttpClientInputs.X509_HOSTNAME_VERIFIER; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.CONNECT_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEEP_ALIVE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.KEYSTORE_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_HOST; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.SOCKET_TIMEOUT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_ALL_ROOTS; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_KEYSTORE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.TRUST_PASSWORD; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USERNAME; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.USE_COOKIES; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.X509_HOSTNAME_VERIFIER; import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap; /** diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java b/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java index 1d1d98f..4c697bd 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/constants/Constants.java @@ -34,14 +34,14 @@ private Constants() { // prevent instantiation } - public class Api { + public static class Api { public static final String BUCKETS = "buckets"; public static final String CLUSTER = "cluster"; public static final String NODES = "nodes"; public static final String VIEWS = "views"; } - public class BucketActions { + public static class BucketActions { public static final String CREATE_OR_EDIT_BUCKET = "CreateOrEditBucket"; public static final String DELETE_BUCKET = "DeleteBucket"; public static final String FLUSH_BUCKET = "FlushBucket"; @@ -50,7 +50,7 @@ public class BucketActions { public static final String GET_BUCKET_STATISTICS = "GetBucketStatistics"; } - public class ClusterActions { + public static class ClusterActions { public static final String GET_AUTO_FAILOVER_SETTINGS = "GetAutoFailOverSettings"; public static final String GET_CLUSTER_DETAILS = "GetClusterDetails"; public static final String GET_CLUSTER_INFO = "GetClusterInfo"; @@ -58,7 +58,7 @@ public class ClusterActions { public static final String REBALANCING_NODES = "RebalancingNodes"; } - public class ErrorMessages { + public static class ErrorMessages { public static final String CONSTRAINS_ERROR_MESSAGE = "The value doesn't meet conditions for general purpose usage. " + "See operation inputs description section for details."; public static final String UNKNOWN_BUILDER_TYPE = "Unknown builder type."; @@ -68,13 +68,13 @@ public class ErrorMessages { "authType, proxyPort and/or saslPassword doesn't meet conditions for general purpose usage."; } - public class HttpClientInputsValues { + public static class HttpClientInputsValues { public static final String ALL_TYPE_HEADER = "Accept:application/json, text/plain, */*"; public static final String FORM_URL_ENCODED = "application/x-www-form-urlencoded; charset=UTF-8"; public static final String X_MEMCACHEKV_STORE_CLIENT_SPECIFICATION_VERSION_0_1 = "X-memcachekv-Store-Client-Specification-Version:0.1"; } - public class Miscellaneous { + public static class Miscellaneous { public static final String ALLOW_ALL = "allow_all"; public static final String AMPERSAND = "&"; public static final String AT = "@"; @@ -85,13 +85,13 @@ public class Miscellaneous { public static final String SLASH = "/"; } - public class NodeActions { + public static class NodeActions { public static final String FAIL_OVER_NODE = "FailOverNode"; public static final String GRACEFUL_FAIL_OVER_NODE = "GracefulFailOverNode"; public static final String SET_RECOVERY_TYPE = "SetRecoveryType"; } - public class Values { + public static class Values { public static final int COUCHBASE_DEFAULT_PROXY_PORT = 11215; public static final int DEFAULT_REPLICA_NUMBER = 1; public static final int DEFAULT_THREADS_NUMBER = 2; @@ -103,7 +103,7 @@ public class Values { public static final int THREADS_NUMBER = 10; } - public class ViewsActions { + public static class ViewsActions { public static final String GET_DESIGN_DOCS_INFO = "GetDesignDocsInfo"; } } \ No newline at end of file diff --git a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/InputsWrapper.java b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/InputsWrapper.java index 6e95374..0294020 100644 --- a/src/main/java/io/cloudslang/content/couchbase/entities/inputs/InputsWrapper.java +++ b/src/main/java/io/cloudslang/content/couchbase/entities/inputs/InputsWrapper.java @@ -24,7 +24,7 @@ package io.cloudslang.content.couchbase.entities.inputs; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; /** * Created by Mihai Tusa diff --git a/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java b/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java index 463a7d5..828edb8 100644 --- a/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java +++ b/src/main/java/io/cloudslang/content/couchbase/execute/CouchbaseService.java @@ -26,8 +26,8 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.entities.inputs.InputsWrapper; -import io.cloudslang.content.httpclient.CSHttpClient; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; +import io.cloudslang.content.httpclient.services.HttpClientService; import io.cloudslang.content.utils.OutputUtilities; import io.vavr.control.Try; @@ -64,7 +64,7 @@ public final Map execute(HttpClientInputs httpClientInputs, private Map asyncCall(HttpClientInputs httpClientInputs) throws InterruptedException, ExecutionException { return CompletableFuture - .supplyAsync(() -> new CSHttpClient().execute(httpClientInputs), executorService) + .supplyAsync(() -> new HttpClientService().execute(httpClientInputs), executorService) .exceptionally(OutputUtilities::getFailureResultsMap) .get(); } diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java index 6dcfd5e..4c03c14 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/HttpClientInputsBuilder.java @@ -23,7 +23,7 @@ */ package io.cloudslang.content.couchbase.factory; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.commons.lang3.StringUtils; import java.util.Optional; diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java b/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java index 02e2a09..0f4d0c8 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/InputsWrapperBuilder.java @@ -29,13 +29,14 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.entities.inputs.InputsWrapper; import io.cloudslang.content.couchbase.entities.inputs.NodeInputs; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import java.util.Optional; import static io.cloudslang.content.couchbase.entities.constants.Constants.ErrorMessages.UNKNOWN_BUILDER_TYPE; import static io.cloudslang.content.couchbase.entities.constants.Constants.Values.INIT_INDEX; + /** * Created by Mihai Tusa * 4/9/2017. diff --git a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java index 28c74c0..d0ba615 100644 --- a/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java +++ b/src/main/java/io/cloudslang/content/couchbase/factory/buckets/BucketsHelper.java @@ -46,8 +46,8 @@ import static io.cloudslang.content.couchbase.entities.couchbase.AuthType.SASL; import static io.cloudslang.content.couchbase.utils.InputsUtil.getPayloadString; import static io.cloudslang.content.couchbase.utils.InputsUtil.setOptionalMapEntry; -import static io.cloudslang.content.httpclient.HttpClientInputs.AUTH_TYPE; -import static io.cloudslang.content.httpclient.HttpClientInputs.PROXY_PORT; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.AUTH_TYPE; +import static io.cloudslang.content.httpclient.entities.HttpClientInputs.PROXY_PORT; import static java.lang.String.valueOf; import static org.apache.commons.lang3.StringUtils.isNotBlank; diff --git a/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java b/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java index 7ba4072..1468ba9 100644 --- a/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java +++ b/src/main/java/io/cloudslang/content/couchbase/utils/InputsUtil.java @@ -31,7 +31,7 @@ import io.cloudslang.content.couchbase.entities.couchbase.EvictionPolicy; import io.cloudslang.content.couchbase.entities.couchbase.RecoveryType; import io.cloudslang.content.couchbase.entities.inputs.InputsWrapper; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; diff --git a/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java b/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java index 31a1c8a..8e4d5e2 100644 --- a/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java +++ b/src/test/java/io/cloudslang/content/couchbase/execute/CouchbaseServiceTest.java @@ -29,8 +29,8 @@ import io.cloudslang.content.couchbase.entities.inputs.CommonInputs; import io.cloudslang.content.couchbase.entities.inputs.NodeInputs; import io.cloudslang.content.couchbase.factory.HttpClientInputsBuilder; -import io.cloudslang.content.httpclient.CSHttpClient; -import io.cloudslang.content.httpclient.HttpClientInputs; +import io.cloudslang.content.httpclient.entities.HttpClientInputs; +import io.cloudslang.content.httpclient.services.HttpClientService; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -60,21 +60,21 @@ */ @RunWith(PowerMockRunner.class) -@PrepareForTest({CSHttpClient.class, CouchbaseService.class}) +@PrepareForTest({HttpClientService.class, CouchbaseService.class}) public class CouchbaseServiceTest { @Rule public final ExpectedException exception = ExpectedException.none(); @Mock - private CSHttpClient csHttpClientMock; + private HttpClientService httpClientServiceMock; private CouchbaseService toTest; private HttpClientInputs httpClientInputs; @Before public void init() throws Exception { - whenNew(CSHttpClient.class).withNoArguments().thenReturn(csHttpClientMock); - when(csHttpClientMock.execute(any(HttpClientInputs.class))).thenReturn(new HashMap<>()); + whenNew(HttpClientService.class).withNoArguments().thenReturn(httpClientServiceMock); + when(httpClientServiceMock.execute(any(HttpClientInputs.class))).thenReturn(new HashMap<>()); toTest = new CouchbaseService(); } @@ -101,8 +101,8 @@ public void testCreateOrEditBucket() { CommonInputs commonInputs = getCommonInputs("CreateOrEditBucket", "buckets", "http://subdomain.couchbase.com:8091"); toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://subdomain.couchbase.com:8091/pools/default/buckets", httpClientInputs.getUrl()); assertEquals("Accept:application/json, text/plain, */*", httpClientInputs.getHeaders()); @@ -146,7 +146,7 @@ public void testCreateOrEditBucketWithoutSaslPassword() { CommonInputs commonInputs = getCommonInputs("CreateOrEditBucket", "buckets", "http://subdomain.couchbase.com:8091"); toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, never()).execute(eq(httpClientInputs)); + verify(httpClientServiceMock, never()).execute(eq(httpClientInputs)); } @Test @@ -158,8 +158,8 @@ public void testDeleteBucket() { BucketInputs bucketInputs = new BucketInputs.Builder().withBucketName("toBeDeletedBucket").build(); toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://anywhere.couchbase.com:8091/pools/default/buckets/toBeDeletedBucket", httpClientInputs.getUrl()); assertEquals("application/json", httpClientInputs.getContentType()); @@ -174,8 +174,8 @@ public void testFlushBucket() { BucketInputs bucketInputs = new BucketInputs.Builder().withBucketName("toBeFlushedBucket").build(); toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://anywhere.couchbase.com:8091/pools/default/buckets/toBeFlushedBucket/controller/doFlush", httpClientInputs.getUrl()); assertEquals("application/json", httpClientInputs.getContentType()); @@ -189,8 +189,8 @@ public void testGetAllBuckets() { CommonInputs commonInputs = getCommonInputs("GetAllBuckets", "buckets", "http://somewhere.couchbase.com:8091"); toTest.execute(httpClientInputs, commonInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://somewhere.couchbase.com:8091/pools/default/buckets", httpClientInputs.getUrl()); assertEquals("X-memcachekv-Store-Client-Specification-Version:0.1", httpClientInputs.getHeaders()); @@ -205,8 +205,8 @@ public void testGetAutoFailOverSettings() { CommonInputs commonInputs = getCommonInputs("GetAutoFailOverSettings", "cluster", "http://somewhere.couchbase.com:8091"); toTest.execute(httpClientInputs, commonInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://somewhere.couchbase.com:8091/settings/autoFailover", httpClientInputs.getUrl()); assertEquals("application/json", httpClientInputs.getContentType()); @@ -221,8 +221,8 @@ public void testGetBucket() { BucketInputs bucketInputs = new BucketInputs.Builder().withBucketName("specifiedBucket").build(); toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://somewhere.couchbase.com:8091/pools/default/buckets/specifiedBucket", httpClientInputs.getUrl()); assertEquals("X-memcachekv-Store-Client-Specification-Version:0.1", httpClientInputs.getHeaders()); @@ -238,8 +238,8 @@ public void testGetBucketStatistics() { BucketInputs bucketInputs = new BucketInputs.Builder().withBucketName("testBucket").build(); toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://somewhere.couchbase.com:8091/pools/default/buckets/testBucket/stats", httpClientInputs.getUrl()); assertEquals("X-memcachekv-Store-Client-Specification-Version:0.1", httpClientInputs.getHeaders()); @@ -254,8 +254,8 @@ public void testGetClusterDetails() { CommonInputs commonInputs = getCommonInputs("GetClusterDetails", "cluster", "http://whatever.couchbase.com:8091"); toTest.execute(httpClientInputs, commonInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://whatever.couchbase.com:8091/pools/default", httpClientInputs.getUrl()); assertEquals("X-memcachekv-Store-Client-Specification-Version:0.1", httpClientInputs.getHeaders()); @@ -270,8 +270,8 @@ public void testGetClusterInfo() { CommonInputs commonInputs = getCommonInputs("GetClusterInfo", "cluster", "http://whatever.couchbase.com:8091"); toTest.execute(httpClientInputs, commonInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://whatever.couchbase.com:8091/pools", httpClientInputs.getUrl()); assertEquals("X-memcachekv-Store-Client-Specification-Version:0.1", httpClientInputs.getHeaders()); @@ -287,8 +287,8 @@ public void testGetDesignDocsInfo() { BucketInputs bucketInputs = new BucketInputs.Builder().withBucketName("toGetDesignDocsBucket").build(); toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://whatever.couchbase.com:8091/pools/default/buckets/toGetDesignDocsBucket/ddocs", httpClientInputs.getUrl()); assertEquals("application/json", httpClientInputs.getContentType()); @@ -303,8 +303,8 @@ public void testFailOverNodeSuccess() { NodeInputs nodeInputs = new NodeInputs.Builder().withInternalNodeIpAddress("ns_2@10.0.0.2").build(); toTest.execute(httpClientInputs, commonInputs, nodeInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://whatever.couchbase.com:8091/controller/failOver", httpClientInputs.getUrl()); assertEquals("Accept:application/json, text/plain, */*", httpClientInputs.getHeaders()); @@ -320,8 +320,8 @@ public void testGracefulFailOverNodeSuccess() { NodeInputs nodeInputs = new NodeInputs.Builder().withInternalNodeIpAddress("ns_2@10.0.0.2").build(); toTest.execute(httpClientInputs, commonInputs, nodeInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://whatever.couchbase.com:8091/controller/startGracefulFailover", httpClientInputs.getUrl()); assertEquals("Accept:application/json, text/plain, */*", httpClientInputs.getHeaders()); @@ -341,8 +341,8 @@ public void testRebalancingNodes() { .build(); toTest.execute(httpClientInputs, commonInputs, clusterInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://whatever.couchbase.com:8091/controller/rebalance", httpClientInputs.getUrl()); assertEquals("Accept:application/json, text/plain, */*", httpClientInputs.getHeaders()); @@ -365,8 +365,8 @@ public void testSetRecoveryTypes() { NodeInputs nodeInputs = new NodeInputs.Builder().withInternalNodeIpAddress("ns_2@10.0.0.2").withRecoveryType("full").build(); toTest.execute(httpClientInputs, commonInputs, nodeInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://whatever.couchbase.com:8091/controller/setRecoveryType", httpClientInputs.getUrl()); assertEquals("Accept:application/json, text/plain, */*", httpClientInputs.getHeaders()); @@ -384,7 +384,7 @@ public void testFailOverNodeNoIPv4Address() { NodeInputs nodeInputs = new NodeInputs.Builder().withInternalNodeIpAddress("ns_2@ blah blah blah ").build(); toTest.execute(httpClientInputs, commonInputs, nodeInputs); - verify(csHttpClientMock, never()).execute(eq(httpClientInputs)); + verify(httpClientServiceMock, never()).execute(eq(httpClientInputs)); } @Test @@ -396,7 +396,7 @@ public void testFailOverNodeInvalidInternalNodeIpAddress() { NodeInputs nodeInputs = new NodeInputs.Builder().withInternalNodeIpAddress(" anything here but not [at] symbol ").build(); toTest.execute(httpClientInputs, commonInputs, nodeInputs); - verify(csHttpClientMock, never()).execute(eq(httpClientInputs)); + verify(httpClientServiceMock, never()).execute(eq(httpClientInputs)); } @Test @@ -411,7 +411,7 @@ public void testUnknownApi() { toTest.execute(httpClientInputs, commonInputs, bucketInputs); - verify(csHttpClientMock, never()).execute(eq(httpClientInputs)); + verify(httpClientServiceMock, never()).execute(eq(httpClientInputs)); } @Test @@ -426,7 +426,7 @@ public void testUnknownBuilderType() { toTest.execute(httpClientInputs, commonInputs, bucketInputs, null); - verify(csHttpClientMock, never()).execute(eq(httpClientInputs)); + verify(httpClientServiceMock, never()).execute(eq(httpClientInputs)); } @Test @@ -436,8 +436,8 @@ public void testGetDestinationClusterReference() { CommonInputs commonInputs = getCommonInputs("GetDestinationClusterReference", "cluster", "http://somewhere.couchbase.com:8091"); toTest.execute(httpClientInputs, commonInputs); - verify(csHttpClientMock, times(1)).execute(eq(httpClientInputs)); - verifyNoMoreInteractions(csHttpClientMock); + verify(httpClientServiceMock, times(1)).execute(eq(httpClientInputs)); + verifyNoMoreInteractions(httpClientServiceMock); assertEquals("http://somewhere.couchbase.com:8091/pools/default/remoteClusters", httpClientInputs.getUrl()); assertEquals("X-memcachekv-Store-Client-Specification-Version:0.1", httpClientInputs.getHeaders());