Skip to content

Commit

Permalink
FINERACT-2070: E2E testcase migration - feature files - pt6
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-kovacs-dpc authored and adamsaghy committed Nov 13, 2024
1 parent 7408f10 commit 4e8fc2c
Show file tree
Hide file tree
Showing 7 changed files with 767 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.apache.fineract.client.services.LoansApi;
import org.apache.fineract.client.services.UsersApi;
import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.api.ApiProperties;
import org.apache.fineract.test.data.ChargeProductType;
import org.apache.fineract.test.data.LoanRescheduleErrorMessage;
import org.apache.fineract.test.data.LoanStatus;
Expand Down Expand Up @@ -118,6 +117,7 @@ public class BatchApiStepDef extends AbstractStepDef {
private static final Integer ERROR_HTTP_404 = 404;
private static final String ERROR_DEVELOPER_MESSAGE_CLIENT = "Client with identifier null does not exist";
private static final String ERROR_DEVELOPER_MESSAGE_LOAN_EXTERNAL = "Loan with external identifier {externalId} does not exist";
private static final String PWD_USER_WITH_ROLE = "1234567890Aa!";

@Autowired
private BatchApiApi batchApiApi;
Expand All @@ -140,9 +140,6 @@ public class BatchApiStepDef extends AbstractStepDef {
@Autowired
private UsersApi usersApi;

@Autowired
private ApiProperties apiProperties;

@When("Batch API sample call ran")
public void runSampleBatchApiCall() throws IOException {
List<BatchRequest> requestList = new ArrayList<>();
Expand Down Expand Up @@ -473,7 +470,7 @@ public void runBatchApiCreateAndApproveLoanRescheduleWithGivenUser(String fromDa
Long createdUserId = createUserResponse.body().getResourceId();
Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
ErrorHelper.checkSuccessfulApiCall(user);
String authorizationString = user.body().getUsername() + ":" + apiProperties.getStrongPassword();
String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
Base64 base64 = new Base64();
headerMap.put("Authorization",
"Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
Expand Down Expand Up @@ -533,7 +530,7 @@ public void runBatchApiCreateAndApproveLoanRescheduleWithGivenUserLockedByCobErr
Long createdUserId = createUserResponse.body().getResourceId();
Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
ErrorHelper.checkSuccessfulApiCall(user);
String authorizationString = user.body().getUsername() + ":" + apiProperties.getStrongPassword();
String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
Base64 base64 = new Base64();
headerMap.put("Authorization",
"Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.fineract.client.models.PutRolesRoleIdPermissionsResponse;
import org.apache.fineract.client.services.RolesApi;
import org.apache.fineract.client.services.UsersApi;
import org.apache.fineract.test.api.ApiProperties;
import org.apache.fineract.test.helper.ErrorHelper;
import org.apache.fineract.test.helper.Utils;
import org.apache.fineract.test.stepdef.AbstractStepDef;
Expand All @@ -50,8 +49,7 @@ public class UserStepDef extends AbstractStepDef {
@Autowired
private UsersApi usersApi;

@Autowired
private ApiProperties apiProperties;
private static final String PWD_USER_WITH_ROLE = "1234567890Aa!";

@When("Admin creates new user with {string} username, {string} role name and given permissions:")
public void createUserWithUsernameAndRoles(String username, String roleName, List<String> permissions) throws IOException {
Expand All @@ -76,8 +74,8 @@ public void createUserWithUsernameAndRoles(String username, String roleName, Lis
.lastname(username) //
.sendPasswordToEmail(Boolean.FALSE) //
.officeId(1L) //
.password(apiProperties.getStrongPassword()) //
.repeatPassword(apiProperties.getStrongPassword()) //
.password(PWD_USER_WITH_ROLE) //
.repeatPassword(PWD_USER_WITH_ROLE) //
.roles(List.of(roleId));

Response<PostUsersResponse> createUserResponse = usersApi.create15(postUsersRequest).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.apache.fineract.client.services.LoansApi;
import org.apache.fineract.client.services.UsersApi;
import org.apache.fineract.client.util.JSON;
import org.apache.fineract.test.api.ApiProperties;
import org.apache.fineract.test.data.DelinquencyRange;
import org.apache.fineract.test.data.LoanStatus;
import org.apache.fineract.test.helper.ErrorHelper;
Expand All @@ -75,6 +74,7 @@ public class LoanDelinquencyStepDef extends AbstractStepDef {
public static final String DEFAULT_LOCALE = "en";
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
private static final Gson GSON = new JSON().getGson();
private static final String PWD_USER_WITH_ROLE = "1234567890Aa!";

@Autowired
private LoansApi loansApi;
Expand All @@ -85,9 +85,6 @@ public class LoanDelinquencyStepDef extends AbstractStepDef {
@Autowired
private EventCheckHelper eventCheckHelper;

@Autowired
private ApiProperties apiProperties;

@Autowired
private UsersApi usersApi;

Expand Down Expand Up @@ -225,7 +222,7 @@ public void delinquencyPauseWithCreatedUser(String startDate, String endDate) th
Long createdUserId = createUserResponse.body().getResourceId();
Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
ErrorHelper.checkSuccessfulApiCall(user);
String authorizationString = user.body().getUsername() + ":" + apiProperties.getStrongPassword();
String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
Base64 base64 = new Base64();
headerMap.put("Authorization",
"Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
Expand Down Expand Up @@ -257,7 +254,7 @@ public void delinquencyPauseWithCreatedUserNOPermissionError(String startDate, S
Long createdUserId = createUserResponse.body().getResourceId();
Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
ErrorHelper.checkSuccessfulApiCall(user);
String authorizationString = user.body().getUsername() + ":" + apiProperties.getStrongPassword();
String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
Base64 base64 = new Base64();
headerMap.put("Authorization",
"Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.apache.fineract.client.services.LoanTransactionsApi;
import org.apache.fineract.client.services.LoansApi;
import org.apache.fineract.client.services.UsersApi;
import org.apache.fineract.test.api.ApiProperties;
import org.apache.fineract.test.data.TransactionType;
import org.apache.fineract.test.data.paymenttype.DefaultPaymentType;
import org.apache.fineract.test.data.paymenttype.PaymentTypeResolver;
Expand All @@ -78,6 +77,8 @@ public class LoanRepaymentStepDef extends AbstractStepDef {
public static final String DEFAULT_RECEIPT_NB = "1234567890";
public static final String DEFAULT_BANK_NB = "1234567890";
public static final String DEFAULT_REPAYMENT_TYPE = "AUTOPAY";
private static final String PWD_USER_WITH_ROLE = "1234567890Aa!";

@Autowired
private LoanTransactionsApi loanTransactionsApi;

Expand All @@ -87,9 +88,6 @@ public class LoanRepaymentStepDef extends AbstractStepDef {
@Autowired
private EventAssertion eventAssertion;

@Autowired
private ApiProperties apiProperties;

@Autowired
private UsersApi usersApi;

Expand Down Expand Up @@ -161,7 +159,7 @@ public void makeRepaymentWithGivenUser(String repaymentType, String transactionD
Long createdUserId = createUserResponse.body().getResourceId();
Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
ErrorHelper.checkSuccessfulApiCall(user);
String authorizationString = user.body().getUsername() + ":" + apiProperties.getStrongPassword();
String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
Base64 base64 = new Base64();
headerMap.put("Authorization",
"Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
Expand Down Expand Up @@ -222,7 +220,7 @@ public void makeRepaymentWithGivenUserByExternalId(String repaymentType, String
Long createdUserId = createUserResponse.body().getResourceId();
Response<GetUsersUserIdResponse> user = usersApi.retrieveOne31(createdUserId).execute();
ErrorHelper.checkSuccessfulApiCall(user);
String authorizationString = user.body().getUsername() + ":" + apiProperties.getStrongPassword();
String authorizationString = user.body().getUsername() + ":" + PWD_USER_WITH_ROLE;
Base64 base64 = new Base64();
headerMap.put("Authorization",
"Basic " + new String(base64.encode(authorizationString.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
Expand Down
Loading

0 comments on commit 4e8fc2c

Please sign in to comment.