From cc942f0f12f048b05be145ff325b3770699a1dde Mon Sep 17 00:00:00 2001 From: Miguel Vargas Date: Tue, 20 Aug 2024 12:05:53 -0500 Subject: [PATCH] test: remove comment and rename variables --- .../java/webpayplus/PatpassByWebpayTest.java | 4 +- .../java/webpayplus/PatpassComercioTest.java | 4 -- src/test/java/webpayplus/WebpayModalTest.java | 15 ++--- .../webpayplus/WebpayPlusDeferredTest.java | 58 +++++++++---------- .../WebpayPlusMallDeferredTest.java | 6 +- src/test/java/webpayplus/WebpayPlusTest.java | 10 ++-- 6 files changed, 42 insertions(+), 55 deletions(-) diff --git a/src/test/java/webpayplus/PatpassByWebpayTest.java b/src/test/java/webpayplus/PatpassByWebpayTest.java index d0a208a..736ef3d 100644 --- a/src/test/java/webpayplus/PatpassByWebpayTest.java +++ b/src/test/java/webpayplus/PatpassByWebpayTest.java @@ -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 mapResponse = new HashMap(); @@ -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); } diff --git a/src/test/java/webpayplus/PatpassComercioTest.java b/src/test/java/webpayplus/PatpassComercioTest.java index cb39182..c524a71 100644 --- a/src/test/java/webpayplus/PatpassComercioTest.java +++ b/src/test/java/webpayplus/PatpassComercioTest.java @@ -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"; @@ -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, @@ -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); diff --git a/src/test/java/webpayplus/WebpayModalTest.java b/src/test/java/webpayplus/WebpayModalTest.java index 8212a53..e18bcf3 100644 --- a/src/test/java/webpayplus/WebpayModalTest.java +++ b/src/test/java/webpayplus/WebpayModalTest.java @@ -58,10 +58,8 @@ 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 mapResponse = new HashMap(); mapResponse.put(ApiConstants.TOKEN_TEXT, testToken); @@ -69,12 +67,11 @@ 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 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()); } @@ -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 mapResponse = new HashMap(); @@ -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()); } diff --git a/src/test/java/webpayplus/WebpayPlusDeferredTest.java b/src/test/java/webpayplus/WebpayPlusDeferredTest.java index 9c9092a..53ebe03 100644 --- a/src/test/java/webpayplus/WebpayPlusDeferredTest.java +++ b/src/test/java/webpayplus/WebpayPlusDeferredTest.java @@ -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"; @@ -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()); } @@ -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; @@ -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()); } diff --git a/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java b/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java index 22d7faf..d42387a 100644 --- a/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java +++ b/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java @@ -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; @@ -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); } diff --git a/src/test/java/webpayplus/WebpayPlusTest.java b/src/test/java/webpayplus/WebpayPlusTest.java index f99a016..dede515 100644 --- a/src/test/java/webpayplus/WebpayPlusTest.java +++ b/src/test/java/webpayplus/WebpayPlusTest.java @@ -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"; @@ -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()); }