diff --git a/CHANGELOG.md b/CHANGELOG.md index bd4c5cf57..d822d34d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added - ASR (Automatic Speech Recognition) +### Changed +- Refactored Application v2 requests to remove duplicated code +- Deprecated Product.MESSAGE from RedactRequest. Use Product.MESSAGES instead +- Deprecated InsightClient#getStandardNumberInsight(number, country, cnam). Use InsightClient#getStandardNumberInsight(StandardInsightRequest) instead +- Deprecated InsightClient.getAdvancedNumberInsight(number, country, ipAddress, cnam). Use InsightClient#getAdvancedNumberInsight(AdvancedInsightRequest) instead +- Deprecated InsightClient.getAdvancedNumberInsight(number, country, ipAddress). Use InsightClient#getAdvancedNumberInsight(AdvancedInsightRequest) instead +- Deprecated public constructors and setters in VerifyRequest use VerifyRequest.Builder instead +- Deprecated MD5Util use HashUtil instead +- Removed setters from BaseRequest. Set fields in the builders of Psd2Request or VerifyRequest instead. + ## [5.6.0] ### Added - NotifyEvent structure for Notify Actions - SHA256 hashing option ### Changed -- Create application request use basic auth for authentication +- Changed application requests to use basic auth in header for authentication ### Fixed - Fixed error throw when trying to log No Content responses diff --git a/src/main/java/com/vonage/client/HttpWrapper.java b/src/main/java/com/vonage/client/HttpWrapper.java index a487ef9c5..e2d2a0d7a 100644 --- a/src/main/java/com/vonage/client/HttpWrapper.java +++ b/src/main/java/com/vonage/client/HttpWrapper.java @@ -61,10 +61,10 @@ public HttpWrapper(HttpConfig httpConfig, AuthMethod... authMethods) { } public HttpClient getHttpClient() { - if (this.httpClient == null) { - this.httpClient = createHttpClient(); + if (httpClient == null) { + httpClient = createHttpClient(); } - return this.httpClient; + return httpClient; } public void setHttpClient(HttpClient httpClient) { diff --git a/src/main/java/com/vonage/client/VonageClient.java b/src/main/java/com/vonage/client/VonageClient.java index fc9ba97f7..ad14a4193 100644 --- a/src/main/java/com/vonage/client/VonageClient.java +++ b/src/main/java/com/vonage/client/VonageClient.java @@ -291,7 +291,7 @@ public Builder privateKeyPath(String privateKeyPath) throws VonageUnableToReadPr * generating an {@link JWTAuthMethod} with the provided credentials. */ public VonageClient build() { - this.authCollection = generateAuthCollection(applicationId, + authCollection = generateAuthCollection(applicationId, apiKey, apiSecret, signatureSecret, diff --git a/src/main/java/com/vonage/client/account/BalanceEndpoint.java b/src/main/java/com/vonage/client/account/BalanceEndpoint.java index 1de61a029..8d42231fd 100644 --- a/src/main/java/com/vonage/client/account/BalanceEndpoint.java +++ b/src/main/java/com/vonage/client/account/BalanceEndpoint.java @@ -46,7 +46,7 @@ public RequestBuilder makeRequest(Void request) throws UnsupportedEncodingExcept } public BalanceResponse execute() { - return this.execute(null); + return execute(null); } @Override diff --git a/src/main/java/com/vonage/client/account/PricingMethod.java b/src/main/java/com/vonage/client/account/PricingMethod.java index 286560533..dab9e7a4e 100644 --- a/src/main/java/com/vonage/client/account/PricingMethod.java +++ b/src/main/java/com/vonage/client/account/PricingMethod.java @@ -38,7 +38,7 @@ protected Class[] getAcceptableAuthMethods() { @Override public RequestBuilder makeRequest(PricingRequest pricingRequest) { - return RequestBuilder.get(this.getUri()).addParameter("country", pricingRequest.getCountryCode()); + return RequestBuilder.get(getUri()).addParameter("country", pricingRequest.getCountryCode()); } @Override diff --git a/src/main/java/com/vonage/client/application/ApplicationMethod.java b/src/main/java/com/vonage/client/application/ApplicationMethod.java new file mode 100644 index 000000000..a3def896b --- /dev/null +++ b/src/main/java/com/vonage/client/application/ApplicationMethod.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 Vonage + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.vonage.client.application; + +import com.vonage.client.AbstractMethod; +import com.vonage.client.HttpWrapper; +import com.vonage.client.VonageClientException; +import org.apache.http.client.methods.RequestBuilder; + +public abstract class ApplicationMethod extends AbstractMethod { + + public ApplicationMethod(HttpWrapper httpWrapper) { + super(httpWrapper); + } + + @Override + protected RequestBuilder applyAuth(RequestBuilder request) throws VonageClientException { + return getAuthMethod(getAcceptableAuthMethods()).applyAsBasicAuth(request); + } +} diff --git a/src/main/java/com/vonage/client/application/CreateApplicationMethod.java b/src/main/java/com/vonage/client/application/CreateApplicationMethod.java index 6b9da35dd..28a8a375d 100644 --- a/src/main/java/com/vonage/client/application/CreateApplicationMethod.java +++ b/src/main/java/com/vonage/client/application/CreateApplicationMethod.java @@ -15,7 +15,6 @@ */ package com.vonage.client.application; -import com.vonage.client.AbstractMethod; import com.vonage.client.HttpWrapper; import com.vonage.client.VonageBadRequestException; import com.vonage.client.VonageClientException; @@ -29,7 +28,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; -class CreateApplicationMethod extends AbstractMethod { +class CreateApplicationMethod extends ApplicationMethod { private static final Class[] ALLOWED_AUTH_METHODS = new Class[]{TokenAuthMethod.class}; private static final String PATH = "/applications"; @@ -59,9 +58,4 @@ public Application parseResponse(HttpResponse response) throws IOException, Vona return Application.fromJson(new BasicResponseHandler().handleResponse(response)); } - - @Override - protected RequestBuilder applyAuth(RequestBuilder request) throws VonageClientException { - return getAuthMethod(getAcceptableAuthMethods()).applyAsBasicAuth(request); - } } diff --git a/src/main/java/com/vonage/client/application/DeleteApplicationMethod.java b/src/main/java/com/vonage/client/application/DeleteApplicationMethod.java index edf944dc5..1c5a3a6dd 100644 --- a/src/main/java/com/vonage/client/application/DeleteApplicationMethod.java +++ b/src/main/java/com/vonage/client/application/DeleteApplicationMethod.java @@ -15,7 +15,6 @@ */ package com.vonage.client.application; -import com.vonage.client.AbstractMethod; import com.vonage.client.HttpWrapper; import com.vonage.client.VonageBadRequestException; import com.vonage.client.VonageClientException; @@ -27,7 +26,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; -class DeleteApplicationMethod extends AbstractMethod { +class DeleteApplicationMethod extends ApplicationMethod { private static final Class[] ALLOWED_AUTH_METHODS = new Class[]{TokenAuthMethod.class}; private static final String PATH = "/applications/%s"; @@ -56,9 +55,4 @@ public Void parseResponse(HttpResponse response) throws IOException, VonageClien return null; } - - @Override - protected RequestBuilder applyAuth(RequestBuilder request) throws VonageClientException { - return getAuthMethod(getAcceptableAuthMethods()).applyAsBasicAuth(request); - } } diff --git a/src/main/java/com/vonage/client/application/GetApplicationMethod.java b/src/main/java/com/vonage/client/application/GetApplicationMethod.java index c2ae14078..03beb125a 100644 --- a/src/main/java/com/vonage/client/application/GetApplicationMethod.java +++ b/src/main/java/com/vonage/client/application/GetApplicationMethod.java @@ -15,7 +15,6 @@ */ package com.vonage.client.application; -import com.vonage.client.AbstractMethod; import com.vonage.client.HttpWrapper; import com.vonage.client.VonageBadRequestException; import com.vonage.client.VonageClientException; @@ -28,7 +27,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; -class GetApplicationMethod extends AbstractMethod { +class GetApplicationMethod extends ApplicationMethod { private static final Class[] ALLOWED_AUTH_METHODS = new Class[]{TokenAuthMethod.class}; private static final String PATH = "/applications/%s"; @@ -57,9 +56,4 @@ public Application parseResponse(HttpResponse response) throws IOException, Vona return Application.fromJson(new BasicResponseHandler().handleResponse(response)); } - - @Override - protected RequestBuilder applyAuth(RequestBuilder request) throws VonageClientException { - return getAuthMethod(getAcceptableAuthMethods()).applyAsBasicAuth(request); - } } diff --git a/src/main/java/com/vonage/client/application/ListApplicationsMethod.java b/src/main/java/com/vonage/client/application/ListApplicationsMethod.java index b730ce6c9..dff5dc749 100644 --- a/src/main/java/com/vonage/client/application/ListApplicationsMethod.java +++ b/src/main/java/com/vonage/client/application/ListApplicationsMethod.java @@ -15,7 +15,6 @@ */ package com.vonage.client.application; -import com.vonage.client.AbstractMethod; import com.vonage.client.HttpWrapper; import com.vonage.client.VonageBadRequestException; import com.vonage.client.VonageClientException; @@ -28,7 +27,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; -class ListApplicationsMethod extends AbstractMethod { +class ListApplicationsMethod extends ApplicationMethod { private static final Class[] ALLOWED_AUTH_METHODS = new Class[]{TokenAuthMethod.class}; private static final String PATH = "/applications"; @@ -69,9 +68,4 @@ public ApplicationList parseResponse(HttpResponse response) throws IOException, return ApplicationList.fromJson(new BasicResponseHandler().handleResponse(response)); } - - @Override - protected RequestBuilder applyAuth(RequestBuilder request) throws VonageClientException { - return getAuthMethod(getAcceptableAuthMethods()).applyAsBasicAuth(request); - } } diff --git a/src/main/java/com/vonage/client/application/UpdateApplicationMethod.java b/src/main/java/com/vonage/client/application/UpdateApplicationMethod.java index a6a1da078..c7e7e8aab 100644 --- a/src/main/java/com/vonage/client/application/UpdateApplicationMethod.java +++ b/src/main/java/com/vonage/client/application/UpdateApplicationMethod.java @@ -15,7 +15,6 @@ */ package com.vonage.client.application; -import com.vonage.client.AbstractMethod; import com.vonage.client.HttpWrapper; import com.vonage.client.VonageBadRequestException; import com.vonage.client.VonageClientException; @@ -29,7 +28,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; -class UpdateApplicationMethod extends AbstractMethod { +class UpdateApplicationMethod extends ApplicationMethod { private static final Class[] ALLOWED_AUTH_METHODS = new Class[]{TokenAuthMethod.class}; private static final String PATH = "/applications/%s"; @@ -59,9 +58,4 @@ public Application parseResponse(HttpResponse response) throws IOException, Vona return Application.fromJson(new BasicResponseHandler().handleResponse(response)); } - - @Override - protected RequestBuilder applyAuth(RequestBuilder request) throws VonageClientException { - return getAuthMethod(getAcceptableAuthMethods()).applyAsBasicAuth(request); - } } diff --git a/src/main/java/com/vonage/client/auth/AuthCollection.java b/src/main/java/com/vonage/client/auth/AuthCollection.java index 5939623a7..dbee0a4eb 100644 --- a/src/main/java/com/vonage/client/auth/AuthCollection.java +++ b/src/main/java/com/vonage/client/auth/AuthCollection.java @@ -63,6 +63,7 @@ public void add(AuthMethod auth) { * * @throws VonageUnacceptableAuthException if no matching AuthMethod is found. */ + @SuppressWarnings("unchecked") public T getAuth(Class type) throws VonageUnacceptableAuthException { for (AuthMethod availableAuthMethod : authList) { if (type.isInstance(availableAuthMethod)) { diff --git a/src/main/java/com/vonage/client/auth/MD5Util.java b/src/main/java/com/vonage/client/auth/MD5Util.java deleted file mode 100644 index 97c559a28..000000000 --- a/src/main/java/com/vonage/client/auth/MD5Util.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2020 Vonage - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.vonage.client.auth; - - -import com.vonage.client.auth.hashutils.HashUtil; - -import java.io.UnsupportedEncodingException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -/** - * Contains utility methods that use MD5 hashing. The class uses STANDARD JVM MD5 algorithm. - * - * @deprecated {@linkplain HashUtil} should be used instead. - */ -public class MD5Util { - - /** - * Calculates MD5 hash for string. assume string is UTF-8 encoded - * @param input string which is going to be encoded into MD5 format - * @return MD5 representation of the input string - * @throws NoSuchAlgorithmException if the MD5 algorithm is not available. - */ - public static String calculateMd5(String input) throws NoSuchAlgorithmException { - try { - return HashUtil.calculate(input, HashUtil.HashType.MD5); - } catch (InvalidKeyException e) { - return null; // Will not actually occur here - } - } - - /** - * Calculates MD5 hash for string. - * @param input string which is going to be encoded into MD5 format - * @param encoding character encoding of the string which is going to be encoded into MD5 format - * @return MD5 representation of the input string - * @throws NoSuchAlgorithmException if the MD5 algorithm is not available. - * @throws UnsupportedEncodingException if the specified encoding is unavailable. - */ - public static String calculateMd5(String input, String encoding) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { - return HashUtil.calculate(input, encoding, HashUtil.HashType.MD5); - } - -} \ No newline at end of file diff --git a/src/main/java/com/vonage/client/auth/RequestSigning.java b/src/main/java/com/vonage/client/auth/RequestSigning.java index 037cd8e46..ec7cd4474 100644 --- a/src/main/java/com/vonage/client/auth/RequestSigning.java +++ b/src/main/java/com/vonage/client/auth/RequestSigning.java @@ -160,6 +160,7 @@ public static boolean verifyRequestSignature(HttpServletRequest request, String * * @param request The HttpServletRequest to be verified. * @param secretKey The pre-shared secret key used by the sender of the request to create the signature. + * @param hashType Hash type to be used to construct request parameters. * * @return true if the signature is correct for this request and secret key. */ diff --git a/src/main/java/com/vonage/client/auth/SignatureAuthMethod.java b/src/main/java/com/vonage/client/auth/SignatureAuthMethod.java index 5ed843fe3..e1be78cb5 100644 --- a/src/main/java/com/vonage/client/auth/SignatureAuthMethod.java +++ b/src/main/java/com/vonage/client/auth/SignatureAuthMethod.java @@ -31,7 +31,7 @@ public class SignatureAuthMethod extends AbstractAuthMethod { public SignatureAuthMethod(String apiKey, String secret) { this.apiKey = apiKey; this.secret = secret; - this.hashType = HashUtil.HashType.MD5; + hashType = HashUtil.HashType.MD5; } public SignatureAuthMethod(String apiKey, String secret, HashUtil.HashType hashType) { diff --git a/src/main/java/com/vonage/client/auth/hashutils/AbstractHasher.java b/src/main/java/com/vonage/client/auth/hashutils/AbstractHasher.java index 648d4a225..7bd298e59 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/AbstractHasher.java +++ b/src/main/java/com/vonage/client/auth/hashutils/AbstractHasher.java @@ -31,9 +31,10 @@ public String calculate(String input) throws NoSuchAlgorithmException, InvalidKe * @return hashed representation of the input string * @throws NoSuchAlgorithmException if the algorithm is not available. * @throws UnsupportedEncodingException if the encoding type is invalid + * @throws InvalidKeyException Only applicable to HMAC encoding types, when a bad key is provided. */ public String calculate(String input, String secretKey, String encoding) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { - return this.calculate(input + secretKey, encoding); + return calculate(input + secretKey, encoding); } /** @@ -44,6 +45,7 @@ public String calculate(String input, String secretKey, String encoding) throws * @return hashed representation of the input string * @throws NoSuchAlgorithmException if the algorithm is not available. * @throws UnsupportedEncodingException if the encoding type is invalid + * @throws InvalidKeyException Only applicable to HMAC encoding types, when a bad key is provided. */ public abstract String calculate(String input, String encoding) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException; diff --git a/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java b/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java index a5b768b47..8756d3c04 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java +++ b/src/main/java/com/vonage/client/auth/hashutils/HashUtil.java @@ -39,6 +39,7 @@ public static String calculate(String input, HashType hashType) throws NoSuchAlg * @return representation of the input string with given hash type * @throws NoSuchAlgorithmException if the algorithm is not available. * @throws InvalidKeyException Only applicable to HMAC encoding types, when a bad key is provided. + * @throws UnsupportedEncodingException if the specified encoding is unavailable. */ public static String calculate(String input, String encoding, HashType hashType) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { return hashTypes.get(hashType).calculate(input, encoding); diff --git a/src/main/java/com/vonage/client/auth/hashutils/HmacMd5Hasher.java b/src/main/java/com/vonage/client/auth/hashutils/HmacMd5Hasher.java index c74d7d6d5..0bbd8578f 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/HmacMd5Hasher.java +++ b/src/main/java/com/vonage/client/auth/hashutils/HmacMd5Hasher.java @@ -28,7 +28,7 @@ public class HmacMd5Hasher extends AbstractHasher { byte[] digest = sha1HMAC.doFinal(input.getBytes(encoding)); - return this.buildHexString(digest); + return buildHexString(digest); } /** @@ -43,6 +43,6 @@ public class HmacMd5Hasher extends AbstractHasher { * @throws InvalidKeyException if key is invalid */ @Override public String calculate(String input, String encoding) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { - return this.calculate(input, input, encoding); + return calculate(input, input, encoding); } } diff --git a/src/main/java/com/vonage/client/auth/hashutils/HmacSha1Hasher.java b/src/main/java/com/vonage/client/auth/hashutils/HmacSha1Hasher.java index 3b88bedf8..d2e27740b 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/HmacSha1Hasher.java +++ b/src/main/java/com/vonage/client/auth/hashutils/HmacSha1Hasher.java @@ -28,7 +28,7 @@ public class HmacSha1Hasher extends AbstractHasher { byte[] digest = sha1HMAC.doFinal(input.getBytes(encoding)); - return this.buildHexString(digest); + return buildHexString(digest); } /** @@ -43,6 +43,6 @@ public class HmacSha1Hasher extends AbstractHasher { * @throws InvalidKeyException if key is invalid */ @Override public String calculate(String input, String encoding) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { - return this.calculate(input, input, encoding); + return calculate(input, input, encoding); } } diff --git a/src/main/java/com/vonage/client/auth/hashutils/HmacSha256Hasher.java b/src/main/java/com/vonage/client/auth/hashutils/HmacSha256Hasher.java index 16697dbf1..cb00b6b13 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/HmacSha256Hasher.java +++ b/src/main/java/com/vonage/client/auth/hashutils/HmacSha256Hasher.java @@ -28,7 +28,7 @@ public class HmacSha256Hasher extends AbstractHasher { byte[] digest = sha256HMAC.doFinal(input.getBytes(encoding)); - return this.buildHexString(digest); + return buildHexString(digest); } /** @@ -43,6 +43,6 @@ public class HmacSha256Hasher extends AbstractHasher { * @throws InvalidKeyException if key is invalid */ @Override public String calculate(String input, String encoding) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { - return this.calculate(input, input, encoding); + return calculate(input, input, encoding); } } diff --git a/src/main/java/com/vonage/client/auth/hashutils/HmacSha512Hasher.java b/src/main/java/com/vonage/client/auth/hashutils/HmacSha512Hasher.java index 7efed9a90..92311fa03 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/HmacSha512Hasher.java +++ b/src/main/java/com/vonage/client/auth/hashutils/HmacSha512Hasher.java @@ -28,7 +28,7 @@ public class HmacSha512Hasher extends AbstractHasher { byte[] digest = sha512HMAC.doFinal(input.getBytes(encoding)); - return this.buildHexString(digest); + return buildHexString(digest); } /** @@ -43,6 +43,6 @@ public class HmacSha512Hasher extends AbstractHasher { * @throws InvalidKeyException if key is invalid */ @Override public String calculate(String input, String encoding) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { - return this.calculate(input, input, encoding); + return calculate(input, input, encoding); } } diff --git a/src/main/java/com/vonage/client/auth/hashutils/Md5Hasher.java b/src/main/java/com/vonage/client/auth/hashutils/Md5Hasher.java index 8a8eb3557..209295651 100644 --- a/src/main/java/com/vonage/client/auth/hashutils/Md5Hasher.java +++ b/src/main/java/com/vonage/client/auth/hashutils/Md5Hasher.java @@ -38,7 +38,7 @@ class Md5Hasher extends AbstractHasher { md.update(input.getBytes(encoding)); byte digest[] = md.digest(); - return this.buildHexString(digest); + return buildHexString(digest); } } diff --git a/src/main/java/com/vonage/client/incoming/DtmfResult.java b/src/main/java/com/vonage/client/incoming/DtmfResult.java index 884a63b84..418110f9a 100644 --- a/src/main/java/com/vonage/client/incoming/DtmfResult.java +++ b/src/main/java/com/vonage/client/incoming/DtmfResult.java @@ -25,12 +25,16 @@ public class DtmfResult { /** * - * @return + * @return The buttons pressed by the user */ public String getDigits() { return digits; } + /** + * + * @return Whether the DTMF input timed out: true if it did, false if not + */ @JsonProperty("timed_out") public boolean isTimedOut() { return timedOut; diff --git a/src/main/java/com/vonage/client/insight/BasicInsightRequest.java b/src/main/java/com/vonage/client/insight/BasicInsightRequest.java index d220f7909..7d009645b 100644 --- a/src/main/java/com/vonage/client/insight/BasicInsightRequest.java +++ b/src/main/java/com/vonage/client/insight/BasicInsightRequest.java @@ -17,8 +17,8 @@ public class BasicInsightRequest extends BaseInsightRequest { private BasicInsightRequest(Builder builder) { - this.number = builder.number; - this.country = builder.country; + number = builder.number; + country = builder.country; } /** diff --git a/src/main/java/com/vonage/client/insight/InsightClient.java b/src/main/java/com/vonage/client/insight/InsightClient.java index 2ffb8e86b..01b92c774 100644 --- a/src/main/java/com/vonage/client/insight/InsightClient.java +++ b/src/main/java/com/vonage/client/insight/InsightClient.java @@ -112,26 +112,6 @@ public StandardInsightResponse getStandardNumberInsight(String number, String co return getStandardNumberInsight(StandardInsightRequest.withNumberAndCountry(number, country)); } - /** - * Perform a Standard Insight Request with a number, country, and cnam. - * - * @param number A single phone number that you need insight about in national or international format. - * @param country If a number does not have a country code or it is uncertain, set the two-character country code. - * @param cnam Indicates if the name of the person who owns the phone number should also be looked up and - * returned. Set to true to receive phone number owner name in the response. This is only available - * for US numbers and incurs an additional charge. - * - * @return A {@link StandardInsightResponse} representing the response from the Vonage Number Insight API. - * - * @throws VonageResponseParseException if the response from the API could not be parsed. - * @throws VonageClientException if there was a problem with the Vonage request or response objects. - * @deprecated Create a {@link StandardInsightRequest} and use {@link InsightClient#getStandardNumberInsight(StandardInsightRequest)} - */ - @Deprecated - public StandardInsightResponse getStandardNumberInsight(String number, String country, boolean cnam) throws VonageResponseParseException, VonageClientException { - return getStandardNumberInsight(StandardInsightRequest.builder(number).country(country).cnam(cnam).build()); - } - /** * Perform a Standard Insight Request with a {@link StandardInsightRequest}. * @@ -175,56 +155,6 @@ public AdvancedInsightResponse getAdvancedNumberInsight(String number, String co return getAdvancedNumberInsight(AdvancedInsightRequest.withNumberAndCountry(number, country)); } - /** - * Perform an Advanced Insight Request with a number, country, and ipAddress. - * - * @param number A single phone number that you need insight about in national or international format. - * @param country If a number does not have a country code or it is uncertain, set the two-character country - * code. - * @param ipAddress The IP address of the user. If supplied, we will compare this to the country the user's phone is - * located in and return an error if it does not match. - * - * @return A {@link AdvancedInsightResponse} representing the response from the Vonage Number Insight API. - * - * @throws VonageResponseParseException if the response from the API could not be parsed. - * @throws VonageClientException if there was a problem with the Vonage request or response objects. - * @deprecated Create a {@link AdvancedInsightRequest} and use {@link InsightClient#getAdvancedNumberInsight(AdvancedInsightRequest)} - */ - @Deprecated - public AdvancedInsightResponse getAdvancedNumberInsight(String number, String country, String ipAddress) throws VonageResponseParseException, VonageClientException { - return getAdvancedNumberInsight(AdvancedInsightRequest.builder(number) - .country(country) - .ipAddress(ipAddress) - .build()); - } - - /** - * Perform an Advanced Insight Request with a number, country, ipAddress, and cnam. - * - * @param number A single phone number that you need insight about in national or international format. - * @param country If a number does not have a country code or it is uncertain, set the two-character country - * code. - * @param ipAddress The IP address of the user. If supplied, we will compare this to the country the user's phone is - * located in and return an error if it does not match. - * @param cnam Indicates if the name of the person who owns the phone number should also be looked up and - * returned. Set to true to receive phone number owner name in the response. This is only available - * for US numbers and incurs an additional charge. - * - * @return A {@link AdvancedInsightResponse} representing the response from the Vonage Number Insight API. - * - * @throws VonageResponseParseException if the response from the API could not be parsed. - * @throws VonageClientException if there was a problem with the Vonage request or response objects. - * @deprecated Create a {@link AdvancedInsightRequest} and use {@link InsightClient#getAdvancedNumberInsight(AdvancedInsightRequest)} - */ - @Deprecated - public AdvancedInsightResponse getAdvancedNumberInsight(String number, String country, String ipAddress, boolean cnam) throws VonageResponseParseException, VonageClientException { - return getAdvancedNumberInsight(AdvancedInsightRequest.builder(number) - .country(country) - .ipAddress(ipAddress) - .cnam(cnam) - .build()); - } - /** * Perform an Advanced Insight Request with a {@link AdvancedInsightRequest}. * diff --git a/src/main/java/com/vonage/client/numbers/ListNumbersEndpoint.java b/src/main/java/com/vonage/client/numbers/ListNumbersEndpoint.java index f2d5e9119..b2defa9ab 100644 --- a/src/main/java/com/vonage/client/numbers/ListNumbersEndpoint.java +++ b/src/main/java/com/vonage/client/numbers/ListNumbersEndpoint.java @@ -56,6 +56,6 @@ public ListNumbersResponse parseResponse(HttpResponse response) throws IOExcepti } ListNumbersResponse listNumbers(ListNumbersFilter request) throws VonageClientException { - return this.execute(request); + return execute(request); } } diff --git a/src/main/java/com/vonage/client/numbers/NumbersClient.java b/src/main/java/com/vonage/client/numbers/NumbersClient.java index a939b9209..57bda7ae7 100644 --- a/src/main/java/com/vonage/client/numbers/NumbersClient.java +++ b/src/main/java/com/vonage/client/numbers/NumbersClient.java @@ -68,6 +68,8 @@ public ListNumbersResponse listNumbers(ListNumbersFilter filter) throws VonageRe /** * Search for available Vonage Virtual Numbers. * + * @param country country to search available numbers from + * @return available Vonage Virtual Numbers * @throws VonageResponseParseException if the response from the API could not be parsed. * @throws VonageClientException if an error is returned by the server. */ @@ -78,6 +80,8 @@ public SearchNumbersResponse searchNumbers(String country) throws VonageResponse /** * Search for available Vonage Virtual Numbers. * + * @param filter search for available Vonage Virtual Number with filters + * @return available Vonage Virtual Numbers * @throws VonageResponseParseException if the response from the API could not be parsed. * @throws VonageClientException if an error is returned by the server. */ diff --git a/src/main/java/com/vonage/client/numbers/SearchNumbersFilter.java b/src/main/java/com/vonage/client/numbers/SearchNumbersFilter.java index 0ef10453f..bc011c1a3 100644 --- a/src/main/java/com/vonage/client/numbers/SearchNumbersFilter.java +++ b/src/main/java/com/vonage/client/numbers/SearchNumbersFilter.java @@ -95,7 +95,8 @@ public SearchPattern getSearchPattern() { } /** - * @param searchPattern + * @param searchPattern The pattern you want to search for. Use the * wildcard to match the start or end of the number. + * For example, *123* matches all numbers that contain the pattern 123. */ public void setSearchPattern(SearchPattern searchPattern) { this.searchPattern = searchPattern; diff --git a/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java b/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java index 1fb78214a..e107a6c0f 100644 --- a/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java +++ b/src/main/java/com/vonage/client/numbers/SearchNumbersResponse.java @@ -30,7 +30,7 @@ public class SearchNumbersResponse { private AvailableNumber[] numbers = new AvailableNumber[]{}; /** - * Get the number of responses returned by the Vonage API. + * @return the number of responses returned by the Vonage API. */ public int getCount() { return count; @@ -38,6 +38,7 @@ public int getCount() { /** * Obtain an array of matching numbers than are available to buy. + * @return list of available numbers */ public AvailableNumber[] getNumbers() { return numbers; diff --git a/src/main/java/com/vonage/client/numbers/SearchPattern.java b/src/main/java/com/vonage/client/numbers/SearchPattern.java index 8fdb0d35c..5873d46dc 100644 --- a/src/main/java/com/vonage/client/numbers/SearchPattern.java +++ b/src/main/java/com/vonage/client/numbers/SearchPattern.java @@ -30,6 +30,6 @@ public enum SearchPattern { } public int getValue() { - return this.value; + return value; } } diff --git a/src/main/java/com/vonage/client/numbers/UpdateNumberRequest.java b/src/main/java/com/vonage/client/numbers/UpdateNumberRequest.java index cc38b7bcb..dff8d601c 100644 --- a/src/main/java/com/vonage/client/numbers/UpdateNumberRequest.java +++ b/src/main/java/com/vonage/client/numbers/UpdateNumberRequest.java @@ -89,7 +89,7 @@ public void setMessagesCallbackValue(String messagesCallbackValue) { } public void addParams(RequestBuilder request) { - request.addParameter("country", this.country).addParameter("msisdn", msisdn); + request.addParameter("country", country).addParameter("msisdn", msisdn); if (moHttpUrl != null) { request.addParameter("moHttpUrl", moHttpUrl); } diff --git a/src/main/java/com/vonage/client/redact/RedactClient.java b/src/main/java/com/vonage/client/redact/RedactClient.java index efaecc8ef..19dd95c3f 100644 --- a/src/main/java/com/vonage/client/redact/RedactClient.java +++ b/src/main/java/com/vonage/client/redact/RedactClient.java @@ -28,7 +28,7 @@ public class RedactClient extends AbstractClient { public RedactClient(HttpWrapper httpWrapper) { super(httpWrapper); - this.redactEndpoint = new RedactEndpoint(httpWrapper); + redactEndpoint = new RedactEndpoint(httpWrapper); } /** @@ -41,7 +41,7 @@ public RedactClient(HttpWrapper httpWrapper) { * @throws VonageResponseParseException if the response from the API could not be parsed. */ public void redactTransaction(String id, RedactRequest.Product product) throws VonageResponseParseException, VonageClientException { - this.redactTransaction(new RedactRequest(id, product)); + redactTransaction(new RedactRequest(id, product)); } /** @@ -58,7 +58,7 @@ public void redactTransaction(String id, RedactRequest.Product product, RedactRe RedactRequest request = new RedactRequest(id, product); request.setType(type); - this.redactTransaction(request); + redactTransaction(request); } /** @@ -70,6 +70,6 @@ public void redactTransaction(String id, RedactRequest.Product product, RedactRe * @throws VonageResponseParseException if the response from the API could not be parsed. */ public void redactTransaction(RedactRequest redactRequest) throws VonageResponseParseException, VonageClientException { - this.redactEndpoint.redactTransaction(redactRequest); + redactEndpoint.redactTransaction(redactRequest); } } diff --git a/src/main/java/com/vonage/client/redact/RedactEndpoint.java b/src/main/java/com/vonage/client/redact/RedactEndpoint.java index 6d2a9b410..d2abe4a7b 100644 --- a/src/main/java/com/vonage/client/redact/RedactEndpoint.java +++ b/src/main/java/com/vonage/client/redact/RedactEndpoint.java @@ -22,10 +22,10 @@ class RedactEndpoint { private RedactMethod redactMethod; RedactEndpoint(HttpWrapper httpWrapper) { - this.redactMethod = new RedactMethod(httpWrapper); + redactMethod = new RedactMethod(httpWrapper); } void redactTransaction(RedactRequest redactRequest) throws VonageClientException { - this.redactMethod.execute(redactRequest); + redactMethod.execute(redactRequest); } } diff --git a/src/main/java/com/vonage/client/redact/RedactRequest.java b/src/main/java/com/vonage/client/redact/RedactRequest.java index bf1af9cb3..8b581c2a1 100644 --- a/src/main/java/com/vonage/client/redact/RedactRequest.java +++ b/src/main/java/com/vonage/client/redact/RedactRequest.java @@ -81,10 +81,6 @@ public enum Product { NUMBER_INSIGHTS("number-insight"), VERIFY("verify"), VERIFY_SDK("verify-sdk"), - /** - * @deprecated Use {@link Product#MESSAGES} - **/ - @Deprecated MESSAGE("messages"), MESSAGES("messages"), WORKFLOW("workflow"); @@ -105,7 +101,7 @@ public enum Type { @JsonValue public String getValue() { - return this.name().toLowerCase(); + return name().toLowerCase(); } } } diff --git a/src/main/java/com/vonage/client/sms/SmsClient.java b/src/main/java/com/vonage/client/sms/SmsClient.java index ad88aa278..9c4aa13f3 100644 --- a/src/main/java/com/vonage/client/sms/SmsClient.java +++ b/src/main/java/com/vonage/client/sms/SmsClient.java @@ -40,12 +40,13 @@ public class SmsClient { /** * Create a new SmsClient. + * @param httpWrapper Http Wrapper used to create a Sms Request */ public SmsClient(HttpWrapper httpWrapper) { - this.message = new SendMessageEndpoint(httpWrapper); - this.search = new SmsSearchEndpoint(httpWrapper); - this.rejected = new SearchRejectedMessagesEndpoint(httpWrapper); - this.singleSearch = new SmsSingleSearchEndpoint(httpWrapper); + message = new SendMessageEndpoint(httpWrapper); + search = new SmsSearchEndpoint(httpWrapper); + rejected = new SearchRejectedMessagesEndpoint(httpWrapper); + singleSearch = new SmsSingleSearchEndpoint(httpWrapper); } /** @@ -80,11 +81,13 @@ public SmsSubmissionResponse submitMessage(Message message) throws VonageRespons * #searchMessages(String, String...)} instead. *

