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- */
191package org .apache .fineract .integrationtests .common ;
202
213import static org .junit .jupiter .api .Assertions .assertEquals ;
224
23- import com .google .common .reflect .TypeToken ;
24- import com .google .gson .Gson ;
255import io .restassured .specification .RequestSpecification ;
266import io .restassured .specification .ResponseSpecification ;
277import java .util .List ;
3414import org .apache .fineract .client .models .PaymentTypeUpdateResponse ;
3515import org .apache .fineract .client .util .Calls ;
3616
37- @ SuppressWarnings ({ "rawtypes" , "unchecked" })
3817@ Slf4j
3918public final class PaymentTypeHelper {
4019
41- public PaymentTypeHelper () {
20+
21+ public PaymentTypeHelper () {}
4222
43- }
44-
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 ) {
23+ public static List <PaymentTypeData > getAllPaymentTypes (final Boolean onlyWithCode ) {
4924 log .info ("-------------------------------GETTING ALL PAYMENT TYPES-------------------------------------------" );
5025 return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .getAllPaymentTypes (onlyWithCode ));
5126 }
5227
53- public PaymentTypeCreateResponse createPaymentType (final PaymentTypeCreateRequest paymentTypeRequest ) {
28+ public static PaymentTypeCreateResponse createPaymentType (final PaymentTypeCreateRequest request ) {
5429 log .info ("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------" );
55- return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .createPaymentType (paymentTypeRequest ));
30+ return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .createPaymentType (request ));
5631 }
5732
58- public void verifyPaymentTypeCreatedOnServer (final Long generatedPaymentTypeID ) {
33+ public static void verifyPaymentTypeCreatedOnServer (final Long generatedPaymentTypeID ) {
5934 log .info ("-------------------------------CHECK PAYMENT DETAILS-------------------------------------------" );
60- PaymentTypeData response = Calls
61- .ok (FineractClientHelper .getFineractClient ().paymentTypes .retrieveOnePaymentType (generatedPaymentTypeID ));
62- Long responsePaymentTypeID = response .getId ();
63- assertEquals (generatedPaymentTypeID , responsePaymentTypeID , "ERROR IN CREATING THE PAYMENT TYPE" );
35+ PaymentTypeData response = Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .retrieveOnePaymentType (generatedPaymentTypeID ));
36+ assertEquals (generatedPaymentTypeID , response .getId (), "ERROR IN CREATING THE PAYMENT TYPE" );
6437 }
6538
66- public PaymentTypeData retrieveById (final Long paymentTypeId ) {
67- log .info ("-------------------------------GETTING PAYMENT TYPE-------------------------------------------" );
39+ // Compatibility method (Don't remove)
40+ public static Object retrieveById (RequestSpecification requestSpec , ResponseSpecification responseSpec , final Long paymentTypeId ) {
41+ log .info ("-------------------------------GETTING PAYMENT TYPE (COMPATIBILITY)-------------------------------------------" );
6842 return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .retrieveOnePaymentType (paymentTypeId ));
6943 }
7044
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 ());
45+ public static PaymentTypeData retrieveById (final Long paymentTypeId ) {
46+ return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .retrieveOnePaymentType (paymentTypeId ));
8147 }
8248
83- public PaymentTypeUpdateResponse updatePaymentType (final Long paymentTypeId ,
84- PaymentTypeUpdateRequest putPaymentTypesPaymentTypeIdRequest ) {
49+ public static PaymentTypeUpdateResponse updatePaymentType (final Long paymentTypeId , PaymentTypeUpdateRequest request ) {
8550 log .info ("-------------------------------UPDATING PAYMENT TYPE-------------------------------------------" );
86- return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .updatePaymentType (paymentTypeId ,
87- putPaymentTypesPaymentTypeIdRequest ));
51+ return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .updatePaymentType (paymentTypeId , request ));
8852 }
8953
90- public PaymentTypeDeleteResponse deletePaymentType (final Long paymentTypeId ) {
54+ public static PaymentTypeDeleteResponse deletePaymentType (final Long paymentTypeId ) {
9155 log .info ("-------------------------------DELETING PAYMENT TYPE-------------------------------------------" );
9256 return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .deleteCodePaymentType (paymentTypeId ));
9357 }
9458
9559 public static String randomNameGenerator (final String prefix , final int lenOfRandomSuffix ) {
9660 return Utils .randomStringGenerator (prefix , lenOfRandomSuffix );
9761 }
98- }
62+ }
0 commit comments