|
16 | 16 | * specific language governing permissions and limitations |
17 | 17 | * under the License. |
18 | 18 | */ |
| 19 | + |
19 | 20 | package org.apache.fineract.integrationtests.common; |
20 | 21 |
|
21 | 22 | import static org.junit.jupiter.api.Assertions.assertEquals; |
22 | 23 |
|
23 | | -import com.google.common.reflect.TypeToken; |
24 | | -import com.google.gson.Gson; |
25 | 24 | import io.restassured.specification.RequestSpecification; |
26 | 25 | import io.restassured.specification.ResponseSpecification; |
27 | 26 | import java.util.List; |
|
34 | 33 | import org.apache.fineract.client.models.PaymentTypeUpdateResponse; |
35 | 34 | import org.apache.fineract.client.util.Calls; |
36 | 35 |
|
37 | | -@SuppressWarnings({ "rawtypes", "unchecked" }) |
38 | 36 | @Slf4j |
| 37 | +@SuppressWarnings("HideUtilityClassConstructor") |
39 | 38 | public final class PaymentTypeHelper { |
40 | 39 |
|
41 | 40 | public PaymentTypeHelper() { |
42 | 41 |
|
43 | 42 | } |
44 | 43 |
|
45 | | - private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes"; |
46 | | - private static final String CREATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "?" + Utils.TENANT_IDENTIFIER; |
47 | | - |
48 | | - public List<PaymentTypeData> getAllPaymentTypes(final Boolean onlyWithCode) { |
| 44 | + public static List<PaymentTypeData> getAllPaymentTypes(final Boolean onlyWithCode) { |
49 | 45 | log.info("-------------------------------GETTING ALL PAYMENT TYPES-------------------------------------------"); |
50 | 46 | return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.getAllPaymentTypes(onlyWithCode)); |
51 | 47 | } |
52 | 48 |
|
53 | | - public PaymentTypeCreateResponse createPaymentType(final PaymentTypeCreateRequest paymentTypeRequest) { |
| 49 | + public static PaymentTypeCreateResponse createPaymentType(final PaymentTypeCreateRequest request) { |
54 | 50 | log.info("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------"); |
55 | | - return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.createPaymentType(paymentTypeRequest)); |
| 51 | + return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.createPaymentType(request)); |
56 | 52 | } |
57 | 53 |
|
58 | | - public void verifyPaymentTypeCreatedOnServer(final Long generatedPaymentTypeID) { |
| 54 | + public static void verifyPaymentTypeCreatedOnServer(final Long generatedPaymentTypeID) { |
59 | 55 | log.info("-------------------------------CHECK PAYMENT DETAILS-------------------------------------------"); |
60 | 56 | PaymentTypeData response = Calls |
61 | 57 | .ok(FineractClientHelper.getFineractClient().paymentTypes.retrieveOnePaymentType(generatedPaymentTypeID)); |
62 | | - Long responsePaymentTypeID = response.getId(); |
63 | | - assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN CREATING THE PAYMENT TYPE"); |
| 58 | + assertEquals(generatedPaymentTypeID, response.getId(), "ERROR IN CREATING THE PAYMENT TYPE"); |
64 | 59 | } |
65 | 60 |
|
66 | | - public PaymentTypeData retrieveById(final Long paymentTypeId) { |
67 | | - log.info("-------------------------------GETTING PAYMENT TYPE-------------------------------------------"); |
| 61 | + // Compatibility method (Don't remove) |
| 62 | + public static Object retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec, final Long paymentTypeId) { |
| 63 | + log.info("-------------------------------GETTING PAYMENT TYPE (COMPATIBILITY)-------------------------------------------"); |
68 | 64 | return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.retrieveOnePaymentType(paymentTypeId)); |
69 | 65 | } |
70 | 66 |
|
71 | | - // TODO: Rewrite to use fineract-client instead! |
72 | | - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, |
73 | | - // org.apache.fineract.client.models.PostLoansLoanIdRequest) |
74 | | - @Deprecated(forRemoval = true) |
75 | | - public PaymentTypeDomain retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec, final Long paymentTypeId) { |
76 | | - final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + paymentTypeId + "?" + Utils.TENANT_IDENTIFIER; |
77 | | - log.info("-------------------------------GETTING PAYMENT TYPE-------------------------------------------"); |
78 | | - Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, ""); |
79 | | - final String jsonData = new Gson().toJson(get); |
80 | | - return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() {}.getType()); |
| 67 | + public static PaymentTypeData retrieveById(final Long paymentTypeId) { |
| 68 | + return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.retrieveOnePaymentType(paymentTypeId)); |
81 | 69 | } |
82 | 70 |
|
83 | | - public PaymentTypeUpdateResponse updatePaymentType(final Long paymentTypeId, |
84 | | - PaymentTypeUpdateRequest putPaymentTypesPaymentTypeIdRequest) { |
| 71 | + public static PaymentTypeUpdateResponse updatePaymentType(final Long paymentTypeId, PaymentTypeUpdateRequest request) { |
85 | 72 | log.info("-------------------------------UPDATING PAYMENT TYPE-------------------------------------------"); |
86 | | - return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.updatePaymentType(paymentTypeId, |
87 | | - putPaymentTypesPaymentTypeIdRequest)); |
| 73 | + return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.updatePaymentType(paymentTypeId, request)); |
88 | 74 | } |
89 | 75 |
|
90 | | - public PaymentTypeDeleteResponse deletePaymentType(final Long paymentTypeId) { |
| 76 | + public static PaymentTypeDeleteResponse deletePaymentType(final Long paymentTypeId) { |
91 | 77 | log.info("-------------------------------DELETING PAYMENT TYPE-------------------------------------------"); |
92 | 78 | return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.deleteCodePaymentType(paymentTypeId)); |
93 | 79 | } |
|
0 commit comments