@Test public void getOperationResultsInvalidTest() { final Map<String, String> expectedResult = new HashMap<>(); expectedResult.put(RETURN_RESULT, RETURNED_RESULT); expectedResult.put(RETURN_CODE, FAILURE_RETURN_CODE); expectedResult.put(STATUS_CODE, FAILURE_CODE); expectedResult.put(EXCEPTION, RETURNED_RESULT); String returnedResult = initializeFailureResult().get(RETURN_RESULT); Map<String, String> results = HttpUtils.getOperationResults(initializeFailureResult(), returnedResult, returnedResult, returnedResult); assertThat(results, is(expectedResult)); assertThat(results.size(), is(4)); }
@NotNull public static Map<String, String> getOperationResults(@NotNull final Map<String, String> result, @NotNull final String successMessage, final String failureMessage, final String document) { final Map<String, String> results; final String statusCode = result.get(STATUS_CODE); if (Integer.parseInt(statusCode) >= 200 && Integer.parseInt(statusCode) < 300) { results = getSuccessResultsMap(successMessage); if (!isEmpty(document)) results.put(DOCUMENT, document); } else { results = getFailureResultsMap(failureMessage); } results.put(STATUS_CODE, statusCode); return results; }
HttpUtils { @NotNull public static Map<String, String> getOperationResults(@NotNull final Map<String, String> result, @NotNull final String successMessage, final String failureMessage, final String document) { final Map<String, String> results; final String statusCode = result.get(STATUS_CODE); if (Integer.parseInt(statusCode) >= 200 && Integer.parseInt(statusCode) < 300) { results = getSuccessResultsMap(successMessage); if (!isEmpty(document)) results.put(DOCUMENT, document); } else { results = getFailureResultsMap(failureMessage); } results.put(STATUS_CODE, statusCode); return results; } }
HttpUtils { @NotNull public static Map<String, String> getOperationResults(@NotNull final Map<String, String> result, @NotNull final String successMessage, final String failureMessage, final String document) { final Map<String, String> results; final String statusCode = result.get(STATUS_CODE); if (Integer.parseInt(statusCode) >= 200 && Integer.parseInt(statusCode) < 300) { results = getSuccessResultsMap(successMessage); if (!isEmpty(document)) results.put(DOCUMENT, document); } else { results = getFailureResultsMap(failureMessage); } results.put(STATUS_CODE, statusCode); return results; }  }
HttpUtils { @NotNull public static Map<String, String> getOperationResults(@NotNull final Map<String, String> result, @NotNull final String successMessage, final String failureMessage, final String document) { final Map<String, String> results; final String statusCode = result.get(STATUS_CODE); if (Integer.parseInt(statusCode) >= 200 && Integer.parseInt(statusCode) < 300) { results = getSuccessResultsMap(successMessage); if (!isEmpty(document)) results.put(DOCUMENT, document); } else { results = getFailureResultsMap(failureMessage); } results.put(STATUS_CODE, statusCode); return results; }  @org.jetbrains.annotations.NotNull static Proxy getProxy(@org.jetbrains.annotations.NotNull final String proxyHost, final int proxyPort, @org.jetbrains.annotations.NotNull final String proxyUser, @org.jetbrains.annotations.NotNull final String proxyPassword); static void setProxy(@org.jetbrains.annotations.NotNull final HttpClientInputs httpClientInputs,
                                @org.jetbrains.annotations.NotNull final String proxyHost,
                                @org.jetbrains.annotations.NotNull final String proxyPort,
                                @org.jetbrains.annotations.NotNull final String proxyUsername,
                                @org.jetbrains.annotations.NotNull final String proxyPassword); @NotNull static URIBuilder getUriBuilder(); @NotNull static String getAuthHeaders(@NotNull final String authToken); @NotNull static Map<String, String> getOperationResults(@NotNull final Map<String, String> result,
                                                          @NotNull final String successMessage,
                                                          final String failureMessage,
                                                          final String document); static void setSecurityInputs(@org.jetbrains.annotations.NotNull final HttpClientInputs httpClientInputs,
                                         @org.jetbrains.annotations.NotNull final String trustAllRoots,
                                         @org.jetbrains.annotations.NotNull final String x509HostnameVerifier,
                                         @org.jetbrains.annotations.NotNull final String trustKeystore,
                                         @org.jetbrains.annotations.NotNull final String trustPassword); static void setConnectionParameters(HttpClientInputs httpClientInputs,
                                               @NotNull final String connectTimeout,
                                               @NotNull final String socketTimeout,
                                               @NotNull final String keepAlive,
                                               @NotNull final String connectionsMaxPerRoot,
                                               @NotNull final String connectionsMaxTotal); static void setTLSParameters(HttpClientInputs httpClientInputs); @NotNull static String getQueryParams(String pageNumber,
                                        final String pageSize); @NotNull static Map<String, String> getFailureResults(@NotNull String inputName, @NotNull Integer statusCode, @NotNull String throwable); }
HttpUtils { @NotNull public static Map<String, String> getOperationResults(@NotNull final Map<String, String> result, @NotNull final String successMessage, final String failureMessage, final String document) { final Map<String, String> results; final String statusCode = result.get(STATUS_CODE); if (Integer.parseInt(statusCode) >= 200 && Integer.parseInt(statusCode) < 300) { results = getSuccessResultsMap(successMessage); if (!isEmpty(document)) results.put(DOCUMENT, document); } else { results = getFailureResultsMap(failureMessage); } results.put(STATUS_CODE, statusCode); return results; }  @org.jetbrains.annotations.NotNull static Proxy getProxy(@org.jetbrains.annotations.NotNull final String proxyHost, final int proxyPort, @org.jetbrains.annotations.NotNull final String proxyUser, @org.jetbrains.annotations.NotNull final String proxyPassword); static void setProxy(@org.jetbrains.annotations.NotNull final HttpClientInputs httpClientInputs,
                                @org.jetbrains.annotations.NotNull final String proxyHost,
                                @org.jetbrains.annotations.NotNull final String proxyPort,
                                @org.jetbrains.annotations.NotNull final String proxyUsername,
                                @org.jetbrains.annotations.NotNull final String proxyPassword); @NotNull static URIBuilder getUriBuilder(); @NotNull static String getAuthHeaders(@NotNull final String authToken); @NotNull static Map<String, String> getOperationResults(@NotNull final Map<String, String> result,
                                                          @NotNull final String successMessage,
                                                          final String failureMessage,
                                                          final String document); static void setSecurityInputs(@org.jetbrains.annotations.NotNull final HttpClientInputs httpClientInputs,
                                         @org.jetbrains.annotations.NotNull final String trustAllRoots,
                                         @org.jetbrains.annotations.NotNull final String x509HostnameVerifier,
                                         @org.jetbrains.annotations.NotNull final String trustKeystore,
                                         @org.jetbrains.annotations.NotNull final String trustPassword); static void setConnectionParameters(HttpClientInputs httpClientInputs,
                                               @NotNull final String connectTimeout,
                                               @NotNull final String socketTimeout,
                                               @NotNull final String keepAlive,
                                               @NotNull final String connectionsMaxPerRoot,
                                               @NotNull final String connectionsMaxTotal); static void setTLSParameters(HttpClientInputs httpClientInputs); @NotNull static String getQueryParams(String pageNumber,
                                        final String pageSize); @NotNull static Map<String, String> getFailureResults(@NotNull String inputName, @NotNull Integer statusCode, @NotNull String throwable);  }