1616 * specific language governing permissions and limitations
1717 * under the License.
1818 */
19+
1920package org .apache .fineract .integrationtests .common ;
2021
2122import static org .junit .jupiter .api .Assertions .assertEquals ;
2223
23- import com .google .common .reflect .TypeToken ;
24- import com .google .gson .Gson ;
2524import io .restassured .specification .RequestSpecification ;
2625import io .restassured .specification .ResponseSpecification ;
2726import java .util .List ;
3433import org .apache .fineract .client .models .PaymentTypeUpdateResponse ;
3534import org .apache .fineract .client .util .Calls ;
3635
37- @ SuppressWarnings ({ "rawtypes" , "unchecked" })
3836@ Slf4j
37+ @ SuppressWarnings ("HideUtilityClassConstructor" )
3938public final class PaymentTypeHelper {
4039
4140 public PaymentTypeHelper () {
42-
4341 }
4442
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 ) {
43+ public static List <PaymentTypeData > getAllPaymentTypes (final Boolean onlyWithCode ) {
4944 log .info ("-------------------------------GETTING ALL PAYMENT TYPES-------------------------------------------" );
5045 return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .getAllPaymentTypes (onlyWithCode ));
5146 }
5247
53- public PaymentTypeCreateResponse createPaymentType (final PaymentTypeCreateRequest paymentTypeRequest ) {
48+ public static PaymentTypeCreateResponse createPaymentType (final PaymentTypeCreateRequest request ) {
5449 log .info ("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------" );
55- return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .createPaymentType (paymentTypeRequest ));
50+ return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .createPaymentType (request ));
5651 }
5752
58- public void verifyPaymentTypeCreatedOnServer (final Long generatedPaymentTypeID ) {
53+ public static void verifyPaymentTypeCreatedOnServer (final Long generatedPaymentTypeID ) {
5954 log .info ("-------------------------------CHECK PAYMENT DETAILS-------------------------------------------" );
6055 PaymentTypeData response = Calls
6156 .ok (FineractClientHelper .getFineractClient ().paymentTypes .retrieveOnePaymentType (generatedPaymentTypeID ));
62- Long responsePaymentTypeID = response .getId ();
63- assertEquals (generatedPaymentTypeID , responsePaymentTypeID , "ERROR IN CREATING THE PAYMENT TYPE" );
57+ assertEquals (generatedPaymentTypeID , response .getId (), "ERROR IN CREATING THE PAYMENT TYPE" );
6458 }
6559
66- public PaymentTypeData retrieveById (final Long paymentTypeId ) {
67- log .info ("-------------------------------GETTING PAYMENT TYPE-------------------------------------------" );
60+ public static Object retrieveById (RequestSpecification requestSpec , ResponseSpecification responseSpec , final Long paymentTypeId ) {
61+ log .info ("-------------------------------GETTING PAYMENT TYPE (COMPATIBILITY) -------------------------------------------" );
6862 return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .retrieveOnePaymentType (paymentTypeId ));
6963 }
7064
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 ());
65+ public static PaymentTypeData retrieveById (final Long paymentTypeId ) {
66+ return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .retrieveOnePaymentType (paymentTypeId ));
8167 }
8268
83- public PaymentTypeUpdateResponse updatePaymentType (final Long paymentTypeId ,
84- PaymentTypeUpdateRequest putPaymentTypesPaymentTypeIdRequest ) {
69+ public static PaymentTypeUpdateResponse updatePaymentType (final Long paymentTypeId , PaymentTypeUpdateRequest request ) {
8570 log .info ("-------------------------------UPDATING PAYMENT TYPE-------------------------------------------" );
86- return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .updatePaymentType (paymentTypeId ,
87- putPaymentTypesPaymentTypeIdRequest ));
71+ return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .updatePaymentType (paymentTypeId , request ));
8872 }
8973
90- public PaymentTypeDeleteResponse deletePaymentType (final Long paymentTypeId ) {
74+ public static PaymentTypeDeleteResponse deletePaymentType (final Long paymentTypeId ) {
9175 log .info ("-------------------------------DELETING PAYMENT TYPE-------------------------------------------" );
9276 return Calls .ok (FineractClientHelper .getFineractClient ().paymentTypes .deleteCodePaymentType (paymentTypeId ));
9377 }
9478
9579 public static String randomNameGenerator (final String prefix , final int lenOfRandomSuffix ) {
9680 return Utils .randomStringGenerator (prefix , lenOfRandomSuffix );
9781 }
98- }
82+ }
0 commit comments