Skip to content

Commit

Permalink
test: remove comment and rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarlic committed Aug 20, 2024
1 parent bf0822c commit cc942f0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 55 deletions.
4 changes: 2 additions & 2 deletions src/test/java/webpayplus/PatpassByWebpayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void refund() throws IOException, TransactionRefundException {

String url = String.format("/%s/transactions/%s/refunds", apiUrl, testToken);

double amount = 1000d;
double amount3 = 1000d;
String type = "REVERSED";

Map<String, Object> mapResponse = new HashMap<String, Object>();
Expand All @@ -184,7 +184,7 @@ public void refund() throws IOException, TransactionRefundException {
String jsonResponse = gson.toJson(mapResponse);
setResponsePost(url, jsonResponse);

final PatpassByWebpayTransactionRefundResponse response = (new PatpassByWebpay.Transaction(option)).refund(testToken, amount);
final PatpassByWebpayTransactionRefundResponse response = (new PatpassByWebpay.Transaction(option)).refund(testToken, amount3);
assertEquals(response.getType(), type);

}
Expand Down
4 changes: 0 additions & 4 deletions src/test/java/webpayplus/PatpassComercioTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public void start() throws IOException, InscriptionStartException {
String rut = "14140066-5";
String serviceId = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String finalUrl = "http://localhost:8081/patpass-comercio/final";
String commerceCode = "28299257";
double maxAmount = 0;
String phoneNumber = "123456734";
String mobileNumber = "123456723";
Expand All @@ -72,7 +71,6 @@ public void start() throws IOException, InscriptionStartException {
String address = "huerfanos 101";
String city = "Santiago";

//PatpassComercio.setCommerceCode(commerceCode);
final PatpassComercioInscriptionStartResponse response = (new PatpassComercio.Inscription(option)).start(urlRequest,
name,
firstLastName,
Expand Down Expand Up @@ -107,8 +105,6 @@ public void status() throws IOException, TransactionStatusException {
String jsonResponse = gson.toJson(mapResponse);
setResponsePost(url, jsonResponse);

String commerceCode = "28299257";
//PatpassComercio.setCommerceCode(commerceCode);
final PatpassComercioTransactionStatusResponse response = (new PatpassComercio.Inscription(option)).status(testToken);

assertEquals(response.isAuthorized(), true);
Expand Down
15 changes: 6 additions & 9 deletions src/test/java/webpayplus/WebpayModalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,20 @@ public static void stopProxy() {
@Test
public void create() throws IOException, TransactionCreateException {


String url = String.format("/%s/transactions", apiUrl);

String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Map<String, Object> mapResponse = new HashMap<String, Object>();
mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);

Gson gson = new GsonBuilder().create();
String jsonResponse = gson.toJson(mapResponse);
setResponsePost(url, jsonResponse);

String buyOrder = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
double amount = 1000;
String returnUrl = "http://wwww.google.com";
String buyOrder3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
double amount3 = 1000;

final ModalTransactionCreateResponse response = (new WebpayPlusModal.Transaction(option)).create(buyOrder, sessionId, amount);
final ModalTransactionCreateResponse response = (new WebpayPlusModal.Transaction(option)).create(buyOrder3, sessionId3, amount3);
assertEquals(testToken, response.getToken());
}

Expand Down Expand Up @@ -131,7 +128,7 @@ public void refund() throws IOException, TransactionRefundException {

String url = String.format("/%s/transactions/%s/refunds", apiUrl, testToken);

double amount = 1000d;
double amount3 = 1000d;
String type = "REVERSED";

Map<String, Object> mapResponse = new HashMap<String, Object>();
Expand All @@ -141,7 +138,7 @@ public void refund() throws IOException, TransactionRefundException {
String jsonResponse = gson.toJson(mapResponse);
setResponsePost(url, jsonResponse);

final ModalTransactionRefundResponse response = (new WebpayPlusModal.Transaction(option)).refund(testToken, amount);
final ModalTransactionRefundResponse response = (new WebpayPlusModal.Transaction(option)).refund(testToken, amount3);
assertEquals(type, response.getType());

}
Expand Down
58 changes: 27 additions & 31 deletions src/test/java/webpayplus/WebpayPlusDeferredTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public static void stopProxy() {

@Test
public void create() throws IOException, TransactionCreateException {
//WebpayPlus.Transaction.setIntegrationType(IntegrationType.SERVER_MOCK);


String url = String.format("/%s/transactions", apiUrl);

String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Expand All @@ -70,12 +69,12 @@ public void create() throws IOException, TransactionCreateException {
String jsonResponse = gson.toJson(mapResponse);
setResponsePost(url, jsonResponse);

String buyOrder = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
double amount = 1000;
String buyOrder3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
double amount3 = 1000;
String returnUrl = "http://wwww.google.com";

final WebpayPlusTransactionCreateResponse response = (new WebpayPlus.Transaction(option)).create(buyOrder, sessionId, amount, returnUrl);
final WebpayPlusTransactionCreateResponse response = (new WebpayPlus.Transaction(option)).create(buyOrder3, sessionId3, amount3, returnUrl);
assertEquals(testToken, response.getToken());
assertEquals(urlResponse, response.getUrl());
}
Expand Down Expand Up @@ -107,17 +106,17 @@ public void commit() throws IOException, TransactionCommitException {

String url = String.format("/%s/transactions/%s", apiUrl, testToken);

String vci = "TSY";
double amount = 1000d;
String status = "AUTHORIZED";
String buyOrder = "1643997337";
String sessionId = "1134425622";
String cardNumber = "6623";
String accountingDate = "0731";
String transactionDate = "2021-07-31T23:31:14.249Z";
String authorizationCode = "1213";
String paymentTypeCode = "VN";
byte responseCode = 0;
String vci3 = "TSY";
double amount3 = 1000d;
String status3 = "AUTHORIZED";
String buyOrder3 = "1643997337";
String sessionId3 = "1134425622";
String cardNumber3 = "6623";
String accountingDate3 = "0731";
String transactionDate3 = "2021-07-31T23:31:14.249Z";
String authorizationCode3 = "1213";
String paymentTypeCode3 = "VN";
byte responseCode3 = 0;
double installmentsAmount;
byte installmentsNumber = 0;
double balance;
Expand All @@ -126,21 +125,18 @@ public void commit() throws IOException, TransactionCommitException {
Gson gson = new GsonBuilder().create();
setResponsePut(url, gson.toJson(mapResponse));

//System.out.println("jsonResponse: " + jsonResponse);
//System.out.println("url: " + url);

final WebpayPlusTransactionCommitResponse response = (new WebpayPlus.Transaction(option)).commit(testToken);
assertEquals(vci, response.getVci());
assertEquals(amount, response.getAmount());
assertEquals(status, response.getStatus());
assertEquals(buyOrder, response.getBuyOrder());
assertEquals(sessionId, response.getSessionId());
assertEquals(cardNumber, response.getCardDetail().getCardNumber());
assertEquals(accountingDate, response.getAccountingDate());
assertEquals(transactionDate, response.getTransactionDate());
assertEquals(authorizationCode, response.getAuthorizationCode());
assertEquals(paymentTypeCode, response.getPaymentTypeCode());
assertEquals(responseCode, response.getResponseCode());
assertEquals(vci3, response.getVci());
assertEquals(amount3, response.getAmount());
assertEquals(status3, response.getStatus());
assertEquals(buyOrder3, response.getBuyOrder());
assertEquals(sessionId3, response.getSessionId());
assertEquals(cardNumber3, response.getCardDetail().getCardNumber());
assertEquals(accountingDate3, response.getAccountingDate());
assertEquals(transactionDate3, response.getTransactionDate());
assertEquals(authorizationCode3, response.getAuthorizationCode());
assertEquals(paymentTypeCode3, response.getPaymentTypeCode());
assertEquals(responseCode3, response.getResponseCode());

assertEquals(installmentsNumber, response.getInstallmentsNumber());
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/webpayplus/WebpayPlusMallDeferredTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public void create() throws IOException, TransactionCreateException {
setResponsePost(url, jsonResponse);
String returnUrl = "http://wwww.google.com";

String buyOrder = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String buyOrder3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));

String buyOrderMallOne = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
double amountMallOne = 1000;
Expand All @@ -95,7 +95,7 @@ public void create() throws IOException, TransactionCreateException {
.add(amountMallOne, mallOneCommerceCode, buyOrderMallOne)
.add(amountMallTwo, mallTwoCommerceCode, buyOrderMallTwo);

final WebpayPlusMallTransactionCreateResponse response = (new WebpayPlus.MallTransaction(option)).create(buyOrder,sessionId, returnUrl, mallDetails);
final WebpayPlusMallTransactionCreateResponse response = (new WebpayPlus.MallTransaction(option)).create(buyOrder3,sessionId3, returnUrl, mallDetails);
assertEquals(response.getToken(), testToken);
assertEquals(response.getUrl(), urlResponse);
}
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/webpayplus/WebpayPlusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public static void stopProxy() {
@Test
public void create() throws IOException, TransactionCreateException {


//WebpayPlus.configureForTesting();
String url = String.format("/%s/transactions", apiUrl);

String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Expand All @@ -79,12 +77,12 @@ public void create() throws IOException, TransactionCreateException {
String jsonResponse = gson.toJson(mapResponse);
setResponsePost(url, jsonResponse);

String buyOrder = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
double amount = 1000;
String buyOrder3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
String sessionId3 = String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
double amount3 = 1000;
String returnUrl = "http://wwww.google.com";

final WebpayPlusTransactionCreateResponse response = (new WebpayPlus.Transaction(option)).create(buyOrder, sessionId, amount, returnUrl);
final WebpayPlusTransactionCreateResponse response = (new WebpayPlus.Transaction(option)).create(buyOrder3, sessionId3, amount3, returnUrl);
assertEquals(testToken, response.getToken());
assertEquals(urlResponse, response.getUrl());
}
Expand Down

0 comments on commit cc942f0

Please sign in to comment.