/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ExternalServicesConfigurationHelper.java

https://gitlab.com/skylabase/incubator-fineract · Java · 64 lines · 36 code · 10 blank · 18 comment · 0 complexity · 35d6a6e01d0e9a8609e93ccc340dfa89 MD5 · raw file

  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.apache.fineract.integrationtests.common;
  20. import java.util.ArrayList;
  21. import java.util.HashMap;
  22. import com.google.gson.Gson;
  23. import com.jayway.restassured.specification.RequestSpecification;
  24. import com.jayway.restassured.specification.ResponseSpecification;
  25. public class ExternalServicesConfigurationHelper {
  26. private final RequestSpecification requestSpec;
  27. private final ResponseSpecification responseSpec;
  28. public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
  29. this.requestSpec = requestSpec;
  30. this.responseSpec = responseSpec;
  31. }
  32. public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(final RequestSpecification requestSpec,
  33. final ResponseSpecification responseSpec, final String serviceName) {
  34. final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?"
  35. + Utils.TENANT_IDENTIFIER;
  36. System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------");
  37. return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, "");
  38. }
  39. public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec,
  40. final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) {
  41. final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?"
  42. + Utils.TENANT_IDENTIFIER;
  43. System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------");
  44. HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL,
  45. updateExternalServicesConfigUpdateValueAsJSON(name, value), "");
  46. return (HashMap) map.get("changes");
  47. }
  48. public static String updateExternalServicesConfigUpdateValueAsJSON(final String name, final String value) {
  49. final HashMap<String, String> map = new HashMap<>();
  50. map.put(name, value);
  51. System.out.println("map : " + map);
  52. return new Gson().toJson(map);
  53. }
  54. }