* + * @param request request to search for a sms message + * @return sms messages that match the search criteria * @throws VonageClientException if there was a problem with the Vonage request or response objects. * @throws VonageResponseParseException if the response from the API could not be parsed. */ public SearchSmsResponse searchMessages(SearchSmsRequest request) throws VonageResponseParseException, VonageClientException { - return this.search.execute(request); + return search.execute(request); } /** @@ -102,7 +105,7 @@ public SearchSmsResponse searchMessages(String id, String... ids) throws VonageR List idList = new ArrayList<>(ids.length + 1); idList.add(id); idList.addAll(Arrays.asList(ids)); - return this.searchMessages(new SmsIdSearchRequest(idList)); + return searchMessages(new SmsIdSearchRequest(idList)); } /** @@ -117,7 +120,7 @@ public SearchSmsResponse searchMessages(String id, String... ids) throws VonageR * @throws VonageResponseParseException if the response from the API could not be parsed. */ public SearchSmsResponse searchMessages(Date date, String to) throws VonageResponseParseException, VonageClientException { - return this.searchMessages(new SmsDateSearchRequest(date, to)); + return searchMessages(new SmsDateSearchRequest(date, to)); } /** @@ -125,13 +128,15 @@ public SearchSmsResponse searchMessages(Date date, String to) throws VonageRespo *

* You should probably use {@link #searchRejectedMessages(Date, String)} instead. * + * @param request search for rejected SMS transactions + * * @return rejection data matching the provided criteria * * @throws VonageClientException if there was a problem with the Vonage request or response objects. * @throws VonageResponseParseException if the response from the API could not be parsed. */ public SearchRejectedMessagesResponse searchRejectedMessages(SearchRejectedMessagesRequest request) throws VonageResponseParseException, VonageClientException { - return this.rejected.execute(request); + return rejected.execute(request); } /** @@ -146,7 +151,7 @@ public SearchRejectedMessagesResponse searchRejectedMessages(SearchRejectedMessa * @throws VonageResponseParseException if the response from the API could not be parsed. */ public SearchRejectedMessagesResponse searchRejectedMessages(Date date, String to) throws VonageResponseParseException, VonageClientException { - return this.searchRejectedMessages(new SearchRejectedMessagesRequest(date, to)); + return searchRejectedMessages(new SearchRejectedMessagesRequest(date, to)); } /** @@ -160,6 +165,6 @@ public SearchRejectedMessagesResponse searchRejectedMessages(Date date, String t * @throws VonageResponseParseException if the response from the API could not be parsed. */ public SmsSingleSearchResponse getSms(String id) throws VonageResponseParseException, VonageClientException { - return this.singleSearch.execute(id); + return singleSearch.execute(id); } } diff --git a/src/main/java/com/vonage/client/sms/callback/AbstractMOServlet.java b/src/main/java/com/vonage/client/sms/callback/AbstractMOServlet.java index fdb3ea0bc..c138aa581 100644 --- a/src/main/java/com/vonage/client/sms/callback/AbstractMOServlet.java +++ b/src/main/java/com/vonage/client/sms/callback/AbstractMOServlet.java @@ -65,14 +65,15 @@ public abstract class AbstractMOServlet extends HttpServlet { protected Executor consumer; public AbstractMOServlet(final boolean validateSignature, final String signatureSharedSecret, final boolean validateUsernamePassword, final String expectedUsername, final String expectedPassword) { + hashType = HashUtil.HashType.MD5; + consumer = Executors.newFixedThreadPool(MAX_CONSUMER_THREADS); + this.validateSignature = validateSignature; this.signatureSharedSecret = signatureSharedSecret; this.validateUsernamePassword = validateUsernamePassword; this.expectedUsername = expectedUsername; this.expectedPassword = expectedPassword; - this.hashType = HashUtil.HashType.MD5; - this.consumer = Executors.newFixedThreadPool(MAX_CONSUMER_THREADS); } public AbstractMOServlet(final boolean validateSignature, @@ -88,7 +89,7 @@ public AbstractMOServlet(final boolean validateSignature, this.expectedPassword = expectedPassword; this.hashType = hashType; - this.consumer = Executors.newFixedThreadPool(MAX_CONSUMER_THREADS); + consumer = Executors.newFixedThreadPool(MAX_CONSUMER_THREADS); } @Override @@ -103,19 +104,19 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) private void validateRequest(HttpServletRequest request) throws VonageCallbackRequestValidationException { boolean passed = true; - if (this.validateUsernamePassword) { + if (validateUsernamePassword) { String username = request.getParameter("username"); String password = request.getParameter("password"); - if (this.expectedUsername != null) if (!this.expectedUsername.equals(username)) passed = false; - if (this.expectedPassword != null) if (!this.expectedPassword.equals(password)) passed = false; + if (expectedUsername != null) if (!expectedUsername.equals(username)) passed = false; + if (expectedPassword != null) if (!expectedPassword.equals(password)) passed = false; } if (!passed) { throw new VonageCallbackRequestValidationException("Bad Credentials"); } - if (this.validateSignature) { - if (!RequestSigning.verifyRequestSignature(request, this.signatureSharedSecret, this.hashType)) { + if (validateSignature) { + if (!RequestSigning.verifyRequestSignature(request, signatureSharedSecret, hashType)) { throw new VonageCallbackRequestValidationException("Bad Signature"); } } @@ -161,7 +162,7 @@ private void handleRequest(HttpServletRequest request, HttpServletResponse respo // Push the task to an async consumption thread ConsumeTask task = new ConsumeTask(this, mo); - this.consumer.execute(task); + consumer.execute(task); // immediately ack the receipt try (PrintWriter out = response.getWriter()) { @@ -241,7 +242,7 @@ public ConsumeTask(final AbstractMOServlet parent, final MO mo) { @Override public void run() { - this.parent.consume(this.mo); + parent.consume(mo); } } diff --git a/src/main/java/com/vonage/client/sms/callback/messages/MO.java b/src/main/java/com/vonage/client/sms/callback/messages/MO.java index a456658e0..c30d52485 100644 --- a/src/main/java/com/vonage/client/sms/callback/messages/MO.java +++ b/src/main/java/com/vonage/client/sms/callback/messages/MO.java @@ -78,7 +78,7 @@ public enum MESSAGE_TYPE { * @return String A descriptive value representing this type */ public String getType() { - return this.type; + return type; } } @@ -119,7 +119,7 @@ public MO(final String messageId, public void setTextData(String text, String keyword) { - this.messageBody = text; + messageBody = text; this.keyword = keyword; } @@ -181,112 +181,112 @@ public void setSessionId(String sessionId) { * @return String the id assigned to this message by Vonage before delivery */ public String getMessageId() { - return this.messageId; + return messageId; } /** * @return MESSAGE_TYPE describes what type of payload this message carries, eg, 8 bit text, unicode text or raw binary */ public MESSAGE_TYPE getMessageType() { - return this.messageType; + return messageType; } /** * @return String the phone number of the end user that sent this message */ public String getSender() { - return this.sender; + return sender; } /** * @return String the short-code/long code number that the end user sent the message to */ public String getDestination() { - return this.destination; + return destination; } /** * @return String the network code (if available) of the end user */ public String getNetworkCode() { - return this.networkCode; + return networkCode; } /** * @return String return the first keyword of the message. If this is a shared short-code then this is what the message will have been routed by. */ public String getKeyword() { - return this.keyword; + return keyword; } /** * @return String The message payload if this is a TEXT or UNICODE message */ public String getMessageBody() { - return this.messageBody; + return messageBody; } /** * @return byte[] the raw binary payload if this is a BINARY message */ public byte[] getBinaryMessageBody() { - return this.binaryMessageBody; + return binaryMessageBody; } /** * @return byte[] the raw binary user-data-header if applicable for this message */ public byte[] getUserDataHeader() { - return this.userDataHeader; + return userDataHeader; } /** * @return BigDecimal if a price was charged for receiving this message, then that is available here */ public BigDecimal getPrice() { - return this.price; + return price; } /** * @return String if this field is populated, then the value should be returned in any MT response */ public String getSessionId() { - return this.sessionId; + return sessionId; } /** * @return boolean is this message part of a concatenated message that needs re-assembly */ public boolean isConcat() { - return this.concat; + return concat; } /** * @return String if this message is part of a concatenated set, then this is the reference id that groups the parts together */ public String getConcatReferenceNumber() { - return this.concatReferenceNumber; + return concatReferenceNumber; } /** * @return String if this message is part of a concatenated set, then this is the total number of parts in the set */ public int getConcatTotalParts() { - return this.concatTotalParts; + return concatTotalParts; } /** * @return String if this message is part of a concatenated set, then this is the 'part number' within the set that this message carries */ public int getConcatPartNumber() { - return this.concatPartNumber; + return concatPartNumber; } /** * @return the timestamp this message was originally received by Vonage */ public Date getTimeStamp() { - return this.timeStamp; + return timeStamp; } } diff --git a/src/main/java/com/vonage/client/sms/messages/Message.java b/src/main/java/com/vonage/client/sms/messages/Message.java index 421fd25a3..23d37736a 100644 --- a/src/main/java/com/vonage/client/sms/messages/Message.java +++ b/src/main/java/com/vonage/client/sms/messages/Message.java @@ -72,6 +72,7 @@ protected Message(final MessageType type, * valid short-code / long code that can be replied to, or a short text description of the application * sending the message (Max 15 chars) * @param to the phone number of the handset you wish to send the message to + * @param statusReportRequired flag to enable status updates about the delivery of this message */ protected Message(final MessageType type, final String from, @@ -87,7 +88,7 @@ protected Message(final MessageType type, * @return int the type of message will influence the makeup of the request we post to the Vonage server, and also the action taken by the Vonage server in response to this message */ public MessageType getType() { - return this.type; + return type; } /** @@ -95,14 +96,14 @@ public MessageType getType() { * typically either a valid short-code / long code that can be replied to, or a short text description of the application sending the message (Max 11 chars) */ public String getFrom() { - return this.from; + return from; } /** * @return String the phone number of the handset that you wish to send the message to */ public String getTo() { - return this.to; + return to; } /** @@ -110,7 +111,7 @@ public String getTo() { * be available in detailed reporting & analytics in order to help with reconciliation of messages */ public String getClientReference() { - return this.clientReference; + return clientReference; } public void setClientReference(String clientReference) { @@ -124,11 +125,11 @@ public void setClientReference(String clientReference) { * @return {@link MessageClass} The message class that is to be applied to this message. */ public MessageClass getMessageClass() { - return this.messageClass; + return messageClass; } public void setMessageClass(MessageClass messageClass) { - this.messageClass = messageClass; + messageClass = messageClass; } public Long getTimeToLive() { @@ -148,10 +149,10 @@ public void setCallbackUrl(String callbackUrl) { } /** - * Get the value of the 'status-report-req' parameter. + * @return get the value of the 'status-report-req' parameter. */ public boolean getStatusReportRequired() { - return this.statusReportRequired; + return statusReportRequired; } /** @@ -222,7 +223,7 @@ public enum MessageClass { } public int getMessageClass() { - return this.messageClass; + return messageClass; } } diff --git a/src/main/java/com/vonage/client/sms/messages/TextMessage.java b/src/main/java/com/vonage/client/sms/messages/TextMessage.java index d21930608..3d26f23c0 100644 --- a/src/main/java/com/vonage/client/sms/messages/TextMessage.java +++ b/src/main/java/com/vonage/client/sms/messages/TextMessage.java @@ -53,6 +53,7 @@ public TextMessage(final String from, * description of the application sending the message (Max 11 chars) * @param to the phone number of the handset that you wish to send the message to * @param messageBody The text of the message to be sent to the handset + * @param unicode set this flag to true if the message needs to be submitted as a unicode message */ public TextMessage(final String from, final String to, @@ -67,7 +68,7 @@ public TextMessage(final String from, * @return String The text of the message to be sent to the handset */ public String getMessageBody() { - return this.messageBody; + return messageBody; } /** @@ -76,7 +77,7 @@ public String getMessageBody() { * would be messages to be sent in non-western scripts, such as Arabic, Kanji, Chinese, etc. */ public boolean isUnicode() { - return this.unicode; + return unicode; } @Override diff --git a/src/main/java/com/vonage/client/sns/SnsClient.java b/src/main/java/com/vonage/client/sns/SnsClient.java index 0d1bc6186..0d31536fc 100644 --- a/src/main/java/com/vonage/client/sns/SnsClient.java +++ b/src/main/java/com/vonage/client/sns/SnsClient.java @@ -38,14 +38,14 @@ public class SnsClient { * @param httpWrapper (required) shared HTTP wrapper object used for making REST calls. */ public SnsClient(HttpWrapper httpWrapper) { - this.endpoint = new SnsEndpoint(httpWrapper); + endpoint = new SnsEndpoint(httpWrapper); } public SnsPublishResponse publish(SnsPublishRequest request) throws VonageClientException, VonageResponseParseException { - return (SnsPublishResponse) this.endpoint.execute(request); + return (SnsPublishResponse) endpoint.execute(request); } public SnsSubscribeResponse subscribe(SnsSubscribeRequest request) throws VonageClientException, VonageResponseParseException { - return (SnsSubscribeResponse) this.endpoint.execute(request); + return (SnsSubscribeResponse) endpoint.execute(request); } } diff --git a/src/main/java/com/vonage/client/sns/response/SnsPublishResponse.java b/src/main/java/com/vonage/client/sns/response/SnsPublishResponse.java index 7fd11a252..1efcc0302 100644 --- a/src/main/java/com/vonage/client/sns/response/SnsPublishResponse.java +++ b/src/main/java/com/vonage/client/sns/response/SnsPublishResponse.java @@ -27,6 +27,6 @@ public SnsPublishResponse(final int resultCode, } public String getTransactionId() { - return this.transactionId; + return transactionId; } } diff --git a/src/main/java/com/vonage/client/verify/BaseRequest.java b/src/main/java/com/vonage/client/verify/BaseRequest.java index 7fafb9c16..3c019ad6c 100644 --- a/src/main/java/com/vonage/client/verify/BaseRequest.java +++ b/src/main/java/com/vonage/client/verify/BaseRequest.java @@ -36,14 +36,6 @@ public class BaseRequest { private Integer pinExpiry; private Integer nextEventWait; - public BaseRequest(String number, Integer length, Locale locale) { - this.number = number; - this.length = length; - this.locale = locale; - country = null; - pinExpiry = null; - nextEventWait = null; - } protected BaseRequest(String number, Integer length, Locale locale, String country, Integer pinExpiry, Integer nextEventWait) { this.number = number; @@ -70,16 +62,6 @@ public Integer getLength() { return length; } - /** - * - * @param length the length of the verification code to be sent to the user. Options are either 4 or 6. - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request or - * {@link Psd2Request.Builder} to create a PSD2 verification request - */ - @Deprecated - public void setLength(Integer length) { - this.length = length; - } /** * @return the default locale used for verification. If this value is {@code null}, the locale will be determined @@ -90,16 +72,6 @@ public Locale getLocale() { } - /** - * - * @param locale Override the default locale used for verification. By default the locale is determined - * from the country code included in {@code number} - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request or - * {@link Psd2Request.Builder} to create a PSD2 verification request - */ - public void setLocale(Locale locale) { - this.locale = locale; - } /** * @return the default locale used for verification in snake case. @@ -123,20 +95,6 @@ public String getCountry() { return country; } - /** - * The country for the destination phone number. - *

- * If you wish to used localised number formats or you are not sure if number is correctly formatted, set this to a - * two-character country code. For example, GB, US. Verify will work out the international phone number for you. - *

- * - * @param country a String containing a 2-character country code - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request or - * {@link Psd2Request.Builder} to create a PSD2 verification request - */ - public void setCountry(String country) { - this.country = country; - } /** * @return PIN expiry time in seconds @@ -145,14 +103,6 @@ public Integer getPinExpiry() { return pinExpiry; } - /** - * @param pinExpiry PIN expiry time in seconds. - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request or - * {@link Psd2Request.Builder} to create a PSD2 verification request - */ - public void setPinExpiry(Integer pinExpiry) { - this.pinExpiry = pinExpiry; - } /** * @return the wait time between attempts to deliver the PIN. An Integer between 600-900, or null. @@ -161,16 +111,6 @@ public Integer getNextEventWait() { return nextEventWait; } - /** - * Set the wait time between attempts to deliver the PIN. - * - * @param nextEventWait An Integer value between 60 and 900 seconds, or null to use the default duration. - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request or - * {@link Psd2Request.Builder} to create a PSD2 verification request - */ - public void setNextEventWait(Integer nextEventWait) { - this.nextEventWait = nextEventWait; - } @Override public String toString() { diff --git a/src/main/java/com/vonage/client/verify/BaseResult.java b/src/main/java/com/vonage/client/verify/BaseResult.java index a9a5bdcb9..ec37b21e3 100644 --- a/src/main/java/com/vonage/client/verify/BaseResult.java +++ b/src/main/java/com/vonage/client/verify/BaseResult.java @@ -123,14 +123,14 @@ protected BaseResult(final int status, } public int getStatus() { - return this.status; + return status; } public String getErrorText() { - return this.errorText; + return errorText; } public boolean isTemporaryError() { - return this.temporaryError; + return temporaryError; } } diff --git a/src/main/java/com/vonage/client/verify/ControlRequest.java b/src/main/java/com/vonage/client/verify/ControlRequest.java index daf92dc36..75479c355 100644 --- a/src/main/java/com/vonage/client/verify/ControlRequest.java +++ b/src/main/java/com/vonage/client/verify/ControlRequest.java @@ -36,8 +36,8 @@ public VerifyControlCommand getCommand() { public void addParams(RequestBuilder request) { request - .addParameter("request_id", this.getRequestId()) - .addParameter("cmd", this.getCommand().toString()); + .addParameter("request_id", getRequestId()) + .addParameter("cmd", getCommand().toString()); } } diff --git a/src/main/java/com/vonage/client/verify/ControlResponse.java b/src/main/java/com/vonage/client/verify/ControlResponse.java index 0947c4a72..b266f00f0 100644 --- a/src/main/java/com/vonage/client/verify/ControlResponse.java +++ b/src/main/java/com/vonage/client/verify/ControlResponse.java @@ -50,7 +50,7 @@ public VerifyControlCommand getCommand() { @JsonProperty("error_text") public String getErrorText() { - return this.errorText; + return errorText; } public static ControlResponse fromJson(String json) { diff --git a/src/main/java/com/vonage/client/verify/Psd2Endpoint.java b/src/main/java/com/vonage/client/verify/Psd2Endpoint.java index bf23b5205..168274288 100644 --- a/src/main/java/com/vonage/client/verify/Psd2Endpoint.java +++ b/src/main/java/com/vonage/client/verify/Psd2Endpoint.java @@ -7,7 +7,7 @@ public class Psd2Endpoint { public Psd2Method method; public Psd2Endpoint(HttpWrapper wrapper) { - this.method = new Psd2Method(wrapper); + method = new Psd2Method(wrapper); } public VerifyResponse psd2Verify(String number, Double amount, String payee){ diff --git a/src/main/java/com/vonage/client/verify/Psd2Request.java b/src/main/java/com/vonage/client/verify/Psd2Request.java index 62dd00aa2..10e791f7f 100644 --- a/src/main/java/com/vonage/client/verify/Psd2Request.java +++ b/src/main/java/com/vonage/client/verify/Psd2Request.java @@ -54,7 +54,7 @@ public Double getAmount() { * @return An alphanumeric string to indicate to the user the name of the recipient that they are confirming a payment to. */ public String getPayee() { - return this.payee; + return payee; } /** @@ -95,6 +95,11 @@ public int getId() { } /** + * @param number The recipient's phone number in E.164 + * format. + * @param amount The decimal amount of the payment to be confirmed, in Euros. + * @param payee An alphanumeric string to indicate to the user the name of the recipient that they + * are confirming a payment to. * @return A new Builder to start building. */ public static Builder builder(String number, Double amount, String payee) { diff --git a/src/main/java/com/vonage/client/verify/SearchEndpoint.java b/src/main/java/com/vonage/client/verify/SearchEndpoint.java index 7902cdd50..aca4c20c3 100644 --- a/src/main/java/com/vonage/client/verify/SearchEndpoint.java +++ b/src/main/java/com/vonage/client/verify/SearchEndpoint.java @@ -23,10 +23,10 @@ class SearchEndpoint { private SearchMethod searchMethod; SearchEndpoint(HttpWrapper httpWrapper) { - this.searchMethod = new SearchMethod(httpWrapper); + searchMethod = new SearchMethod(httpWrapper); } SearchVerifyResponse search(String... requestIds) throws VonageClientException, VonageResponseParseException { - return this.searchMethod.execute(new SearchRequest(requestIds)); + return searchMethod.execute(new SearchRequest(requestIds)); } } diff --git a/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java b/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java index f4266f598..2e73c5dfc 100644 --- a/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java +++ b/src/main/java/com/vonage/client/verify/SearchVerifyResponse.java @@ -32,16 +32,16 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class SearchVerifyResponse { private VerifyStatus status; - private List verificationRequests = new ArrayList<>(); + private List verificationRequests; private String errorText; @JsonCreator SearchVerifyResponse() { - this.status = VerifyStatus.OK; + status = VerifyStatus.OK; } SearchVerifyResponse(List verificationRequests) { - this.status = VerifyStatus.OK; + status = VerifyStatus.OK; this.verificationRequests = verificationRequests; } @@ -56,12 +56,12 @@ public VerifyStatus getStatus() { @JsonProperty("verification_requests") public List getVerificationRequests() { - return this.verificationRequests; + return verificationRequests; } @JsonProperty("error_text") public String getErrorText() { - return this.errorText; + return errorText; } public static SearchVerifyResponse fromJson(String json) { diff --git a/src/main/java/com/vonage/client/verify/VerifyDetails.java b/src/main/java/com/vonage/client/verify/VerifyDetails.java index 3974984ad..6d4690aea 100644 --- a/src/main/java/com/vonage/client/verify/VerifyDetails.java +++ b/src/main/java/com/vonage/client/verify/VerifyDetails.java @@ -40,57 +40,57 @@ public class VerifyDetails { @JsonProperty("request_id") public String getRequestId() { - return this.requestId; + return requestId; } @JsonProperty("account_id") public String getAccountId() { - return this.accountId; + return accountId; } public String getNumber() { - return this.number; + return number; } @JsonProperty("sender_id") public String getSenderId() { - return this.senderId; + return senderId; } @JsonProperty("date_submitted") public Date getDateSubmitted() { - return this.dateSubmitted; + return dateSubmitted; } @JsonProperty("date_finalized") public Date getDateFinalized() { - return this.dateFinalized; + return dateFinalized; } @JsonProperty("first_event_date") public Date getFirstEventDate() { - return this.firstEventDate; + return firstEventDate; } @JsonProperty("last_event_date") public Date getLastEventDate() { - return this.lastEventDate; + return lastEventDate; } public Status getStatus() { - return this.status; + return status; } public BigDecimal getPrice() { - return this.price; + return price; } public String getCurrency() { - return this.currency; + return currency; } public List getChecks() { - return this.checks; + return checks; } public enum Status { @@ -127,7 +127,7 @@ public static Status fromString(String status) { @JsonValue public String getStatus() { - return this.status; + return status; } } } diff --git a/src/main/java/com/vonage/client/verify/VerifyRequest.java b/src/main/java/com/vonage/client/verify/VerifyRequest.java index 513ab2482..cf0971f29 100644 --- a/src/main/java/com/vonage/client/verify/VerifyRequest.java +++ b/src/main/java/com/vonage/client/verify/VerifyRequest.java @@ -29,87 +29,6 @@ public class VerifyRequest extends BaseRequest { private Workflow workflow; - - /** - * Constructor. - * - * @param number (required) The recipient's phone number in E.164 - * format. - * @param brand (required) The name of the company or app to be verified for. Must not be longer than 18 - * characters. - * @deprecated this construtor is deprecated use {@link Builder} to contruct a 2FA verify request - */ - @Deprecated - public VerifyRequest(final String number, final String brand) { - this(number, brand, null, -1, null, null); - } - - /** - * Constructor. - * - * @param number (required) The recipient's phone number in E.164 - * format. - * @param brand (required) The name of the company or app you are verifying for. Must not be longer than 18 - * characters. - * @param from (optional The Vonage number to use as the sender for the verification SMS message and calls, in - * E.164 format. - * @deprecated this construtor is deprecated use {@link Builder} to contruct a 2FA verify request - */ - @Deprecated - public VerifyRequest(final String number, final String brand, final String from) { - this(number, brand, from, -1, null, null); - } - - /** - * Constructor. - * - * @param number (required) The recipient's phone number in E.164 - * format. - * @param brand (required) The name of the company or app you are verifying for. Must not be longer than 18 - * characters. - * @param from (optional The Vonage number to use as the sender for the verification SMS message and calls, in - * E.164 format. - * @param length (optional) The length of the verification code to be sent to the user. Must be either 4 or 6. Use - * -1 to use the default value. - * @param locale (optional) Override the default locale used for verification. By default the locale is determined - * from the country code included in {@code number} - * @deprecated this construtor is deprecated use {@link Builder} instead - */ - @Deprecated - public VerifyRequest(final String number, final String brand, final String from, final int length, final Locale locale) { - this(number, brand, from, length, locale, null); - } - - /** - * Constructor. - * - * @param number (required) The recipient's phone number in E.164 - * format. - * @param brand (required) The name of the company or app you are verifying for. Must not be longer than 18 - * characters. - * @param from (optional A short alphanumeric string to specify the SenderID for SMS sent by Verify. Depending on - * the destination of the phone number you are applying, restrictions may apply. By default, sender_id - * is {@code VERIFY}. Must be 11 characters or fewer. - * @param length (optional) The length of the verification code to be sent to the user. Must be either 4 or 6. Use - * -1 to use the default value. - * @param locale (optional) Override the default locale used for verification. By default the locale is determined - * from the country code included in {@code number} - * @param type (optional) If provided, restrict the verification to the specified network type. Contact - * support@nexmo.com to enable this feature. - */ - @Deprecated - public VerifyRequest(final String number, final String brand, final String from, final int length, final Locale locale, final LineType type) { - super(number, length, locale); - - this.type = type; - this.brand = brand; - this.from = from; - this.workflow = null; - setCountry(null); - setPinExpiry(null); - setNextEventWait(null); - } - public VerifyRequest(Builder builder) { super(builder.number, builder.length, builder.locale, builder.country, builder.pinExpiry, builder.nextEventWait); brand = builder.brand; @@ -135,16 +54,6 @@ public LineType getType() { } - /** - * @param type the type of network the verification will be restricted to. This value has no effect unless it has been - * enabled by contacting {@code support@nexmo.com}. - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request - * @see Builder#type(LineType) - */ - public void setType(LineType type) { - this.type = type; - } - /** * @return the short alphanumeric string to specify the SenderID for SMS sent by Verify, or {@code null} if one was @@ -156,14 +65,6 @@ public String getFrom() { return from; } - /** - * @param from the short alphanumeric string to specify the SenderID for SMS sent by Verify. - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request - * @see VerifyRequest.Builder#senderId(String) - */ - public void setFrom(String from) { - this.from = from; - } /** * Types of phone line to be specified for {@link VerifyRequest#type}. This option is not generally available. It will @@ -181,15 +82,6 @@ public Workflow getWorkflow() { return workflow; } - /** - * @param workflow The workflow to use for conveying the PIN to your user. - * @deprecated since 5.5.0 use {@link VerifyRequest.Builder} to create a 2FA verification request - * @see Builder#workflow(Workflow) - */ - public void setWorkflow(Workflow workflow) { - this.workflow = workflow; - } - /** * Enumeration representing different verification workflows. *

diff --git a/src/main/java/com/vonage/client/verify/VerifyResponse.java b/src/main/java/com/vonage/client/verify/VerifyResponse.java index cff8e6f31..0efb3085e 100644 --- a/src/main/java/com/vonage/client/verify/VerifyResponse.java +++ b/src/main/java/com/vonage/client/verify/VerifyResponse.java @@ -36,16 +36,16 @@ public VerifyResponse(@JsonProperty(value = "status", required = true) VerifySta @JsonProperty("request_id") public String getRequestId() { - return this.requestId; + return requestId; } public VerifyStatus getStatus() { - return this.status; + return status; } @JsonProperty("error_text") public String getErrorText() { - return this.errorText; + return errorText; } public static VerifyResponse fromJson(String json) { diff --git a/src/main/java/com/vonage/client/verify/VerifyStatus.java b/src/main/java/com/vonage/client/verify/VerifyStatus.java index 0ad08a170..d538785cf 100644 --- a/src/main/java/com/vonage/client/verify/VerifyStatus.java +++ b/src/main/java/com/vonage/client/verify/VerifyStatus.java @@ -66,7 +66,7 @@ public static VerifyStatus fromInt(int verifyStatus) { } public int getVerifyStatus() { - return this.verifyStatus; + return verifyStatus; } public boolean isTemporaryError() { diff --git a/src/main/java/com/vonage/client/voice/CallModifier.java b/src/main/java/com/vonage/client/voice/CallModifier.java index d25c5d0d0..83ba500b7 100644 --- a/src/main/java/com/vonage/client/voice/CallModifier.java +++ b/src/main/java/com/vonage/client/voice/CallModifier.java @@ -32,7 +32,7 @@ public CallModifier(String uuid, ModifyCallPayload modifyCallPayload) { public CallModifier(String uuid, ModifyCallAction action) { this.uuid = uuid; - this.modifyCallPayload = new ModifyCallPayload(action); + modifyCallPayload = new ModifyCallPayload(action); } public static CallModifier transferCall(String uuid, String nccoUrl) { @@ -54,7 +54,7 @@ public ModifyCallAction getAction() { public String toJson() { try { ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(this.modifyCallPayload); + return mapper.writeValueAsString(modifyCallPayload); } catch (JsonProcessingException jpe) { throw new VonageUnexpectedException("Failed to produce json from CallModifier object.", jpe); } diff --git a/src/main/java/com/vonage/client/voice/DtmfEndpoint.java b/src/main/java/com/vonage/client/voice/DtmfEndpoint.java index d291c12ae..f1e5df190 100644 --- a/src/main/java/com/vonage/client/voice/DtmfEndpoint.java +++ b/src/main/java/com/vonage/client/voice/DtmfEndpoint.java @@ -22,10 +22,10 @@ public class DtmfEndpoint { private final SendDtmfMethod sendDtmf; public DtmfEndpoint(HttpWrapper httpWrapper) { - this.sendDtmf = new SendDtmfMethod(httpWrapper); + sendDtmf = new SendDtmfMethod(httpWrapper); } public DtmfResponse put(String uuid, String digits) throws VonageClientException { - return this.sendDtmf.execute(new DtmfRequest(uuid, digits)); + return sendDtmf.execute(new DtmfRequest(uuid, digits)); } } \ No newline at end of file diff --git a/src/main/java/com/vonage/client/voice/TalkRequest.java b/src/main/java/com/vonage/client/voice/TalkRequest.java index 6d49b7934..52df9338a 100644 --- a/src/main/java/com/vonage/client/voice/TalkRequest.java +++ b/src/main/java/com/vonage/client/voice/TalkRequest.java @@ -30,7 +30,7 @@ public class TalkRequest { private String uuid; public TalkRequest(String uuid, String text, VoiceName voiceName, int loop) { - this.talkPayload = new TalkPayload(text, voiceName, loop); + talkPayload = new TalkPayload(text, voiceName, loop); this.uuid = uuid; } @@ -57,7 +57,7 @@ public void setUuid(String uuid) { public String toJson() { try { ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(this.talkPayload); + return mapper.writeValueAsString(talkPayload); } catch (JsonProcessingException jpe) { throw new VonageUnexpectedException("Failed to produce json from TalkRequest object.", jpe); } diff --git a/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java b/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java index edf7bf10f..49c38b1e6 100644 --- a/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java +++ b/src/main/java/com/vonage/client/voice/ncco/ConversationAction.java @@ -38,13 +38,13 @@ public class ConversationAction implements Action { private EventMethod eventMethod; private ConversationAction(Builder builder) { - this.name = builder.name; - this.musicOnHoldUrl = builder.musicOnHoldUrl; - this.startOnEnter = builder.startOnEnter; - this.endOnExit = builder.endOnExit; - this.record = builder.record; - this.eventUrl = builder.eventUrl; - this.eventMethod = builder.eventMethod; + name = builder.name; + musicOnHoldUrl = builder.musicOnHoldUrl; + startOnEnter = builder.startOnEnter; + endOnExit = builder.endOnExit; + record = builder.record; + eventUrl = builder.eventUrl; + eventMethod = builder.eventMethod; } @Override @@ -86,12 +86,12 @@ public static Builder builder(String name) { public static class Builder { private String name; - private Collection musicOnHoldUrl = null; - private Boolean startOnEnter = null; - private Boolean endOnExit = null; - private Boolean record = null; - private Collection eventUrl = null; - private EventMethod eventMethod = null; + private Collection musicOnHoldUrl; + private Boolean startOnEnter; + private Boolean endOnExit; + private Boolean record; + private Collection eventUrl; + private EventMethod eventMethod; /** * @param name The name of the Conversation room. diff --git a/src/main/java/com/vonage/client/voice/ncco/InputAction.java b/src/main/java/com/vonage/client/voice/ncco/InputAction.java index 79bfb2de3..e6dc04f89 100644 --- a/src/main/java/com/vonage/client/voice/ncco/InputAction.java +++ b/src/main/java/com/vonage/client/voice/ncco/InputAction.java @@ -41,11 +41,11 @@ public class InputAction implements Action { * @param builder builder to create InputAction object */ private InputAction(Builder builder) { - this.type = builder.type; - this.dtmf = builder.dtmf; - this.eventUrl = builder.eventUrl; - this.eventMethod = builder.eventMethod; - this.speech = builder.speech; + type = builder.type; + dtmf = builder.dtmf; + eventUrl = builder.eventUrl; + eventMethod = builder.eventMethod; + speech = builder.speech; } @Override diff --git a/src/main/java/com/vonage/client/voice/ncco/RecordAction.java b/src/main/java/com/vonage/client/voice/ncco/RecordAction.java index f031dab1b..a052c3a7f 100644 --- a/src/main/java/com/vonage/client/voice/ncco/RecordAction.java +++ b/src/main/java/com/vonage/client/voice/ncco/RecordAction.java @@ -40,10 +40,9 @@ public class RecordAction implements Action { private Integer channels; /** - * @deprecated Use {@link Builder} + * @param builder Builder for building the Record Action */ - @Deprecated - public RecordAction(Builder builder) { + private RecordAction(Builder builder) { this.format = builder.format; this.endOnSilence = builder.endOnSilence; this.endOnKey = builder.endOnKey; diff --git a/src/main/java/com/vonage/client/voice/ncco/StreamAction.java b/src/main/java/com/vonage/client/voice/ncco/StreamAction.java index 95b4dcbf8..560f10f3a 100644 --- a/src/main/java/com/vonage/client/voice/ncco/StreamAction.java +++ b/src/main/java/com/vonage/client/voice/ncco/StreamAction.java @@ -35,10 +35,10 @@ public class StreamAction implements Action { private Integer loop; private StreamAction(Builder builder) { - this.streamUrl = builder.streamUrl; - this.level = builder.level; - this.bargeIn = builder.bargeIn; - this.loop = builder.loop; + streamUrl = builder.streamUrl; + level = builder.level; + bargeIn = builder.bargeIn; + loop = builder.loop; } @Override @@ -72,9 +72,9 @@ public static Builder builder(String... streamUrl) { public static class Builder { private Collection streamUrl; - private Float level = null; - private Boolean bargeIn = null; - private Integer loop = null; + private Float level; + private Boolean bargeIn; + private Integer loop; /** * @param streamUrl An array containing a single URL to an mp3 or wav (16-bit) audio file to stream to the diff --git a/src/main/java/com/vonage/client/voice/ncco/WebSocketEndpoint.java b/src/main/java/com/vonage/client/voice/ncco/WebSocketEndpoint.java index b32f4c1d0..9cfed12e3 100644 --- a/src/main/java/com/vonage/client/voice/ncco/WebSocketEndpoint.java +++ b/src/main/java/com/vonage/client/voice/ncco/WebSocketEndpoint.java @@ -33,9 +33,9 @@ public class WebSocketEndpoint implements Endpoint { private Map headers; private WebSocketEndpoint(Builder builder) { - this.uri = builder.uri; - this.contentType = builder.contentType; - this.headers = builder.headers; + uri = builder.uri; + contentType = builder.contentType; + headers = builder.headers; } public String getUri() { diff --git a/src/main/java/com/vonage/client/voice/servlet/AbstractAnswerServlet.java b/src/main/java/com/vonage/client/voice/servlet/AbstractAnswerServlet.java index cbf73f437..f217de99f 100644 --- a/src/main/java/com/vonage/client/voice/servlet/AbstractAnswerServlet.java +++ b/src/main/java/com/vonage/client/voice/servlet/AbstractAnswerServlet.java @@ -31,12 +31,12 @@ public abstract class AbstractAnswerServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - serializeNccoResponse(resp, this.handleRequest(req)); + serializeNccoResponse(resp, handleRequest(req)); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - serializeNccoResponse(resp, this.handleRequest(req)); + serializeNccoResponse(resp, handleRequest(req)); } private void serializeNccoResponse(HttpServletResponse httpResponse, NccoResponse nccoResponse) throws IOException { diff --git a/src/main/java/com/vonage/client/voice/servlet/NccoResponse.java b/src/main/java/com/vonage/client/voice/servlet/NccoResponse.java index d493c9848..dfcd17dfb 100644 --- a/src/main/java/com/vonage/client/voice/servlet/NccoResponse.java +++ b/src/main/java/com/vonage/client/voice/servlet/NccoResponse.java @@ -44,7 +44,7 @@ public NccoResponse() { } public void appendNcco(Action action) { - this.actionList.add(action); + actionList.add(action); } public String toJson() { diff --git a/src/main/java/com/vonage/client/voice/servlet/NccoResponseBuilder.java b/src/main/java/com/vonage/client/voice/servlet/NccoResponseBuilder.java index c4ee32ee5..4f21408c6 100644 --- a/src/main/java/com/vonage/client/voice/servlet/NccoResponseBuilder.java +++ b/src/main/java/com/vonage/client/voice/servlet/NccoResponseBuilder.java @@ -27,15 +27,15 @@ public class NccoResponseBuilder { private NccoResponse value; public NccoResponseBuilder() { - this.value = new NccoResponse(); + value = new NccoResponse(); } public NccoResponseBuilder appendNcco(Action action) { - this.value.appendNcco(action); + value.appendNcco(action); return this; } public NccoResponse getValue() { - return this.value; + return value; } } \ No newline at end of file diff --git a/src/test/java/com/vonage/client/HttpWrapperTest.java b/src/test/java/com/vonage/client/HttpWrapperTest.java index 258e0f4c4..257abf8a2 100644 --- a/src/test/java/com/vonage/client/HttpWrapperTest.java +++ b/src/test/java/com/vonage/client/HttpWrapperTest.java @@ -28,34 +28,32 @@ public class HttpWrapperTest { private static final String EXPECTED_DEFAULT_REST_BASE_URI = "https://rest.nexmo.com"; private static final String EXPECTED_DEFAULT_SNS_BASE_URI = "https://sns.nexmo.com"; - private HttpWrapper hw; + private HttpWrapper wrapper; @Before public void setUp() { - this.hw = new HttpWrapper(new AuthCollection()); + wrapper = new HttpWrapper(new AuthCollection()); } @Test public void basicTest() { - assertNotNull(this.hw.getHttpClient()); + assertNotNull(wrapper.getHttpClient()); } @Test public void testAuthMethodAccessors() { AuthCollection auths = new AuthCollection(); - this.hw.setAuthCollection(auths); - assertEquals(auths, this.hw.getAuthCollection()); + wrapper.setAuthCollection(auths); + assertEquals(auths, wrapper.getAuthCollection()); } @Test public void testHttpConfigAccessor() { - assertNotNull(this.hw.getHttpConfig()); + assertNotNull(wrapper.getHttpConfig()); } @Test public void testDefaultConstructorSetsDefaultConfigValues() { - HttpWrapper wrapper = new HttpWrapper(); - HttpConfig config = wrapper.getHttpConfig(); assertEquals(EXPECTED_DEFAULT_API_BASE_URI, config.getApiBaseUri()); assertEquals(EXPECTED_DEFAULT_REST_BASE_URI, config.getRestBaseUri()); diff --git a/src/test/java/com/vonage/client/account/AccountClientTest.java b/src/test/java/com/vonage/client/account/AccountClientTest.java index 87464ea4f..3c91115ef 100644 --- a/src/test/java/com/vonage/client/account/AccountClientTest.java +++ b/src/test/java/com/vonage/client/account/AccountClientTest.java @@ -19,7 +19,6 @@ import com.vonage.client.HttpWrapper; import com.vonage.client.VonageClientException; import com.vonage.client.auth.TokenAuthMethod; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -47,7 +46,7 @@ public void setUp() throws Exception { public void testGetBalance() throws Exception { BalanceResponse response = client.getBalance(); verify(client.balance).execute(); - Assert.assertEquals(sentinel, response); + assertEquals(sentinel, response); } @Test @@ -62,34 +61,34 @@ public void testGetSmsPrice() throws Exception { + " \"currency\": \"EUR\",\n" + " \"mcc\": \"123\",\n" + " \"mnc\": \"456\",\n" + " \"networkCode\": \"networkcode\",\n" + " \"networkName\": \"Test Landline\"\n" + " } \n" + " ]\n" + "}\n"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); PricingResponse response = client.getSmsPrice("US"); - Assert.assertEquals("1", response.getDialingPrefix()); - Assert.assertEquals(new BigDecimal("0.00570000"), response.getDefaultPrice()); - Assert.assertEquals("EUR", response.getCurrency()); - Assert.assertEquals("United States of America", response.getCountry().getDisplayName()); - Assert.assertEquals("US", response.getCountry().getCode()); - Assert.assertEquals("United States", response.getCountry().getName()); - - Assert.assertEquals(2, response.getNetworks().size()); + assertEquals("1", response.getDialingPrefix()); + assertEquals(new BigDecimal("0.00570000"), response.getDefaultPrice()); + assertEquals("EUR", response.getCurrency()); + assertEquals("United States of America", response.getCountry().getDisplayName()); + assertEquals("US", response.getCountry().getCode()); + assertEquals("United States", response.getCountry().getName()); + + assertEquals(2, response.getNetworks().size()); Network first = response.getNetworks().get(0); - Assert.assertEquals(Network.Type.MOBILE, first.getType()); - Assert.assertEquals(new BigDecimal("0.00570000"), first.getPrice()); - Assert.assertEquals("EUR", first.getCurrency()); - Assert.assertEquals("987", first.getMcc()); - Assert.assertEquals("123", first.getMnc()); - Assert.assertEquals("123456", first.getCode()); - Assert.assertEquals("Test Mobile", first.getName()); + assertEquals(Network.Type.MOBILE, first.getType()); + assertEquals(new BigDecimal("0.00570000"), first.getPrice()); + assertEquals("EUR", first.getCurrency()); + assertEquals("987", first.getMcc()); + assertEquals("123", first.getMnc()); + assertEquals("123456", first.getCode()); + assertEquals("Test Mobile", first.getName()); Network second = response.getNetworks().get(1); - Assert.assertEquals(Network.Type.LANDLINE, second.getType()); - Assert.assertEquals(new BigDecimal("0.00330000"), second.getPrice()); - Assert.assertEquals("EUR", second.getCurrency()); - Assert.assertEquals("123", second.getMcc()); - Assert.assertEquals("456", second.getMnc()); - Assert.assertEquals("networkcode", second.getCode()); - Assert.assertEquals("Test Landline", second.getName()); + assertEquals(Network.Type.LANDLINE, second.getType()); + assertEquals(new BigDecimal("0.00330000"), second.getPrice()); + assertEquals("EUR", second.getCurrency()); + assertEquals("123", second.getMcc()); + assertEquals("456", second.getMnc()); + assertEquals("networkcode", second.getCode()); + assertEquals("Test Landline", second.getName()); } @Test @@ -104,34 +103,34 @@ public void testGetVoicePrice() throws Exception { + " \"currency\": \"EUR\",\n" + " \"mcc\": \"123\",\n" + " \"mnc\": \"456\",\n" + " \"networkCode\": \"networkcode\",\n" + " \"networkName\": \"Test Landline\"\n" + " } \n" + " ]\n" + "}\n"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); PricingResponse response = client.getVoicePrice("US"); - Assert.assertEquals("1", response.getDialingPrefix()); - Assert.assertEquals(new BigDecimal("0.00570000"), response.getDefaultPrice()); - Assert.assertEquals("EUR", response.getCurrency()); - Assert.assertEquals("United States of America", response.getCountry().getDisplayName()); - Assert.assertEquals("US", response.getCountry().getCode()); - Assert.assertEquals("United States", response.getCountry().getName()); - - Assert.assertEquals(2, response.getNetworks().size()); + assertEquals("1", response.getDialingPrefix()); + assertEquals(new BigDecimal("0.00570000"), response.getDefaultPrice()); + assertEquals("EUR", response.getCurrency()); + assertEquals("United States of America", response.getCountry().getDisplayName()); + assertEquals("US", response.getCountry().getCode()); + assertEquals("United States", response.getCountry().getName()); + + assertEquals(2, response.getNetworks().size()); Network first = response.getNetworks().get(0); - Assert.assertEquals(Network.Type.MOBILE, first.getType()); - Assert.assertEquals(new BigDecimal("0.00570000"), first.getPrice()); - Assert.assertEquals("EUR", first.getCurrency()); - Assert.assertEquals("987", first.getMcc()); - Assert.assertEquals("123", first.getMnc()); - Assert.assertEquals("123456", first.getCode()); - Assert.assertEquals("Test Mobile", first.getName()); + assertEquals(Network.Type.MOBILE, first.getType()); + assertEquals(new BigDecimal("0.00570000"), first.getPrice()); + assertEquals("EUR", first.getCurrency()); + assertEquals("987", first.getMcc()); + assertEquals("123", first.getMnc()); + assertEquals("123456", first.getCode()); + assertEquals("Test Mobile", first.getName()); Network second = response.getNetworks().get(1); - Assert.assertEquals(Network.Type.LANDLINE, second.getType()); - Assert.assertEquals(new BigDecimal("0.00330000"), second.getPrice()); - Assert.assertEquals("EUR", second.getCurrency()); - Assert.assertEquals("123", second.getMcc()); - Assert.assertEquals("456", second.getMnc()); - Assert.assertEquals("networkcode", second.getCode()); - Assert.assertEquals("Test Landline", second.getName()); + assertEquals(Network.Type.LANDLINE, second.getType()); + assertEquals(new BigDecimal("0.00330000"), second.getPrice()); + assertEquals("EUR", second.getCurrency()); + assertEquals("123", second.getMcc()); + assertEquals("456", second.getMnc()); + assertEquals("networkcode", second.getCode()); + assertEquals("Test Landline", second.getName()); } @Test @@ -157,43 +156,43 @@ public void testGetPrefixVoicePrice() throws Exception { + " \"countryCode\": \"UM\",\n" + " \"countryName\": \"United States Minor Outlying Islands\"\n" + " }\n" + " ]\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); PrefixPricingResponse response = client.getPrefixPrice(ServiceType.VOICE, "1"); - Assert.assertEquals(2, response.getCount()); - Assert.assertEquals(2, response.getCountries().size()); + assertEquals(2, response.getCount()); + assertEquals(2, response.getCountries().size()); PricingResponse firstResponse = response.getCountries().get(0); - Assert.assertEquals("1", firstResponse.getDialingPrefix()); - Assert.assertEquals(new BigDecimal("0.01270000"), firstResponse.getDefaultPrice()); - Assert.assertEquals("EUR", firstResponse.getCurrency()); - Assert.assertEquals("Canada", firstResponse.getCountry().getDisplayName()); - Assert.assertEquals("CA", firstResponse.getCountry().getCode()); - Assert.assertEquals("Canada", firstResponse.getCountry().getName()); - - Assert.assertEquals(2, firstResponse.getNetworks().size()); + assertEquals("1", firstResponse.getDialingPrefix()); + assertEquals(new BigDecimal("0.01270000"), firstResponse.getDefaultPrice()); + assertEquals("EUR", firstResponse.getCurrency()); + assertEquals("Canada", firstResponse.getCountry().getDisplayName()); + assertEquals("CA", firstResponse.getCountry().getCode()); + assertEquals("Canada", firstResponse.getCountry().getName()); + + assertEquals(2, firstResponse.getNetworks().size()); Network firstResponseFirstNetwork = firstResponse.getNetworks().get(0); - Assert.assertEquals(Network.Type.MOBILE, firstResponseFirstNetwork.getType()); - Assert.assertEquals(new BigDecimal("0.01280000"), firstResponseFirstNetwork.getPrice()); - Assert.assertEquals("EUR", firstResponseFirstNetwork.getCurrency()); - Assert.assertEquals("302", firstResponseFirstNetwork.getMcc()); - Assert.assertEquals("702", firstResponseFirstNetwork.getMnc()); - Assert.assertEquals("302702", firstResponseFirstNetwork.getCode()); - Assert.assertEquals("BELL ALIANT REGIONAL Communications LP", firstResponseFirstNetwork.getName()); + assertEquals(Network.Type.MOBILE, firstResponseFirstNetwork.getType()); + assertEquals(new BigDecimal("0.01280000"), firstResponseFirstNetwork.getPrice()); + assertEquals("EUR", firstResponseFirstNetwork.getCurrency()); + assertEquals("302", firstResponseFirstNetwork.getMcc()); + assertEquals("702", firstResponseFirstNetwork.getMnc()); + assertEquals("302702", firstResponseFirstNetwork.getCode()); + assertEquals("BELL ALIANT REGIONAL Communications LP", firstResponseFirstNetwork.getName()); Network firstResponseSecondNetwork = firstResponse.getNetworks().get(1); - Assert.assertEquals(Network.Type.LANDLINE, firstResponseSecondNetwork.getType()); - Assert.assertEquals(new BigDecimal("0.01000000"), firstResponseSecondNetwork.getPrice()); - Assert.assertEquals("EUR", firstResponseSecondNetwork.getCurrency()); - Assert.assertEquals("CA-FIXED", firstResponseSecondNetwork.getCode()); - Assert.assertEquals("Canada Landline", firstResponseSecondNetwork.getName()); + assertEquals(Network.Type.LANDLINE, firstResponseSecondNetwork.getType()); + assertEquals(new BigDecimal("0.01000000"), firstResponseSecondNetwork.getPrice()); + assertEquals("EUR", firstResponseSecondNetwork.getCurrency()); + assertEquals("CA-FIXED", firstResponseSecondNetwork.getCode()); + assertEquals("Canada Landline", firstResponseSecondNetwork.getName()); PricingResponse secondResponse = response.getCountries().get(1); - Assert.assertEquals("1", secondResponse.getDialingPrefix()); - Assert.assertEquals("EUR", secondResponse.getCurrency()); - Assert.assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getDisplayName()); - Assert.assertEquals("UM", secondResponse.getCountry().getCode()); - Assert.assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getName()); + assertEquals("1", secondResponse.getDialingPrefix()); + assertEquals("EUR", secondResponse.getCurrency()); + assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getDisplayName()); + assertEquals("UM", secondResponse.getCountry().getCode()); + assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getName()); } @Test @@ -215,40 +214,40 @@ public void testGetPrefixSmsPrice() throws Exception { + " \"countryCode\": \"UM\",\n" + " \"countryName\": \"United States Minor Outlying Islands\"\n" + " }\n" + " ]\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); PrefixPricingResponse response = client.getPrefixPrice(ServiceType.SMS, "1"); - Assert.assertEquals(2, response.getCount()); - Assert.assertEquals(2, response.getCountries().size()); + assertEquals(2, response.getCount()); + assertEquals(2, response.getCountries().size()); PricingResponse firstResponse = response.getCountries().get(0); - Assert.assertEquals("1", firstResponse.getDialingPrefix()); - Assert.assertEquals(new BigDecimal("0.00570000"), firstResponse.getDefaultPrice()); - Assert.assertEquals("EUR", firstResponse.getCurrency()); - Assert.assertEquals("Canada", firstResponse.getCountry().getDisplayName()); - Assert.assertEquals("CA", firstResponse.getCountry().getCode()); - Assert.assertEquals("Canada", firstResponse.getCountry().getName()); - - Assert.assertEquals(1, firstResponse.getNetworks().size()); + assertEquals("1", firstResponse.getDialingPrefix()); + assertEquals(new BigDecimal("0.00570000"), firstResponse.getDefaultPrice()); + assertEquals("EUR", firstResponse.getCurrency()); + assertEquals("Canada", firstResponse.getCountry().getDisplayName()); + assertEquals("CA", firstResponse.getCountry().getCode()); + assertEquals("Canada", firstResponse.getCountry().getName()); + + assertEquals(1, firstResponse.getNetworks().size()); Network network = firstResponse.getNetworks().get(0); - Assert.assertEquals(Network.Type.MOBILE, network.getType()); - Assert.assertEquals(new BigDecimal("0.00570000"), network.getPrice()); - Assert.assertEquals("EUR", network.getCurrency()); - Assert.assertEquals("302", network.getMcc()); - Assert.assertEquals("655", network.getMnc()); - Assert.assertEquals("302655", network.getCode()); - Assert.assertEquals("MTS Communications Inc.", network.getName()); + assertEquals(Network.Type.MOBILE, network.getType()); + assertEquals(new BigDecimal("0.00570000"), network.getPrice()); + assertEquals("EUR", network.getCurrency()); + assertEquals("302", network.getMcc()); + assertEquals("655", network.getMnc()); + assertEquals("302655", network.getCode()); + assertEquals("MTS Communications Inc.", network.getName()); PricingResponse secondResponse = response.getCountries().get(1); - Assert.assertEquals("1", secondResponse.getDialingPrefix()); - Assert.assertEquals("EUR", secondResponse.getCurrency()); - Assert.assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getDisplayName()); - Assert.assertEquals("UM", secondResponse.getCountry().getCode()); - Assert.assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getName()); + assertEquals("1", secondResponse.getDialingPrefix()); + assertEquals("EUR", secondResponse.getCurrency()); + assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getDisplayName()); + assertEquals("UM", secondResponse.getCountry().getCode()); + assertEquals("United States Minor Outlying Islands", secondResponse.getCountry().getName()); } @Test public void testTopUpSuccessful() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, "")); + wrapper.setHttpClient(stubHttpClient(200, "")); // No assertions as an exception will be thrown if failure occurs. client.topUp("ABC123"); } @@ -256,14 +255,14 @@ public void testTopUpSuccessful() throws Exception { @Test(expected = VonageClientException.class) public void testTopUpFailedAuth() throws Exception { String json = "{\"error-code\":\"401\",\"error-code-label\":\"authentication failed\"}"; - wrapper.setHttpClient(this.stubHttpClient(401, json)); + wrapper.setHttpClient(stubHttpClient(401, json)); client.topUp("ABC123"); } @Test(expected = VonageClientException.class) public void testTopUpFailed() throws Exception { String json = "{\"error-code\":\"420\",\"error-code-label\":\"topup failed\"}"; - wrapper.setHttpClient(this.stubHttpClient(401, json)); + wrapper.setHttpClient(stubHttpClient(401, json)); client.topUp("ABC123"); } @@ -281,7 +280,7 @@ public void testListSecretSuccessful() throws Exception { + " }\n" + " },\n" + " \"id\": \"secret-id-two\",\n" + " \"created_at\": \"2016-01-20T16:34:49Z\"\n" + " }\n" + " ]\n" + " }\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); ListSecretsResponse response = client.listSecrets("abcd1234"); SecretResponse[] responses = response.getSecrets().toArray(new SecretResponse[0]); @@ -304,7 +303,7 @@ public void testListSecretFailedAuth() throws Exception { + " \"title\": \"Invalid credentials supplied\",\n" + " \"detail\": \"You did not provide correct credentials.\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(401, json)); + wrapper.setHttpClient(stubHttpClient(401, json)); client.listSecrets("ABC123"); } @@ -314,7 +313,7 @@ public void testListSecretNotFound() throws Exception { + " \"title\": \"Invalid API Key\",\n" + " \"detail\": \"API key 'ABC123' does not exist, or you do not have access\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(404, json)); + wrapper.setHttpClient(stubHttpClient(404, json)); client.listSecrets("ABC123"); } @@ -323,7 +322,7 @@ public void testCreateSecretSuccessful() throws Exception { String json = "{\n" + " \"_links\": {\n" + " \"self\": {\n" + " \"href\": \"/accounts/abcd1234/secrets/secret-id-one\"\n" + " }\n" + " },\n" + " \"id\": \"secret-id-one\",\n" + " \"created_at\": \"2017-03-02T16:34:49Z\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(201, json)); + wrapper.setHttpClient(stubHttpClient(201, json)); SecretResponse response = client.createSecret("apiKey", "secret"); @@ -343,7 +342,7 @@ public void testCreateSecretBadRequest() throws Exception { + " \"invalid_parameters\": [\n" + " {\n" + " \"name\": \"secret\",\n" + " \"reason\": \"Does not meet complexity requirements\"\n" + " }\n" + " ],\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(400, json)); + wrapper.setHttpClient(stubHttpClient(400, json)); client.createSecret("key", "secret"); } @@ -353,7 +352,7 @@ public void testCreateSecretFailedAuth() throws Exception { + " \"title\": \"Invalid credentials supplied\",\n" + " \"detail\": \"You did not provide correct credentials.\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(401, json)); + wrapper.setHttpClient(stubHttpClient(401, json)); client.createSecret("key", "secret"); } @@ -364,7 +363,7 @@ public void testCreateSecretMaxSecrets() throws Exception { + " \"title\": \"Maxmimum number of secrets already met\",\n" + " \"detail\": \"This account has reached maximum number of '2' allowed secrets\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(403, json)); + wrapper.setHttpClient(stubHttpClient(403, json)); client.createSecret("key", "secret"); } @@ -374,7 +373,7 @@ public void testCreateSecretAccountNotFound() throws Exception { + " \"title\": \"Invalid API Key\",\n" + " \"detail\": \"API key 'ABC123' does not exist, or you do not have access\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(404, json)); + wrapper.setHttpClient(stubHttpClient(404, json)); client.createSecret("key", "secret"); } @@ -383,7 +382,7 @@ public void testGetSecretSuccessful() throws Exception { String json = "{\n" + " \"_links\": {\n" + " \"self\": {\n" + " \"href\": \"/accounts/abcd1234/secrets/secret-id-one\"\n" + " }\n" + " },\n" + " \"id\": \"secret-id-one\",\n" + " \"created_at\": \"2017-03-02T16:34:49Z\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SecretResponse response = client.getSecret("apiKey", "secret-id-one"); @@ -400,7 +399,7 @@ public void testGetSecretFailedAuth() throws Exception { + " \"title\": \"Invalid credentials supplied\",\n" + " \"detail\": \"You did not provide correct credentials.\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(401, json)); + wrapper.setHttpClient(stubHttpClient(401, json)); client.getSecret("apiKey", "secret-id-one"); } @@ -410,13 +409,13 @@ public void testGetSecretNotFound() throws Exception { + " \"title\": \"Invalid API Key\",\n" + " \"detail\": \"API key 'ABC123' does not exist, or you do not have access\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(404, json)); + wrapper.setHttpClient(stubHttpClient(404, json)); client.getSecret("apiKey", "secret-id-one"); } @Test public void testRevokeSecretSuccessful() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(204, "")); + wrapper.setHttpClient(stubHttpClient(204, "")); // No assertions as an exception will be thrown if failure occurs. client.revokeSecret("apiKey", "secretId"); } @@ -427,7 +426,7 @@ public void testRevokeSecretFailedAuth() throws Exception { + " \"title\": \"Invalid credentials supplied\",\n" + " \"detail\": \"You did not provide correct credentials.\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(401, json)); + wrapper.setHttpClient(stubHttpClient(401, json)); client.revokeSecret("apiKey", "secret-id-one"); } @@ -438,7 +437,7 @@ public void testRevokeSecretForbidden() throws Exception { + " \"title\": \"Secret Deletion Forbidden\",\n" + " \"detail\": \"Can not delete the last secret. The account must always have at least 1 secret active at any time\",\n" + " \"instance\": \"797a8f199c45014ab7b08bfe9cc1c12c\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(403, json)); + wrapper.setHttpClient(stubHttpClient(403, json)); client.revokeSecret("apiKey", "secret-id-one"); } @@ -451,14 +450,14 @@ public void testUpdateIncomingSmsUrl() throws Exception { " \"max-inbound-request\": 20,\n" + " \"max-calls-per-second\": 30\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SettingsResponse response = client.updateSmsIncomingUrl("https://example.com/webhooks/inbound-sms"); - Assert.assertEquals("https://example.com/webhooks/inbound-sms", response.getIncomingSmsUrl()); - Assert.assertEquals("https://example.com/webhooks/delivery-receipt", response.getDeliveryReceiptUrl()); - Assert.assertEquals(Integer.valueOf(30), response.getMaxApiCallsPerSecond()); - Assert.assertEquals(Integer.valueOf(20), response.getMaxInboundMessagesPerSecond()); - Assert.assertEquals(Integer.valueOf(10), response.getMaxOutboundMessagesPerSecond()); + assertEquals("https://example.com/webhooks/inbound-sms", response.getIncomingSmsUrl()); + assertEquals("https://example.com/webhooks/delivery-receipt", response.getDeliveryReceiptUrl()); + assertEquals(Integer.valueOf(30), response.getMaxApiCallsPerSecond()); + assertEquals(Integer.valueOf(20), response.getMaxInboundMessagesPerSecond()); + assertEquals(Integer.valueOf(10), response.getMaxOutboundMessagesPerSecond()); } @Test @@ -470,14 +469,14 @@ public void testUpdateDeliveryReceiptUrl() throws Exception { " \"max-inbound-request\": 20,\n" + " \"max-calls-per-second\": 30\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SettingsResponse response = client.updateDeliveryReceiptUrl("https://example.com/webhooks/delivery-receipt"); - Assert.assertEquals("https://example.com/webhooks/inbound-sms", response.getIncomingSmsUrl()); - Assert.assertEquals("https://example.com/webhooks/delivery-receipt", response.getDeliveryReceiptUrl()); - Assert.assertEquals(Integer.valueOf(30), response.getMaxApiCallsPerSecond()); - Assert.assertEquals(Integer.valueOf(20), response.getMaxInboundMessagesPerSecond()); - Assert.assertEquals(Integer.valueOf(10), response.getMaxOutboundMessagesPerSecond()); + assertEquals("https://example.com/webhooks/inbound-sms", response.getIncomingSmsUrl()); + assertEquals("https://example.com/webhooks/delivery-receipt", response.getDeliveryReceiptUrl()); + assertEquals(Integer.valueOf(30), response.getMaxApiCallsPerSecond()); + assertEquals(Integer.valueOf(20), response.getMaxInboundMessagesPerSecond()); + assertEquals(Integer.valueOf(10), response.getMaxOutboundMessagesPerSecond()); } @Test @@ -490,13 +489,13 @@ public void testUpdatingAccountSettings() throws Exception { " \"max-calls-per-second\": 30\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SettingsResponse response = client.updateSettings(new SettingsRequest("https://example.com/webhooks/inbound-sms", "https://example.com/webhooks/delivery-receipt")); - Assert.assertEquals("https://example.com/webhooks/inbound-sms", response.getIncomingSmsUrl()); - Assert.assertEquals("https://example.com/webhooks/delivery-receipt", response.getDeliveryReceiptUrl()); - Assert.assertEquals(Integer.valueOf(30), response.getMaxApiCallsPerSecond()); - Assert.assertEquals(Integer.valueOf(20), response.getMaxInboundMessagesPerSecond()); - Assert.assertEquals(Integer.valueOf(10), response.getMaxOutboundMessagesPerSecond()); + assertEquals("https://example.com/webhooks/inbound-sms", response.getIncomingSmsUrl()); + assertEquals("https://example.com/webhooks/delivery-receipt", response.getDeliveryReceiptUrl()); + assertEquals(Integer.valueOf(30), response.getMaxApiCallsPerSecond()); + assertEquals(Integer.valueOf(20), response.getMaxInboundMessagesPerSecond()); + assertEquals(Integer.valueOf(10), response.getMaxOutboundMessagesPerSecond()); } } diff --git a/src/test/java/com/vonage/client/account/BalanceEndpointTest.java b/src/test/java/com/vonage/client/account/BalanceEndpointTest.java index f8a472840..25c459e02 100644 --- a/src/test/java/com/vonage/client/account/BalanceEndpointTest.java +++ b/src/test/java/com/vonage/client/account/BalanceEndpointTest.java @@ -34,19 +34,19 @@ public class BalanceEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new BalanceEndpoint(new HttpWrapper()); + endpoint = new BalanceEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{TokenAuthMethod.class}, auths); } @Test public void testMakeRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(null); + RequestBuilder builder = endpoint.makeRequest(null); assertEquals("GET", builder.getMethod()); assertEquals("https://rest.nexmo.com/account/get-balance", builder.build().getURI().toString()); Map params = TestUtils.makeParameterMap(builder.getParameters()); @@ -70,7 +70,7 @@ public void testParseResponse() throws Exception { " \"value\": 3.14159,\n" + " \"autoReload\": false\n" + "}}"); - BalanceResponse response = this.endpoint.parseResponse(stub); + BalanceResponse response = endpoint.parseResponse(stub); assertEquals(3.14159, response.getValue(), 0.00001); assertFalse(response.isAutoReload()); } diff --git a/src/test/java/com/vonage/client/account/CreateSecretMethodTest.java b/src/test/java/com/vonage/client/account/CreateSecretMethodTest.java index c4c5cf9d5..c80254e6f 100644 --- a/src/test/java/com/vonage/client/account/CreateSecretMethodTest.java +++ b/src/test/java/com/vonage/client/account/CreateSecretMethodTest.java @@ -31,7 +31,7 @@ public class CreateSecretMethodTest { @Before public void setUp() { - this.method = new CreateSecretMethod(new HttpWrapper()); + method = new CreateSecretMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/account/GetSecretMethodTest.java b/src/test/java/com/vonage/client/account/GetSecretMethodTest.java index b590cdcc1..07c27f476 100644 --- a/src/test/java/com/vonage/client/account/GetSecretMethodTest.java +++ b/src/test/java/com/vonage/client/account/GetSecretMethodTest.java @@ -28,7 +28,7 @@ public class GetSecretMethodTest { @Before public void setUp() { - this.method = new GetSecretMethod(new HttpWrapper()); + method = new GetSecretMethod(new HttpWrapper()); } @Test(expected = IllegalArgumentException.class) diff --git a/src/test/java/com/vonage/client/account/ListSecretsMethodTest.java b/src/test/java/com/vonage/client/account/ListSecretsMethodTest.java index da79ca335..8b2a2ce39 100644 --- a/src/test/java/com/vonage/client/account/ListSecretsMethodTest.java +++ b/src/test/java/com/vonage/client/account/ListSecretsMethodTest.java @@ -28,7 +28,7 @@ public class ListSecretsMethodTest { @Before public void setUp() throws Exception { - this.method = new ListSecretsMethod(new HttpWrapper()); + method = new ListSecretsMethod(new HttpWrapper()); } @Test(expected = IllegalArgumentException.class) diff --git a/src/test/java/com/vonage/client/account/PrefixPricingMethodTest.java b/src/test/java/com/vonage/client/account/PrefixPricingMethodTest.java index 6d7e438c2..b0b70a6be 100644 --- a/src/test/java/com/vonage/client/account/PrefixPricingMethodTest.java +++ b/src/test/java/com/vonage/client/account/PrefixPricingMethodTest.java @@ -28,7 +28,7 @@ public class PrefixPricingMethodTest { @Before public void setUp() { - this.method = new PrefixPricingMethod(new HttpWrapper()); + method = new PrefixPricingMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/account/RevokeSecretMethodTest.java b/src/test/java/com/vonage/client/account/RevokeSecretMethodTest.java index e6eac9ff2..b157f295c 100644 --- a/src/test/java/com/vonage/client/account/RevokeSecretMethodTest.java +++ b/src/test/java/com/vonage/client/account/RevokeSecretMethodTest.java @@ -28,7 +28,7 @@ public class RevokeSecretMethodTest { @Before public void setUp() { - this.method = new RevokeSecretMethod(new HttpWrapper()); + method = new RevokeSecretMethod(new HttpWrapper()); } @Test(expected = IllegalArgumentException.class) diff --git a/src/test/java/com/vonage/client/account/SettingsMethodTest.java b/src/test/java/com/vonage/client/account/SettingsMethodTest.java index 11989ed2f..88b438c4f 100644 --- a/src/test/java/com/vonage/client/account/SettingsMethodTest.java +++ b/src/test/java/com/vonage/client/account/SettingsMethodTest.java @@ -32,7 +32,7 @@ public class SettingsMethodTest { @Before public void setUp() throws Exception { - this.method = new SettingsMethod(new HttpWrapper()); + method = new SettingsMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/account/SmsPricingMethodTest.java b/src/test/java/com/vonage/client/account/SmsPricingMethodTest.java index 43cdda9e1..105324763 100644 --- a/src/test/java/com/vonage/client/account/SmsPricingMethodTest.java +++ b/src/test/java/com/vonage/client/account/SmsPricingMethodTest.java @@ -28,7 +28,7 @@ public class SmsPricingMethodTest { @Before public void setUp() { - this.method = new SmsPricingMethod(new HttpWrapper()); + method = new SmsPricingMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/account/TopUpMethodTest.java b/src/test/java/com/vonage/client/account/TopUpMethodTest.java index 4824167aa..fce515490 100644 --- a/src/test/java/com/vonage/client/account/TopUpMethodTest.java +++ b/src/test/java/com/vonage/client/account/TopUpMethodTest.java @@ -28,7 +28,7 @@ public class TopUpMethodTest { @Before public void setUp() throws Exception { - this.method = new TopUpMethod(new HttpWrapper()); + method = new TopUpMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/account/VoicePricingMethodTest.java b/src/test/java/com/vonage/client/account/VoicePricingMethodTest.java index bbf630152..01a20c6a2 100644 --- a/src/test/java/com/vonage/client/account/VoicePricingMethodTest.java +++ b/src/test/java/com/vonage/client/account/VoicePricingMethodTest.java @@ -28,7 +28,7 @@ public class VoicePricingMethodTest { @Before public void setUp() throws Exception { - this.method = new VoicePricingMethod(new HttpWrapper()); + method = new VoicePricingMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/application/AppBasicAuthTest.java b/src/test/java/com/vonage/client/application/ApplicationMethodTest.java similarity index 96% rename from src/test/java/com/vonage/client/application/AppBasicAuthTest.java rename to src/test/java/com/vonage/client/application/ApplicationMethodTest.java index 0facbe252..9a283767d 100644 --- a/src/test/java/com/vonage/client/application/AppBasicAuthTest.java +++ b/src/test/java/com/vonage/client/application/ApplicationMethodTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; -public abstract class AppBasicAuthTest { +public abstract class ApplicationMethodTest { @Test public void testApplyAuth() throws Exception { diff --git a/src/test/java/com/vonage/client/application/CreateApplicationMethodTest.java b/src/test/java/com/vonage/client/application/CreateApplicationMethodTest.java index c4b857517..ad953536f 100644 --- a/src/test/java/com/vonage/client/application/CreateApplicationMethodTest.java +++ b/src/test/java/com/vonage/client/application/CreateApplicationMethodTest.java @@ -17,14 +17,13 @@ import com.vonage.client.HttpConfig; import com.vonage.client.HttpWrapper; -import com.vonage.client.auth.TokenAuthMethod; import org.apache.http.client.methods.RequestBuilder; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CreateApplicationMethodTest extends AppBasicAuthTest { +public class CreateApplicationMethodTest extends ApplicationMethodTest { private CreateApplicationMethod method; @Before diff --git a/src/test/java/com/vonage/client/application/DeleteApplicationMethodTest.java b/src/test/java/com/vonage/client/application/DeleteApplicationMethodTest.java index 37f3568d8..7f084ff5d 100644 --- a/src/test/java/com/vonage/client/application/DeleteApplicationMethodTest.java +++ b/src/test/java/com/vonage/client/application/DeleteApplicationMethodTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; -public class DeleteApplicationMethodTest extends AppBasicAuthTest { +public class DeleteApplicationMethodTest extends ApplicationMethodTest { private DeleteApplicationMethod method; @Before diff --git a/src/test/java/com/vonage/client/application/GetApplicationMethodTest.java b/src/test/java/com/vonage/client/application/GetApplicationMethodTest.java index 7db57f1f6..91e172f87 100644 --- a/src/test/java/com/vonage/client/application/GetApplicationMethodTest.java +++ b/src/test/java/com/vonage/client/application/GetApplicationMethodTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; -public class GetApplicationMethodTest extends AppBasicAuthTest { +public class GetApplicationMethodTest extends ApplicationMethodTest { private GetApplicationMethod method; @Before diff --git a/src/test/java/com/vonage/client/application/ListApplicationsMethodTest.java b/src/test/java/com/vonage/client/application/ListApplicationsMethodTest.java index aa771b046..8d1575e00 100644 --- a/src/test/java/com/vonage/client/application/ListApplicationsMethodTest.java +++ b/src/test/java/com/vonage/client/application/ListApplicationsMethodTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; -public class ListApplicationsMethodTest extends AppBasicAuthTest { +public class ListApplicationsMethodTest extends ApplicationMethodTest { private ListApplicationsMethod method; @Before diff --git a/src/test/java/com/vonage/client/application/UpdateApplicationMethodTest.java b/src/test/java/com/vonage/client/application/UpdateApplicationMethodTest.java index fd242cc92..9dfbefee2 100644 --- a/src/test/java/com/vonage/client/application/UpdateApplicationMethodTest.java +++ b/src/test/java/com/vonage/client/application/UpdateApplicationMethodTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; -public class UpdateApplicationMethodTest extends AppBasicAuthTest { +public class UpdateApplicationMethodTest extends ApplicationMethodTest { private UpdateApplicationMethod method; @Before diff --git a/src/test/java/com/vonage/client/conversion/ConversionMethodTest.java b/src/test/java/com/vonage/client/conversion/ConversionMethodTest.java index f554a05d9..0d5ab5c3d 100644 --- a/src/test/java/com/vonage/client/conversion/ConversionMethodTest.java +++ b/src/test/java/com/vonage/client/conversion/ConversionMethodTest.java @@ -34,7 +34,7 @@ public class ConversionMethodTest { @Before public void setUp() throws Exception { - this.method = new ConversionMethod(new HttpWrapper()); + method = new ConversionMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/insight/AdvancedInsightEndpointTest.java b/src/test/java/com/vonage/client/insight/AdvancedInsightEndpointTest.java index f5ab8d786..e626101e7 100644 --- a/src/test/java/com/vonage/client/insight/AdvancedInsightEndpointTest.java +++ b/src/test/java/com/vonage/client/insight/AdvancedInsightEndpointTest.java @@ -34,18 +34,18 @@ public class AdvancedInsightEndpointTest { @Before public void setUp() { - this.endpoint = new AdvancedInsightEndpoint(new HttpWrapper()); + endpoint = new AdvancedInsightEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() throws Exception { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{SignatureAuthMethod.class, TokenAuthMethod.class}, auths); } @Test public void testMakeRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(AdvancedInsightRequest.builder("1234").build()); + RequestBuilder builder = endpoint.makeRequest(AdvancedInsightRequest.builder("1234").build()); assertEquals("POST", builder.getMethod()); assertEquals("https://api.nexmo.com/ni/advanced/json", builder.build().getURI().toString()); Map params = TestUtils.makeParameterMap(builder.getParameters()); @@ -57,7 +57,7 @@ public void testMakeRequest() throws Exception { @Test public void testMakeRequestWithCountry() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(AdvancedInsightRequest.builder("1234") + RequestBuilder builder = endpoint.makeRequest(AdvancedInsightRequest.builder("1234") .country("GB") .build()); assertEquals("POST", builder.getMethod()); @@ -71,7 +71,7 @@ public void testMakeRequestWithCountry() throws Exception { @Test public void testMakeRequestWithIpAddress() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(AdvancedInsightRequest.builder("1234") + RequestBuilder builder = endpoint.makeRequest(AdvancedInsightRequest.builder("1234") .ipAddress("123.123.123.123") .build()); @@ -86,7 +86,7 @@ public void testMakeRequestWithIpAddress() throws Exception { @Test public void testMakeRequestWithCnam() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(AdvancedInsightRequest.builder("1234") + RequestBuilder builder = endpoint.makeRequest(AdvancedInsightRequest.builder("1234") .cnam(true) .build()); assertEquals("POST", builder.getMethod()); @@ -100,7 +100,7 @@ public void testMakeRequestWithCnam() throws Exception { @Test public void testMakeAsyncRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(AdvancedInsightRequest.builder("1234") + RequestBuilder builder = endpoint.makeRequest(AdvancedInsightRequest.builder("1234") .async(true) .callback("https://example.com") .build()); @@ -135,7 +135,7 @@ public void testParseResponse() throws Exception { + " \"reachable\": \"unknown\",\n" + " \"ported\": \"assumed_not_ported\",\n" + " \"roaming\": {\"status\": \"not_roaming\"}\n" + "}" ); - AdvancedInsightResponse response = this.endpoint.parseResponse(stub); + AdvancedInsightResponse response = endpoint.parseResponse(stub); assertEquals("0c082a69-85df-4bbc-aae6-ee998e17e5a4", response.getRequestId()); } diff --git a/src/test/java/com/vonage/client/insight/BasicInsightEndpointTest.java b/src/test/java/com/vonage/client/insight/BasicInsightEndpointTest.java index 10afe38cc..8f378c65b 100644 --- a/src/test/java/com/vonage/client/insight/BasicInsightEndpointTest.java +++ b/src/test/java/com/vonage/client/insight/BasicInsightEndpointTest.java @@ -34,18 +34,18 @@ public class BasicInsightEndpointTest { @Before public void setUp() { - this.endpoint = new BasicInsightEndpoint(new HttpWrapper()); + endpoint = new BasicInsightEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() throws Exception { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{SignatureAuthMethod.class, TokenAuthMethod.class}, auths); } @Test public void testMakeRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(BasicInsightRequest.builder("1234").build()); + RequestBuilder builder = endpoint.makeRequest(BasicInsightRequest.builder("1234").build()); assertEquals("POST", builder.getMethod()); assertEquals("https://api.nexmo.com/ni/basic/json", builder.build().getURI().toString()); Map params = TestUtils.makeParameterMap(builder.getParameters()); @@ -55,7 +55,7 @@ public void testMakeRequest() throws Exception { @Test public void testMakeRequestWithCountry() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(BasicInsightRequest.builder("1234") + RequestBuilder builder = endpoint.makeRequest(BasicInsightRequest.builder("1234") .country("GB") .build()); assertEquals("POST", builder.getMethod()); @@ -76,7 +76,7 @@ public void testParseResponse() throws Exception { + " \"country_code_iso3\": \"GBR\",\n" + " \"country_name\": \"United Kingdom\",\n" + " \"country_prefix\": \"44\"\n" + "}" ); - BasicInsightResponse response = this.endpoint.parseResponse(stub); + BasicInsightResponse response = endpoint.parseResponse(stub); assertEquals("d79c3d82-e2ee-46ff-972a-97b76be419cb", response.getRequestId()); } diff --git a/src/test/java/com/vonage/client/insight/InsightClientTest.java b/src/test/java/com/vonage/client/insight/InsightClientTest.java index d80d56d55..2b85a12d0 100644 --- a/src/test/java/com/vonage/client/insight/InsightClientTest.java +++ b/src/test/java/com/vonage/client/insight/InsightClientTest.java @@ -98,7 +98,7 @@ public void setUp() { public void testBasicInsightWithNumber() throws Exception { wrapper.setHttpClient(stubHttpClient(200, BASIC_RESPOSE_JSON)); - BasicInsightResponse response = this.client.getBasicNumberInsight("1234"); + BasicInsightResponse response = client.getBasicNumberInsight("1234"); assertBasicResponse(response); } @@ -107,7 +107,7 @@ public void testBasicInsightWithNumber() throws Exception { public void testBasicInsightWithNumberAndCountry() throws Exception { wrapper.setHttpClient(stubHttpClient(200, BASIC_RESPOSE_JSON)); - BasicInsightResponse response = this.client.getBasicNumberInsight("1234", "GB"); + BasicInsightResponse response = client.getBasicNumberInsight("1234", "GB"); assertBasicResponse(response); } @@ -116,7 +116,7 @@ public void testBasicInsightWithNumberAndCountry() throws Exception { public void testStandardInsightWithNumber() throws Exception { wrapper.setHttpClient(stubHttpClient(200, STANDARD_RESPONSE_JSON)); - StandardInsightResponse response = this.client.getStandardNumberInsight("1234"); + StandardInsightResponse response = client.getStandardNumberInsight("1234"); assertBasicResponse(response); } @@ -125,25 +125,17 @@ public void testStandardInsightWithNumber() throws Exception { public void testStandardInsightWithNumberAndCountry() throws Exception { wrapper.setHttpClient(stubHttpClient(200, STANDARD_RESPONSE_JSON)); - StandardInsightResponse response = this.client.getStandardNumberInsight("1234", "GB"); - - assertStandardResponse(response); - } - - @Test - public void testStandardInsightWithNumberAndCountryAndCnam() throws Exception { - wrapper.setHttpClient(stubHttpClient(200, STANDARD_RESPONSE_JSON)); - - StandardInsightResponse response = this.client.getStandardNumberInsight("1234", "GB", true); + StandardInsightResponse response = client.getStandardNumberInsight("1234", "GB"); assertStandardResponse(response); } + @Test public void testAdvancedInsightWithNumber() throws Exception { wrapper.setHttpClient(stubHttpClient(200, ADVANCED_RESPONSE_JSON)); - AdvancedInsightResponse response = this.client.getAdvancedNumberInsight("1234"); + AdvancedInsightResponse response = client.getAdvancedNumberInsight("1234"); assertAdvancedInsightResponse(response); } @@ -152,34 +144,18 @@ public void testAdvancedInsightWithNumber() throws Exception { public void testAdvancedInsightWithNumberAndCountry() throws Exception { wrapper.setHttpClient(stubHttpClient(200, ADVANCED_RESPONSE_JSON)); - AdvancedInsightResponse response = this.client.getAdvancedNumberInsight("1234", "GB"); - - assertAdvancedInsightResponse(response); - } - - @Test - public void testAdvancedInsightWithNumberAndCountryAndIp() throws Exception { - wrapper.setHttpClient(stubHttpClient(200, ADVANCED_RESPONSE_JSON)); - - AdvancedInsightResponse response = this.client.getAdvancedNumberInsight("1234", "GB", "127.0.0.1"); + AdvancedInsightResponse response = client.getAdvancedNumberInsight("1234", "GB"); assertAdvancedInsightResponse(response); } - @Test - public void testAdvancedInsightWithNumberAndCountryAndIpAndCnam() throws Exception { - wrapper.setHttpClient(stubHttpClient(200, ADVANCED_RESPONSE_JSON)); - - AdvancedInsightResponse response = this.client.getAdvancedNumberInsight("1234", "GB", "127.0.0.1", true); - - assertAdvancedInsightResponse(response); - } + @Test public void testAsyncAdvancedInsight() throws Exception { wrapper.setHttpClient(stubHttpClient(200, ASYNC_ADVANCED_RESPONSE_JSON)); - AdvancedInsightResponse response = this.client.getAdvancedNumberInsight(AdvancedInsightRequest.builder("1234") + AdvancedInsightResponse response = client.getAdvancedNumberInsight(AdvancedInsightRequest.builder("1234") .async(true) .callback("https://example.com") .build()); diff --git a/src/test/java/com/vonage/client/insight/StandardInsightEndpointTest.java b/src/test/java/com/vonage/client/insight/StandardInsightEndpointTest.java index 700380b75..bcea19c32 100644 --- a/src/test/java/com/vonage/client/insight/StandardInsightEndpointTest.java +++ b/src/test/java/com/vonage/client/insight/StandardInsightEndpointTest.java @@ -34,18 +34,18 @@ public class StandardInsightEndpointTest { @Before public void setUp() { - this.endpoint = new StandardInsightEndpoint(new HttpWrapper()); + endpoint = new StandardInsightEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() throws Exception { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{SignatureAuthMethod.class, TokenAuthMethod.class}, auths); } @Test public void testMakeRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(StandardInsightRequest.builder("1234").build()); + RequestBuilder builder = endpoint.makeRequest(StandardInsightRequest.builder("1234").build()); assertEquals("POST", builder.getMethod()); assertEquals("https://api.nexmo.com/ni/standard/json", builder.build().getURI().toString()); Map params = TestUtils.makeParameterMap(builder.getParameters()); @@ -56,7 +56,7 @@ public void testMakeRequest() throws Exception { @Test public void testMakeRequestWithCountry() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(StandardInsightRequest.builder("1234") + RequestBuilder builder = endpoint.makeRequest(StandardInsightRequest.builder("1234") .country("GB") .build()); assertEquals("POST", builder.getMethod()); @@ -69,7 +69,7 @@ public void testMakeRequestWithCountry() throws Exception { @Test public void testMakeRequestWithCnam() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(StandardInsightRequest.builder("1234") + RequestBuilder builder = endpoint.makeRequest(StandardInsightRequest.builder("1234") .cnam(true) .build()); assertEquals("POST", builder.getMethod()); @@ -99,7 +99,7 @@ public void testParseResponse() throws Exception { + " \"network_type\": \"mobile\"\n" + " },\n" + " \"ported\": \"assumed_not_ported\"\n" + "}" ); - StandardInsightResponse response = this.endpoint.parseResponse(stub); + StandardInsightResponse response = endpoint.parseResponse(stub); assertEquals("34564b7d-df8b-47fd-aa07-b722602dd974", response.getRequestId()); } diff --git a/src/test/java/com/vonage/client/numbers/BuyNumberEndpointTest.java b/src/test/java/com/vonage/client/numbers/BuyNumberEndpointTest.java index 0cdd86c69..c2a61948c 100644 --- a/src/test/java/com/vonage/client/numbers/BuyNumberEndpointTest.java +++ b/src/test/java/com/vonage/client/numbers/BuyNumberEndpointTest.java @@ -42,7 +42,7 @@ public class BuyNumberEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new BuyNumberEndpoint(new HttpWrapper()); + endpoint = new BuyNumberEndpoint(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/numbers/CancelNumberEndpointTest.java b/src/test/java/com/vonage/client/numbers/CancelNumberEndpointTest.java index 5cd44928f..f96201be1 100644 --- a/src/test/java/com/vonage/client/numbers/CancelNumberEndpointTest.java +++ b/src/test/java/com/vonage/client/numbers/CancelNumberEndpointTest.java @@ -34,7 +34,7 @@ public class CancelNumberEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new CancelNumberEndpoint(new HttpWrapper()); + endpoint = new CancelNumberEndpoint(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/numbers/ListNumbersEndpointTest.java b/src/test/java/com/vonage/client/numbers/ListNumbersEndpointTest.java index c2d0c5078..701b4be81 100644 --- a/src/test/java/com/vonage/client/numbers/ListNumbersEndpointTest.java +++ b/src/test/java/com/vonage/client/numbers/ListNumbersEndpointTest.java @@ -41,7 +41,7 @@ public class ListNumbersEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new ListNumbersEndpoint(new HttpWrapper()); + endpoint = new ListNumbersEndpoint(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/numbers/SearchNumbersEndpointTest.java b/src/test/java/com/vonage/client/numbers/SearchNumbersEndpointTest.java index 7354d56db..b8a7686aa 100644 --- a/src/test/java/com/vonage/client/numbers/SearchNumbersEndpointTest.java +++ b/src/test/java/com/vonage/client/numbers/SearchNumbersEndpointTest.java @@ -42,7 +42,7 @@ public class SearchNumbersEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new SearchNumbersEndpoint(new HttpWrapper()); + endpoint = new SearchNumbersEndpoint(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/numbers/UpdateNumberEndpointTest.java b/src/test/java/com/vonage/client/numbers/UpdateNumberEndpointTest.java index 2e00aa315..1f85be7fe 100644 --- a/src/test/java/com/vonage/client/numbers/UpdateNumberEndpointTest.java +++ b/src/test/java/com/vonage/client/numbers/UpdateNumberEndpointTest.java @@ -33,18 +33,18 @@ public class UpdateNumberEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new UpdateNumberEndpoint(new HttpWrapper()); + endpoint = new UpdateNumberEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() throws Exception { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{TokenAuthMethod.class}, auths); } @Test public void testMakeRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(new UpdateNumberRequest("447700900013", "UK")); + RequestBuilder builder = endpoint.makeRequest(new UpdateNumberRequest("447700900013", "UK")); assertEquals("POST", builder.getMethod()); assertEquals("https://rest.nexmo.com/number/update", builder.build().getURI().toString()); @@ -64,7 +64,7 @@ public void testMakeRequestWithOptionalParams() throws Exception { request.setVoiceStatusCallback("https://api.example.com/callback"); request.setMessagesCallbackValue("MESSAGES-APPLICATION-ID"); - RequestBuilder builder = this.endpoint.makeRequest(request); + RequestBuilder builder = endpoint.makeRequest(request); assertEquals("POST", builder.getMethod()); assertEquals("https://rest.nexmo.com/number/update", builder.build().getURI().toString()); @@ -88,7 +88,7 @@ public void testParseResponse() throws Exception { HttpResponse stub = TestUtils.makeJsonHttpResponse(200, "{\n" + " \"error-code\":\"200\",\n" + " \"error-code-label\":\"success\"\n" + "}" ); - this.endpoint.parseResponse(stub); + endpoint.parseResponse(stub); } catch (Exception e) { fail("Parsing a 200 response should not raise an error."); } @@ -101,7 +101,7 @@ public void testParseErrorResponse() throws Exception { 500, "{\n" + " \"error-code\":\"500\",\n" + " \"error-code-label\":\"There was an error\"\n" + "}" ); - this.endpoint.parseResponse(stub); + endpoint.parseResponse(stub); fail("An exception should have been thrown here."); } catch (Exception e) { // This is expected. diff --git a/src/test/java/com/vonage/client/redact/RedactClientTest.java b/src/test/java/com/vonage/client/redact/RedactClientTest.java index 2d0280bdd..5cfc0b181 100644 --- a/src/test/java/com/vonage/client/redact/RedactClientTest.java +++ b/src/test/java/com/vonage/client/redact/RedactClientTest.java @@ -31,12 +31,12 @@ public void setUp() { @Test public void testSuccessfulResponse() { try { - wrapper.setHttpClient(this.stubHttpClient(204, "")); + wrapper.setHttpClient(stubHttpClient(204, "")); RedactRequest redactRequest = new RedactRequest("test-id", RedactRequest.Product.SMS); redactRequest.setType(RedactRequest.Type.INBOUND); - this.client.redactTransaction(redactRequest); - this.client.redactTransaction(redactRequest.getId(), redactRequest.getProduct(), redactRequest.getType()); + client.redactTransaction(redactRequest); + client.redactTransaction(redactRequest.getId(), redactRequest.getProduct(), redactRequest.getType()); } catch (Exception e) { fail("No exceptions should be thrown."); } @@ -44,42 +44,42 @@ public void testSuccessfulResponse() { @Test(expected = VonageBadRequestException.class) public void testWrongCredentials() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(401, "")); + wrapper.setHttpClient(stubHttpClient(401, "")); RedactRequest redactRequest = new RedactRequest("test-id", RedactRequest.Product.VOICE); - this.client.redactTransaction(redactRequest); - this.client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); + client.redactTransaction(redactRequest); + client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); } @Test(expected = VonageBadRequestException.class) public void testPrematureRedactionOrUnauthorized() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(403, "")); + wrapper.setHttpClient(stubHttpClient(403, "")); RedactRequest redactRequest = new RedactRequest("test-id", RedactRequest.Product.VOICE); - this.client.redactTransaction(redactRequest); - this.client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); + client.redactTransaction(redactRequest); + client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); } @Test(expected = VonageBadRequestException.class) public void testInvalidId() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(404, "")); + wrapper.setHttpClient(stubHttpClient(404, "")); RedactRequest redactRequest = new RedactRequest("test-id", RedactRequest.Product.VOICE); - this.client.redactTransaction(redactRequest); - this.client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); + client.redactTransaction(redactRequest); + client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); } @Test(expected = VonageBadRequestException.class) public void testInvalidJsonInvalidProduct() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(422, "")); + wrapper.setHttpClient(stubHttpClient(422, "")); RedactRequest redactRequest = new RedactRequest("test-id", RedactRequest.Product.VOICE); - this.client.redactTransaction(redactRequest); - this.client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); + client.redactTransaction(redactRequest); + client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); } @Test(expected = VonageBadRequestException.class) public void testRateLimit() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(429, "")); + wrapper.setHttpClient(stubHttpClient(429, "")); RedactRequest redactRequest = new RedactRequest("test-id", RedactRequest.Product.VOICE); - this.client.redactTransaction(redactRequest); - this.client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); + client.redactTransaction(redactRequest); + client.redactTransaction(redactRequest.getId(), redactRequest.getProduct()); } } diff --git a/src/test/java/com/vonage/client/redact/RedactMethodTest.java b/src/test/java/com/vonage/client/redact/RedactMethodTest.java index 664f731f1..11b3f7e1d 100644 --- a/src/test/java/com/vonage/client/redact/RedactMethodTest.java +++ b/src/test/java/com/vonage/client/redact/RedactMethodTest.java @@ -32,7 +32,7 @@ public class RedactMethodTest { @Before public void setUp() throws Exception { - this.method = new RedactMethod(new HttpWrapper()); + method = new RedactMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/redact/RedactRequestTest.java b/src/test/java/com/vonage/client/redact/RedactRequestTest.java index d47d2e2b6..f48df8a16 100644 --- a/src/test/java/com/vonage/client/redact/RedactRequestTest.java +++ b/src/test/java/com/vonage/client/redact/RedactRequestTest.java @@ -68,12 +68,7 @@ public void testProductVerifySdk() { String json = "{\"id\":\"testId\",\"product\":\"verify-sdk\"}"; assertEquals(new RedactRequest("testId", RedactRequest.Product.VERIFY_SDK).toJson(), json); } - - @Test - public void testProductMessage() { - String json = "{\"id\":\"testId\",\"product\":\"messages\"}"; - assertEquals(new RedactRequest("testId", RedactRequest.Product.MESSAGE).toJson(), json); - } + @Test public void testProductMessages() { diff --git a/src/test/java/com/vonage/client/sms/SearchRejectedMessagesEndpointTest.java b/src/test/java/com/vonage/client/sms/SearchRejectedMessagesEndpointTest.java index e2d838886..9d115d584 100644 --- a/src/test/java/com/vonage/client/sms/SearchRejectedMessagesEndpointTest.java +++ b/src/test/java/com/vonage/client/sms/SearchRejectedMessagesEndpointTest.java @@ -36,18 +36,18 @@ public class SearchRejectedMessagesEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new SearchRejectedMessagesEndpoint(new HttpWrapper()); + endpoint = new SearchRejectedMessagesEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() throws Exception { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{TokenAuthMethod.class}, auths); } @Test public void testMakeRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(new SearchRejectedMessagesRequest(new GregorianCalendar(2017, + RequestBuilder builder = endpoint.makeRequest(new SearchRejectedMessagesRequest(new GregorianCalendar(2017, Calendar.OCTOBER, 22 ).getTime(), "447700900737")); @@ -70,7 +70,7 @@ public void testParseResponse() throws Exception { + " \"error-code-label\": \"partner quota exceeded -- Your pre-pay account does not have sufficient credit to process this message\"\n" + " }\n" + " ]\n" + "}\n" ); - SearchRejectedMessagesResponse response = this.endpoint.parseResponse(stub); + SearchRejectedMessagesResponse response = endpoint.parseResponse(stub); assertEquals(1, response.getCount()); assertNotNull(response.getItems()); assertEquals(1, response.getItems().length); diff --git a/src/test/java/com/vonage/client/sms/SearchSmsEndpointTest.java b/src/test/java/com/vonage/client/sms/SearchSmsEndpointTest.java index d5388fb46..125d96b9c 100644 --- a/src/test/java/com/vonage/client/sms/SearchSmsEndpointTest.java +++ b/src/test/java/com/vonage/client/sms/SearchSmsEndpointTest.java @@ -38,18 +38,18 @@ public class SearchSmsEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new SmsSearchEndpoint(new HttpWrapper()); + endpoint = new SmsSearchEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() throws Exception { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{TokenAuthMethod.class}, auths); } @Test public void testMakeSingleIdRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(new SmsIdSearchRequest("one-id")); + RequestBuilder builder = endpoint.makeRequest(new SmsIdSearchRequest("one-id")); assertEquals("GET", builder.getMethod()); assertThat(builder.build().getURI().toString(), startsWith("https://rest.nexmo.com/search/messages?")); @@ -65,7 +65,7 @@ public void testMakeSingleIdRequest() throws Exception { public void testMakeMultipleIdRequest() throws Exception { SmsIdSearchRequest request = new SmsIdSearchRequest("one-id"); request.addId("two-id"); - RequestBuilder builder = this.endpoint.makeRequest(request); + RequestBuilder builder = endpoint.makeRequest(request); assertEquals("GET", builder.getMethod()); assertThat(builder.build().getURI().toString(), startsWith("https://rest.nexmo.com/search/messages?")); @@ -85,7 +85,7 @@ public void testMakeDateRequest() throws Exception { GregorianCalendar.SEPTEMBER, 22 ).getTime(), "447700900510"); - RequestBuilder builder = this.endpoint.makeRequest(request); + RequestBuilder builder = endpoint.makeRequest(request); assertEquals("GET", builder.getMethod()); assertThat(builder.build().getURI().toString(), startsWith("https://rest.nexmo.com/search/messages?")); @@ -113,7 +113,7 @@ public void testParseResponse() throws Exception { + " \"final-status\": \"DELIVRD\",\n" + " \"date-closed\": \"2011-11-25 18:03:00\",\n" + " \"latency\": 14151,\n" + " \"type\": \"MT\"\n" + " }\n" + " ]\n" + "}\n" ); - SearchSmsResponse response = this.endpoint.parseResponse(stub); + SearchSmsResponse response = endpoint.parseResponse(stub); assertThat(response.getCount(), equalTo(2)); diff --git a/src/test/java/com/vonage/client/sms/SmsClientTest.java b/src/test/java/com/vonage/client/sms/SmsClientTest.java index cf4e945a3..c7d5110cd 100644 --- a/src/test/java/com/vonage/client/sms/SmsClientTest.java +++ b/src/test/java/com/vonage/client/sms/SmsClientTest.java @@ -78,7 +78,7 @@ private HttpClient stubHttpClient(int statusCode, String content) throws Excepti @Test public void testSubmitMessage() throws Exception { - this.wrapper.setHttpClient(this.stubHttpClient( + wrapper.setHttpClient(stubHttpClient( 200, "{\n" + " \"message-count\":2,\n" + @@ -111,7 +111,7 @@ public void testSubmitMessage() throws Exception { @Test public void testSubmitMessageHttpError() throws Exception { - this.wrapper.setHttpClient(this.stubHttpClient(500, "")); + wrapper.setHttpClient(stubHttpClient(500, "")); Message message = new TextMessage("TestSender", "not-a-number", "Test"); try { @@ -124,7 +124,7 @@ public void testSubmitMessageHttpError() throws Exception { @Test public void testSearchMessagesId() throws Exception { - this.wrapper.setHttpClient(this.stubHttpClient(200, "{\n" + + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"count\": 2,\n" + " \"items\": [\n" + " {\n" + @@ -164,7 +164,7 @@ public void testSearchMessagesId() throws Exception { @Test public void testSearchMessagesDate() throws Exception { - this.wrapper.setHttpClient(this.stubHttpClient(200, "{\n" + + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"count\": 2,\n" + " \"items\": [\n" + " {\n" + @@ -207,7 +207,7 @@ public void testSearchMessagesDate() throws Exception { @Test public void testSearchRejected() throws Exception { - this.wrapper.setHttpClient(this.stubHttpClient(200, "{\n" + + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"count\": 1,\n" + " \"items\": [\n" + " {\n" + @@ -230,7 +230,7 @@ public void testSearchRejected() throws Exception { @Test public void testSearchSingleMessagesId() throws Exception { - this.wrapper.setHttpClient(this.stubHttpClient(200, "{\n" + + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"message-id\": \"00A0B0C0\",\n" + " \"account-id\": \"key\",\n" + " \"network\": \"20810\",\n" + diff --git a/src/test/java/com/vonage/client/sms/SmsSingleSearchEndpointTest.java b/src/test/java/com/vonage/client/sms/SmsSingleSearchEndpointTest.java index 7c3623062..238dee1f3 100644 --- a/src/test/java/com/vonage/client/sms/SmsSingleSearchEndpointTest.java +++ b/src/test/java/com/vonage/client/sms/SmsSingleSearchEndpointTest.java @@ -28,7 +28,7 @@ public class SmsSingleSearchEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new SmsSingleSearchEndpoint(new HttpWrapper()); + endpoint = new SmsSingleSearchEndpoint(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/sms/callback/AbstractMOServletTest.java b/src/test/java/com/vonage/client/sms/callback/AbstractMOServletTest.java index 48ff2747a..55bf95e42 100644 --- a/src/test/java/com/vonage/client/sms/callback/AbstractMOServletTest.java +++ b/src/test/java/com/vonage/client/sms/callback/AbstractMOServletTest.java @@ -54,12 +54,12 @@ class TestMOServlet extends AbstractMOServlet { final String expectedUsername, final String expectedPassword) { super(validateSignature, signatureSharedSecret, validateUsernamePassword, expectedUsername, expectedPassword); - this.consumer = new SynchronousExecutor(); + consumer = new SynchronousExecutor(); } @Override public void consume(MO mo) { - this.result = mo; + result = mo; } } diff --git a/src/test/java/com/vonage/client/sns/SnsClientTest.java b/src/test/java/com/vonage/client/sns/SnsClientTest.java index 7841dbada..e239335bd 100644 --- a/src/test/java/com/vonage/client/sns/SnsClientTest.java +++ b/src/test/java/com/vonage/client/sns/SnsClientTest.java @@ -52,8 +52,8 @@ public class SnsClientTest { @Before public void setUp() throws Exception { - this.httpWrapper = new HttpWrapper(new TokenAuthMethod("abcd", "efgh")); - this.client = new SnsClient(httpWrapper); + httpWrapper = new HttpWrapper(new TokenAuthMethod("abcd", "efgh")); + client = new SnsClient(httpWrapper); } private HttpClient stubHttpClient(int statusCode, String content) throws Exception { @@ -77,13 +77,13 @@ private HttpClient stubHttpClient(int statusCode, String content) throws Excepti @Ignore @Test public void testSubscribe() throws Exception { - this.httpWrapper.setHttpClient(this.stubHttpClient(200, "\n" + + httpWrapper.setHttpClient(stubHttpClient(200, "\n" + " subscribe\n" + " 0\n" + " a result message\n" + " arn:aws:sns:region:num:id\n" + "")); - SnsSubscribeResponse result = this.client.subscribe(new SnsSubscribeRequest( + SnsSubscribeResponse result = client.subscribe(new SnsSubscribeRequest( "arn:aws:sns:region:num:id", "447777111222" )); @@ -94,13 +94,13 @@ public void testSubscribe() throws Exception { @Test @Ignore public void testPublish() throws Exception { - this.httpWrapper.setHttpClient(this.stubHttpClient(200, "\n" + + httpWrapper.setHttpClient(stubHttpClient(200, "\n" + " publish\n" + " 0\n" + " a result message\n" + " 1234\n" + "")); - SnsPublishResponse result = this.client.publish(new SnsPublishRequest( + SnsPublishResponse result = client.publish(new SnsPublishRequest( "arn:aws:sns:region:num:id", "447777111222", "447777111223", @@ -113,8 +113,8 @@ public void testPublish() throws Exception { @Test public void testSubmitWithInvalidResponse() throws Exception { try { - this.httpWrapper.setHttpClient(this.stubHttpClient(500, "")); - this.client.subscribe(new SnsSubscribeRequest( + httpWrapper.setHttpClient(stubHttpClient(500, "")); + client.subscribe(new SnsSubscribeRequest( "arn:aws:sns:region:num:id", "447777111222" )); diff --git a/src/test/java/com/vonage/client/sns/SnsEndpointTest.java b/src/test/java/com/vonage/client/sns/SnsEndpointTest.java index f2e94e91d..779126088 100644 --- a/src/test/java/com/vonage/client/sns/SnsEndpointTest.java +++ b/src/test/java/com/vonage/client/sns/SnsEndpointTest.java @@ -35,12 +35,12 @@ public class SnsEndpointTest { @Before public void setUp() { - this.endpoint = new SnsEndpoint(new HttpWrapper()); + endpoint = new SnsEndpoint(new HttpWrapper()); } @Test public void testParseSubscribeResponse() throws Exception { - SnsResponse result = this.endpoint.parseSubmitResponse( + SnsResponse result = endpoint.parseSubmitResponse( "\n" + " subscribe\n" + " 0\n" + " a result message\n" + " arn:aws:sns:region:num:id\n" + ""); @@ -54,7 +54,7 @@ public void testParseSubscribeResponse() throws Exception { @Test public void testParsePublishResponse() throws Exception { - SnsResponse result = this.endpoint.parseSubmitResponse( + SnsResponse result = endpoint.parseSubmitResponse( "\n" + " publish\n" + " 0\n" + " a result message\n" + " 1234\n" + ""); @@ -68,7 +68,7 @@ public void testParsePublishResponse() throws Exception { @Test public void testParseResponseInvalidResultCode() throws Exception { - SnsResponse result = this.endpoint.parseSubmitResponse( + SnsResponse result = endpoint.parseSubmitResponse( "\n" + " subscribe\n" + " non-numeric\n" + " a result message\n" + " arn:aws:sns:region:num:id\n" + ""); @@ -79,7 +79,7 @@ public void testParseResponseInvalidResultCode() throws Exception { @Test public void testParseResponseNullResultCode() throws Exception { - SnsResponse result = this.endpoint.parseSubmitResponse( + SnsResponse result = endpoint.parseSubmitResponse( "\n" + " subscribe\n" + " \n" + " a result message\n" + " arn:aws:sns:region:num:id\n" @@ -92,7 +92,7 @@ public void testParseResponseNullResultCode() throws Exception { @Test public void testParseResponseMissingResultCode() throws Exception { try { - this.endpoint.parseSubmitResponse("\n" + " subscribe\n" + endpoint.parseSubmitResponse("\n" + " subscribe\n" + " a result message\n" + " arn:aws:sns:region:num:id\n" + " 1234\n" + ""); @@ -104,7 +104,7 @@ public void testParseResponseMissingResultCode() throws Exception { @Test public void testParseResponseInvalidTagIsIgnored() throws Exception { - SnsResponse result = this.endpoint.parseSubmitResponse( + SnsResponse result = endpoint.parseSubmitResponse( "\n" + " subscribe\n" + " 0\n" + " a result message\n" + " arn:aws:sns:region:num:id\n" @@ -117,7 +117,7 @@ public void testParseResponseInvalidTagIsIgnored() throws Exception { @Test public void testParseResponseUnparseable() throws Exception { try { - this.endpoint.parseSubmitResponse("not-xml"); + endpoint.parseSubmitResponse("not-xml"); fail("Attempting to parse non-xml should throw VonageResponseParseException"); } catch (VonageResponseParseException e) { // this is expected @@ -127,7 +127,7 @@ public void testParseResponseUnparseable() throws Exception { @Test public void testParseDummyCommand() throws Exception { try { - this.endpoint.parseSubmitResponse( + endpoint.parseSubmitResponse( "\n" + " dummy command\n" + " 0\n" + " a result message\n" + " arn:aws:sns:region:num:id\n" diff --git a/src/test/java/com/vonage/client/verify/ControlEndpointTest.java b/src/test/java/com/vonage/client/verify/ControlEndpointTest.java index 8dda19e6a..d30c00b07 100644 --- a/src/test/java/com/vonage/client/verify/ControlEndpointTest.java +++ b/src/test/java/com/vonage/client/verify/ControlEndpointTest.java @@ -35,18 +35,18 @@ public class ControlEndpointTest { @Before public void setUp() throws Exception { - this.endpoint = new ControlEndpoint(new HttpWrapper()); + endpoint = new ControlEndpoint(new HttpWrapper()); } @Test public void testGetAcceptableAuthMethods() throws Exception { - Class[] auths = this.endpoint.getAcceptableAuthMethods(); + Class[] auths = endpoint.getAcceptableAuthMethods(); assertArrayEquals(new Class[]{TokenAuthMethod.class}, auths); } @Test public void testMakeRequest() throws Exception { - RequestBuilder builder = this.endpoint.makeRequest(new ControlRequest("request-id", + RequestBuilder builder = endpoint.makeRequest(new ControlRequest("request-id", VerifyControlCommand.CANCEL )); assertEquals("POST", builder.getMethod()); @@ -62,7 +62,7 @@ public void testParseResponse() throws Exception { HttpResponse stub = TestUtils.makeJsonHttpResponse(200, "{\n" + " \"status\":\"0\",\n" + " \"command\":\"cancel\"\n" + "}" ); - ControlResponse response = this.endpoint.parseResponse(stub); + ControlResponse response = endpoint.parseResponse(stub); assertEquals("0", response.getStatus()); assertEquals(VerifyControlCommand.CANCEL, response.getCommand()); } @@ -73,7 +73,7 @@ public void testParseErrorResponse() throws Exception { "{\n" + " \"error_text\": \"Missing username\",\n" + " \"status\": \"2\"\n" + "}" ); try { - ControlResponse response = this.endpoint.parseResponse(stub); + ControlResponse response = endpoint.parseResponse(stub); fail("Parsing an error response should throw an exception."); } catch (VerifyException exc) { assertEquals("2", exc.getStatus()); diff --git a/src/test/java/com/vonage/client/verify/SearchMethodTest.java b/src/test/java/com/vonage/client/verify/SearchMethodTest.java index 5024595e8..4620540d9 100644 --- a/src/test/java/com/vonage/client/verify/SearchMethodTest.java +++ b/src/test/java/com/vonage/client/verify/SearchMethodTest.java @@ -28,7 +28,7 @@ public class SearchMethodTest { @Before public void setUp() throws Exception { - this.method = new SearchMethod(new HttpWrapper()); + method = new SearchMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/verify/VerifyClientCheckEndpointTest.java b/src/test/java/com/vonage/client/verify/VerifyClientCheckEndpointTest.java index 50de7655a..929f05e04 100644 --- a/src/test/java/com/vonage/client/verify/VerifyClientCheckEndpointTest.java +++ b/src/test/java/com/vonage/client/verify/VerifyClientCheckEndpointTest.java @@ -17,12 +17,14 @@ import com.vonage.client.ClientTest; import com.vonage.client.VonageResponseParseException; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.math.BigDecimal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + public class VerifyClientCheckEndpointTest extends ClientTest { @Before @@ -47,12 +49,12 @@ public void testCheckWithValidResponseAndIp() throws Exception { responses[1] = client.check("a-request-id", "1234"); for (CheckResponse response : responses) { - Assert.assertEquals("a-request-id", response.getRequestId()); - Assert.assertEquals(VerifyStatus.OK, response.getStatus()); - Assert.assertEquals("an-event-id", response.getEventId()); - Assert.assertEquals(new BigDecimal("0.10000000"), response.getPrice()); - Assert.assertEquals("EUR", response.getCurrency()); - Assert.assertNull(response.getErrorText()); + assertEquals("a-request-id", response.getRequestId()); + assertEquals(VerifyStatus.OK, response.getStatus()); + assertEquals("an-event-id", response.getEventId()); + assertEquals(new BigDecimal("0.10000000"), response.getPrice()); + assertEquals("EUR", response.getCurrency()); + assertNull(response.getErrorText()); } } @@ -63,7 +65,7 @@ public void testCheckWithoutRequestId() throws Exception { wrapper.setHttpClient(stubHttpClient(200, json)); CheckResponse response = client.check("a-request-id", "1234", "127.0.0.1"); - Assert.assertNull(response.getRequestId()); + assertNull(response.getRequestId()); } @Test(expected = VonageResponseParseException.class) @@ -81,7 +83,7 @@ public void testCheckWithNonNumericStatus() throws Exception { + "}\n"; wrapper.setHttpClient(stubHttpClient(200, json)); CheckResponse response = client.check("a-request-id", "1234"); - Assert.assertEquals(VerifyStatus.INTERNAL_ERROR, response.getStatus()); + assertEquals(VerifyStatus.INTERNAL_ERROR, response.getStatus()); } @Test @@ -91,7 +93,7 @@ public void testCheckWithoutEventId() throws Exception { wrapper.setHttpClient(stubHttpClient(200, json)); CheckResponse response = client.check("a-request-id", "1234", "127.0.0.1"); - Assert.assertNull(response.getEventId()); + assertNull(response.getEventId()); } @Test @@ -101,7 +103,7 @@ public void testCheckWithoutPrice() throws Exception { wrapper.setHttpClient(stubHttpClient(200, json)); CheckResponse response = client.check("a-request-id", "1234", "127.0.0.1"); - Assert.assertNull(response.getPrice()); + assertNull(response.getPrice()); } @Test(expected = VonageResponseParseException.class) @@ -120,7 +122,7 @@ public void testCheckWithoutCurrency() throws Exception { wrapper.setHttpClient(stubHttpClient(200, json)); CheckResponse response = client.check("a-request-id", "1234", "127.0.0.1"); - Assert.assertNull(response.getCurrency()); + assertNull(response.getCurrency()); } @Test @@ -129,8 +131,8 @@ public void testCheckWithError() throws Exception { wrapper.setHttpClient(stubHttpClient(200, json)); CheckResponse response = client.check("a-request-id", "1234", "127.0.0.1"); - Assert.assertEquals(VerifyStatus.MISSING_PARAMS, response.getStatus()); - Assert.assertEquals("There was an error.", response.getErrorText()); + assertEquals(VerifyStatus.MISSING_PARAMS, response.getStatus()); + assertEquals("There was an error.", response.getErrorText()); } @Test @@ -139,6 +141,6 @@ public void testWithInvalidNumericStatus() throws Exception { wrapper.setHttpClient(stubHttpClient(200, json)); CheckResponse response = client.check("a-request-id", "1234", "127.0.0.1"); - Assert.assertEquals(VerifyStatus.UNKNOWN, response.getStatus()); + assertEquals(VerifyStatus.UNKNOWN, response.getStatus()); } } diff --git a/src/test/java/com/vonage/client/verify/VerifyClientPsd2EndpointTest.java b/src/test/java/com/vonage/client/verify/VerifyClientPsd2EndpointTest.java index 83eea57b4..37f6e330e 100644 --- a/src/test/java/com/vonage/client/verify/VerifyClientPsd2EndpointTest.java +++ b/src/test/java/com/vonage/client/verify/VerifyClientPsd2EndpointTest.java @@ -17,7 +17,7 @@ public void setUp() { @Test public void testPsd2Verify() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{" + "\"request_id\": \"abcdef0123456789abcdef0123456789\"," + " \"status\": 0" + "}" )); @@ -29,7 +29,7 @@ public void testPsd2Verify() throws Exception { @Test public void testPsd2VerifyWithWorkflow() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{" + "\"request_id\": \"abcdef0123456789abcdef0123456789\"," + " \"status\": 0" + "}" )); @@ -41,7 +41,7 @@ public void testPsd2VerifyWithWorkflow() throws Exception { @Test public void testPsd2VerifyWithOptionalParameters() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{" + "\"request_id\": \"abcdef0123456789abcdef0123456789\"," + " \"status\": 0" + "}" )); diff --git a/src/test/java/com/vonage/client/verify/VerifyClientSearchEndpointTest.java b/src/test/java/com/vonage/client/verify/VerifyClientSearchEndpointTest.java index aa6db32a7..5e326d5d3 100644 --- a/src/test/java/com/vonage/client/verify/VerifyClientSearchEndpointTest.java +++ b/src/test/java/com/vonage/client/verify/VerifyClientSearchEndpointTest.java @@ -47,7 +47,7 @@ public void testSearchSuccessWithSingleResult() throws Exception { + " \"first_event_date\": \"2012-01-02 03:04:05\",\n" + " \"last_event_date\": \"2012-01-02 03:04:06\",\n" + " \"price\": \"0.03000000\",\n" + " \"currency\": \"EUR\",\n" + " \"status\": \"SUCCESS\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SearchVerifyResponse response = client.search("not-a-search-request-id"); assertEquals(VerifyStatus.OK, response.getStatus()); @@ -95,7 +95,7 @@ public void testSearchError() throws Exception { //language=JSON String json = "{\n" + " \"request_id\": \"\",\n" + " \"status\": \"101\",\n" + " \"error_text\": \"No response found.\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SearchVerifyResponse response = client.search("AAAAA"); assertEquals(VerifyStatus.NO_RESPONSE, response.getStatus()); @@ -111,7 +111,7 @@ public void testSearchFailed() throws Exception { + " \"first_event_date\": \"2016-10-19 11:18:56\",\n" + " \"last_event_date\": \"2016-10-19 11:18:56\",\n" + " \"price\": \"0.03000000\",\n" + " \"currency\": \"EUR\",\n" + " \"status\": \"FAILED\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SearchVerifyResponse response = client.search("AAAAA"); assertEquals(VerifyStatus.OK, response.getStatus()); @@ -129,7 +129,7 @@ public void testSearchExpired() throws Exception { + " \"first_event_date\": \"2016-10-19 11:25:19\",\n" + " \"last_event_date\": \"2016-10-19 11:30:26\",\n" + " \"price\": \"0\",\n" + " \"currency\": \"EUR\",\n" + " \"status\": \"EXPIRED\"\n" + "}\n"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SearchVerifyResponse response = client.search("AAAAA"); assertEquals(VerifyStatus.OK, response.getStatus()); @@ -146,7 +146,7 @@ public void testSearchInProgress() throws Exception { + " \"checks\": [],\n" + " \"first_event_date\": \"2016-10-19 11:25:19\",\n" + " \"last_event_date\": \"2016-10-19 11:30:26\",\n" + " \"price\": \"0.10000000\",\n" + " \"currency\": \"EUR\",\n" + " \"status\": \"IN PROGRESS\"\n" + "}\n"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SearchVerifyResponse response = client.search("AAAAA"); assertEquals(VerifyStatus.OK, response.getStatus()); @@ -160,7 +160,7 @@ public void testSearchWithWrongParams() throws Exception { String json = "{\n" + " \"request_id\": \"\",\n" + " \"status\": 6,\n" + " \"error_text\": \"The Vonage platform was unable to process this message for the following reason: Wrong parameters.\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SearchVerifyResponse response = client.search("AAAAA"); assertEquals(VerifyStatus.INVALID_REQUEST, response.getStatus()); @@ -181,7 +181,7 @@ public void testSearchWithMultipleResults() throws Exception { + " \"checks\": [],\n" + " \"first_event_date\": \"2016-10-21 15:41:58\",\n" + " \"last_event_date\": \"2016-10-21 15:41:58\",\n" + " \"price\": \"0.10000000\",\n" + " \"currency\": \"EUR\",\n" + " \"status\": \"EXPIRED\"\n" + " }\n" + " ]\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); SearchVerifyResponse response = client.search("not-a-search-request-id"); assertEquals(VerifyStatus.OK, response.getStatus()); @@ -240,7 +240,7 @@ public void testSearchInvalidDates() throws Exception { + " \"price\": \"0.10000000\",\n" + " \"currency\": \"EUR\",\n" + " \"status\": \"SUCCESS\"\n" + " }"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); client.search("a-random-request-id"); } } diff --git a/src/test/java/com/vonage/client/verify/VerifyClientVerifyControlEndpointTest.java b/src/test/java/com/vonage/client/verify/VerifyClientVerifyControlEndpointTest.java index eadfeca3e..60e106567 100644 --- a/src/test/java/com/vonage/client/verify/VerifyClientVerifyControlEndpointTest.java +++ b/src/test/java/com/vonage/client/verify/VerifyClientVerifyControlEndpointTest.java @@ -16,7 +16,7 @@ package com.vonage.client.verify; import com.vonage.client.ClientTest; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; @@ -30,20 +30,20 @@ public void setUp() { @Test public void testAdvanceVerification() throws Exception { String json = "{\n" + " \"status\":\"0\",\n" + " \"command\":\"trigger_next_event\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); ControlResponse response = client.advanceVerification("a-request-id"); - Assert.assertEquals("0", response.getStatus()); - Assert.assertEquals(VerifyControlCommand.TRIGGER_NEXT_EVENT, response.getCommand()); + assertEquals("0", response.getStatus()); + assertEquals(VerifyControlCommand.TRIGGER_NEXT_EVENT, response.getCommand()); } @Test public void testCancelVerification() throws Exception { String json = "{\n" + " \"status\":\"0\",\n" + " \"command\":\"cancel\"\n" + "}"; - wrapper.setHttpClient(this.stubHttpClient(200, json)); + wrapper.setHttpClient(stubHttpClient(200, json)); ControlResponse response = client.cancelVerification("a-request-id"); - Assert.assertEquals("0", response.getStatus()); - Assert.assertEquals(VerifyControlCommand.CANCEL, response.getCommand()); + assertEquals("0", response.getStatus()); + assertEquals(VerifyControlCommand.CANCEL, response.getCommand()); } } diff --git a/src/test/java/com/vonage/client/verify/VerifyClientVerifyEndpointTest.java b/src/test/java/com/vonage/client/verify/VerifyClientVerifyEndpointTest.java index 9660f7d5a..9d6810f9d 100644 --- a/src/test/java/com/vonage/client/verify/VerifyClientVerifyEndpointTest.java +++ b/src/test/java/com/vonage/client/verify/VerifyClientVerifyEndpointTest.java @@ -34,7 +34,7 @@ public void setUp() { @Test public void testVerifyWithNumberBrandFromLengthLocaleLineType() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"request_id\": \"not-really-a-request-id\",\n" + " \"status\": 0,\n" + " \"error_text\": \"error\"\n" + "}" )); @@ -54,7 +54,7 @@ public void testVerifyWithNumberBrandFromLengthLocaleLineType() throws Exception @Test public void testVerifyWithNumberBrandFromLengthLocale() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"request_id\": \"not-really-a-request-id\",\n" + " \"status\": 0,\n" + " \"error_text\": \"error\"\n" + "}" )); @@ -68,7 +68,7 @@ public void testVerifyWithNumberBrandFromLengthLocale() throws Exception { @Test public void testVerifyWithNumberBrandFrom() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"request_id\": \"not-really-a-request-id\",\n" + " \"status\": 0,\n" + " \"error_text\": \"error\"\n" + "}" )); @@ -82,7 +82,7 @@ public void testVerifyWithNumberBrandFrom() throws Exception { @Test public void testVerifyWithNumberBrand() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"request_id\": \"not-really-a-request-id\",\n" + " \"status\": 0,\n" + " \"error_text\": \"error\"\n" + "}" )); @@ -96,7 +96,7 @@ public void testVerifyWithNumberBrand() throws Exception { @Test public void testVerifyWithRequestObject() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"request_id\": \"not-really-a-request-id\",\n" + " \"status\": 0,\n" + " \"error_text\": \"error\"\n" + "}" )); @@ -114,7 +114,7 @@ public void testVerifyWithRequestObject() throws Exception { @Test public void testVerifyHttpError() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(500, + wrapper.setHttpClient(stubHttpClient(500, "{\n" + " \"request_id\": \"not-really-a-request-id\",\n" + " \"status\": 0,\n" + " \"error_text\": \"error\"\n" + "}" )); @@ -128,17 +128,16 @@ public void testVerifyHttpError() throws Exception { @Test public void testVerifyWithNonNumericStatus() throws Exception { - wrapper.setHttpClient(this.stubHttpClient(200, + wrapper.setHttpClient(stubHttpClient(200, "{\n" + " \"request_id\": \"not-really-a-request-id\",\n" + " \"status\": \"test\",\n" + " \"error_text\": \"error\"\n" + "}" )); - VerifyResponse response = client.verify(new VerifyRequest("447700900999", - "TestBrand", - "15555215554", - 6, - Locale.US - )); + VerifyResponse response = client.verify(VerifyRequest.builder("447700900999","TestBrand") + .senderId("15555215554") + .length(6) + .locale(Locale.US) + .build()); assertEquals(VerifyStatus.INTERNAL_ERROR, response.getStatus()); assertEquals("error", response.getErrorText()); diff --git a/src/test/java/com/vonage/client/verify/VerifyDetailsTest.java b/src/test/java/com/vonage/client/verify/VerifyDetailsTest.java index 2b4418722..12787032d 100644 --- a/src/test/java/com/vonage/client/verify/VerifyDetailsTest.java +++ b/src/test/java/com/vonage/client/verify/VerifyDetailsTest.java @@ -15,13 +15,13 @@ */ package com.vonage.client.verify; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; import org.junit.Test; public class VerifyDetailsTest { @Test public void testVerifyDetailsStatusFromString() { - Assert.assertEquals(VerifyDetails.Status.INVALID, VerifyDetails.Status.fromString("101")); + assertEquals(VerifyDetails.Status.INVALID, VerifyDetails.Status.fromString("101")); } } diff --git a/src/test/java/com/vonage/client/voice/CreateCallMethodTest.java b/src/test/java/com/vonage/client/voice/CreateCallMethodTest.java index dfb794922..8c3c7ae82 100644 --- a/src/test/java/com/vonage/client/voice/CreateCallMethodTest.java +++ b/src/test/java/com/vonage/client/voice/CreateCallMethodTest.java @@ -65,7 +65,7 @@ public class CreateCallMethodTest { @Before public void setUp() throws Exception { - this.method = new CreateCallMethod(new HttpWrapper()); + method = new CreateCallMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/voice/ReadCallMethodTest.java b/src/test/java/com/vonage/client/voice/ReadCallMethodTest.java index f72fe3998..e7e7159d5 100644 --- a/src/test/java/com/vonage/client/voice/ReadCallMethodTest.java +++ b/src/test/java/com/vonage/client/voice/ReadCallMethodTest.java @@ -38,7 +38,7 @@ public void setUp() throws Exception { @Test public void getAcceptableAuthMethods() throws Exception { - assertArrayEquals(new Class[]{JWTAuthMethod.class}, this.method.getAcceptableAuthMethods()); + assertArrayEquals(new Class[]{JWTAuthMethod.class}, method.getAcceptableAuthMethods()); } @Test diff --git a/src/test/java/com/vonage/client/voice/StartStreamMethodTest.java b/src/test/java/com/vonage/client/voice/StartStreamMethodTest.java index a7855b4a0..6d597fc74 100644 --- a/src/test/java/com/vonage/client/voice/StartStreamMethodTest.java +++ b/src/test/java/com/vonage/client/voice/StartStreamMethodTest.java @@ -28,7 +28,7 @@ public class StartStreamMethodTest { @Before public void setUp() throws Exception { - this.method = new StartStreamMethod(new HttpWrapper()); + method = new StartStreamMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/voice/StartTalkMethodTest.java b/src/test/java/com/vonage/client/voice/StartTalkMethodTest.java index b867120d9..06b0e4e14 100644 --- a/src/test/java/com/vonage/client/voice/StartTalkMethodTest.java +++ b/src/test/java/com/vonage/client/voice/StartTalkMethodTest.java @@ -28,7 +28,7 @@ public class StartTalkMethodTest { @Before public void setUp() throws Exception { - this.method = new StartTalkMethod(new HttpWrapper()); + method = new StartTalkMethod(new HttpWrapper()); } @Test diff --git a/src/test/java/com/vonage/client/voice/StopStreamMethodTest.java b/src/test/java/com/vonage/client/voice/StopStreamMethodTest.java index 91455477e..9ef8a6a78 100644 --- a/src/test/java/com/vonage/client/voice/StopStreamMethodTest.java +++ b/src/test/java/com/vonage/client/voice/StopStreamMethodTest.java @@ -41,7 +41,7 @@ public class StopStreamMethodTest { @Before public void setUp() throws Exception { - this.method = new StopStreamMethod(new HttpWrapper()); + method = new StopStreamMethod(new HttpWrapper()); httpMethod = "DELETE"; }