Skip to content

Commit a81a4cb

Browse files
committed
[CC-2673] Cleanup tests.
1 parent ec5a52e commit a81a4cb

66 files changed

Lines changed: 632 additions & 451 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/test/java/com/unzer/payment/PaymentExceptionTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@
99
import static org.junit.jupiter.api.Assertions.assertEquals;
1010
import static org.junit.jupiter.api.Assertions.assertNotNull;
1111

12-
public class PaymentExceptionTest {
12+
class PaymentExceptionTest {
1313

1414

1515
@Test
16-
public void testMessageIsNotNull() {
16+
void testMessageIsNotNull() {
1717
PaymentException paymentException = new PaymentException("An Error occurred!");
1818
assertNotNull(paymentException.getMessage());
1919
assertEquals("An Error occurred!", paymentException.getMessage());
2020
}
2121

2222
@Test
23-
public void testMessageIsEmpty() {
23+
void testMessageIsEmpty() {
2424
PaymentException paymentException = new PaymentException("");
2525
assertNotNull(paymentException.getMessage());
2626
assertEquals("Unzer responded with 0 when calling . ", paymentException.getMessage());
2727
}
2828

2929
@Test
30-
public void testPaymentErrorListEmptyAndMessageNotEmpty() {
30+
void testPaymentErrorListEmptyAndMessageNotEmpty() {
3131
PaymentException paymentException = new PaymentException(new ArrayList<PaymentError>(), "An Error occurred!");
3232
assertNotNull(paymentException.getMessage());
3333
assertEquals("An Error occurred!", paymentException.getMessage());
3434
}
3535

3636
@Test
37-
public void testPaymentErrorListEmptyAndMessageIsEmpty() {
37+
void testPaymentErrorListEmptyAndMessageIsEmpty() {
3838
PaymentException paymentException = new PaymentException(new ArrayList<PaymentError>(), "");
3939
assertNotNull(paymentException.getMessage());
4040
assertEquals("Unzer responded with 0 when calling . ", paymentException.getMessage());
4141
}
4242

4343
@Test
44-
public void testPaymentErrorListNotEmptyAndMessageIsEmpty() {
44+
void testPaymentErrorListNotEmptyAndMessageIsEmpty() {
4545
PaymentError paymentError = new PaymentError();
4646
paymentError.setCode("0");
4747
paymentError.setCustomerMessage("This is a Customer Error Message!");
@@ -56,7 +56,7 @@ public void testPaymentErrorListNotEmptyAndMessageIsEmpty() {
5656
}
5757

5858
@Test
59-
public void testMessageIsNull() {
59+
void testMessageIsNull() {
6060
PaymentException paymentException = new PaymentException(null);
6161
assertNotNull(paymentException.getMessage());
6262
assertEquals("Unzer responded with 0 when calling . ", paymentException.getMessage());

src/test/java/com/unzer/payment/PaymentTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
import java.math.BigDecimal;
77

8-
import static org.junit.jupiter.api.Assertions.*;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.assertFalse;
10+
import static org.junit.jupiter.api.Assertions.assertTrue;
911

10-
public class PaymentTest {
12+
class PaymentTest {
1113

1214
@Test
13-
public void testIsNotEmpty() {
15+
void testIsNotEmpty() {
1416
Payment payment = new Payment(getUnzer());
1517
assertFalse(payment.isNotEmpty(""));
1618
assertFalse(payment.isNotEmpty(" "));
@@ -19,7 +21,7 @@ public void testIsNotEmpty() {
1921
}
2022

2123
@Test
22-
public void testChargeOnNullAuthorization() {
24+
void testChargeOnNullAuthorization() {
2325
Payment payment = new Payment(getUnzer());
2426

2527
try {

src/test/java/com/unzer/payment/PaymentTypeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
import static org.junit.jupiter.api.Assertions.assertThrows;
88

9-
public class PaymentTypeTest extends AbstractPaymentTest {
9+
class PaymentTypeTest extends AbstractPaymentTest {
1010

1111
@Test
12-
public void testForInvalidPaymentType() {
12+
void testForInvalidPaymentType() {
1313
assertThrows(PaymentException.class, () -> {
1414
getUnzer().fetchPaymentType("s-xxx-shdshdbshbv");
1515
});

src/test/java/com/unzer/payment/business/AuthorizationTest.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.unzer.payment.business;
22

3-
import com.unzer.payment.*;
3+
import com.unzer.payment.Authorization;
4+
import com.unzer.payment.BaseTransaction;
5+
import com.unzer.payment.Basket;
6+
import com.unzer.payment.Customer;
7+
import com.unzer.payment.Payment;
8+
import com.unzer.payment.Unzer;
49
import com.unzer.payment.communication.HttpCommunicationException;
510
import com.unzer.payment.marketplace.MarketplaceAuthorization;
611
import com.unzer.payment.marketplace.MarketplacePayment;
@@ -24,10 +29,10 @@
2429
import static org.junit.jupiter.api.Assertions.assertNotNull;
2530

2631

27-
public class AuthorizationTest extends AbstractPaymentTest {
32+
class AuthorizationTest extends AbstractPaymentTest {
2833

2934
@Test
30-
public void testAuthorizeWithAuthorizationObject() throws MalformedURLException, HttpCommunicationException {
35+
void testAuthorizeWithAuthorizationObject() throws MalformedURLException, HttpCommunicationException {
3136
Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false));
3237
assertNotNull(authorize.getId());
3338
assertNotNull(authorize);
@@ -36,7 +41,7 @@ public void testAuthorizeWithAuthorizationObject() throws MalformedURLException,
3641
}
3742

3843
@Test
39-
public void testAuthorizeWithTypeId() throws MalformedURLException, HttpCommunicationException {
44+
void testAuthorizeWithTypeId() throws MalformedURLException, HttpCommunicationException {
4045
Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false);
4146
assertNotNull(authorize);
4247
assertNotNull(authorize.getId());
@@ -45,7 +50,7 @@ public void testAuthorizeWithTypeId() throws MalformedURLException, HttpCommunic
4550
}
4651

4752
@Test
48-
public void testAuthorizeSuccess() throws MalformedURLException, HttpCommunicationException {
53+
void testAuthorizeSuccess() throws MalformedURLException, HttpCommunicationException {
4954
Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false);
5055
assertNotNull(authorize);
5156
assertNotNull(authorize.getId());
@@ -55,7 +60,7 @@ public void testAuthorizeSuccess() throws MalformedURLException, HttpCommunicati
5560
}
5661

5762
@Test
58-
public void testAuthorizeWithPaymentType() throws MalformedURLException, HttpCommunicationException {
63+
void testAuthorizeWithPaymentType() throws MalformedURLException, HttpCommunicationException {
5964
Unzer unzer = getUnzer(Keys.DEFAULT);
6065
LocalDate locaDateNow = LocalDate.now();
6166
Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1));
@@ -67,7 +72,7 @@ public void testAuthorizeWithPaymentType() throws MalformedURLException, HttpCom
6772
}
6873

6974
@Test
70-
public void testAuthorizeReturnPaymentTypeAndCustomer() throws MalformedURLException, HttpCommunicationException {
75+
void testAuthorizeReturnPaymentTypeAndCustomer() throws MalformedURLException, HttpCommunicationException {
7176
Unzer unzer = getUnzer(Keys.DEFAULT);
7277
LocalDate locaDateNow = LocalDate.now();
7378
Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1));
@@ -82,7 +87,7 @@ public void testAuthorizeReturnPaymentTypeAndCustomer() throws MalformedURLExcep
8287
}
8388

8489
@Test
85-
public void testAuthorizeWithCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException {
90+
void testAuthorizeWithCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException {
8691
Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid()));
8792
Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), customer.getCustomerId(), false);
8893
assertNotNull(authorize);
@@ -92,7 +97,7 @@ public void testAuthorizeWithCustomerId() throws MalformedURLException, HttpComm
9297
}
9398

9499
@Test
95-
public void testAuthorizeWithReturnUrl() throws MalformedURLException, HttpCommunicationException {
100+
void testAuthorizeWithReturnUrl() throws MalformedURLException, HttpCommunicationException {
96101
Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false);
97102
assertNotNull(authorize);
98103
assertNotNull(authorize.getId());
@@ -101,7 +106,7 @@ public void testAuthorizeWithReturnUrl() throws MalformedURLException, HttpCommu
101106
}
102107

103108
@Test
104-
public void testAuthorizeWithCustomerTypeReturnUrl() throws MalformedURLException, HttpCommunicationException {
109+
void testAuthorizeWithCustomerTypeReturnUrl() throws MalformedURLException, HttpCommunicationException {
105110
Unzer unzer = getUnzer(Keys.DEFAULT);
106111
LocalDate locaDateNow = LocalDate.now();
107112
Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1));
@@ -114,7 +119,7 @@ public void testAuthorizeWithCustomerTypeReturnUrl() throws MalformedURLExceptio
114119
}
115120

116121
@Test
117-
public void testAuthorizeWithCustomerIdReturnUrl() throws MalformedURLException, HttpCommunicationException, ParseException {
122+
void testAuthorizeWithCustomerIdReturnUrl() throws MalformedURLException, HttpCommunicationException, ParseException {
118123
Customer maxCustomer = getMaximumCustomer(generateUuid());
119124
Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), maxCustomer.getId(), false);
120125
assertNotNull(authorize);
@@ -124,7 +129,7 @@ public void testAuthorizeWithCustomerIdReturnUrl() throws MalformedURLException,
124129
}
125130

126131
@Test
127-
public void testFetchAuthorization() throws MalformedURLException, HttpCommunicationException {
132+
void testFetchAuthorization() throws MalformedURLException, HttpCommunicationException {
128133
Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false);
129134
assertNotNull(authorize);
130135
assertNotNull(authorize.getId());
@@ -136,7 +141,7 @@ public void testFetchAuthorization() throws MalformedURLException, HttpCommunica
136141
}
137142

138143
@Test
139-
public void testAuthorizeWithOrderId() throws MalformedURLException, HttpCommunicationException {
144+
void testAuthorizeWithOrderId() throws MalformedURLException, HttpCommunicationException {
140145
String orderId = generateUuid();
141146
Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, orderId, null, null, false));
142147
assertNotNull(authorize);
@@ -151,7 +156,7 @@ public void testAuthorizeWithOrderId() throws MalformedURLException, HttpCommuni
151156
}
152157

153158
@Test
154-
public void testAuthorizeCard3dsFalse() throws MalformedURLException, HttpCommunicationException {
159+
void testAuthorizeCard3dsFalse() throws MalformedURLException, HttpCommunicationException {
155160
String orderId = generateUuid();
156161
Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, orderId, null, null, false));
157162
assertNotNull(authorize);
@@ -167,7 +172,7 @@ public void testAuthorizeCard3dsFalse() throws MalformedURLException, HttpCommun
167172
}
168173

169174
@Test
170-
public void testAuthorizeCard3dsTrue() throws MalformedURLException, HttpCommunicationException {
175+
void testAuthorizeCard3dsTrue() throws MalformedURLException, HttpCommunicationException {
171176
String orderId = generateUuid();
172177
Unzer unzer = getUnzer();
173178
Authorization authorize = unzer.authorize(getAuthorization(createPaymentTypeCard(unzer, "4711100000000000").getId(), null, orderId, null, null, true));
@@ -184,7 +189,7 @@ public void testAuthorizeCard3dsTrue() throws MalformedURLException, HttpCommuni
184189
}
185190

186191
@Test
187-
public void testAuthorizeWithPaymentReference() throws MalformedURLException, HttpCommunicationException {
192+
void testAuthorizeWithPaymentReference() throws MalformedURLException, HttpCommunicationException {
188193
Authorization authorization = getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId());
189194
authorization.setPaymentReference("pmt-ref");
190195
Authorization authorize = getUnzer().authorize(authorization);
@@ -194,7 +199,7 @@ public void testAuthorizeWithPaymentReference() throws MalformedURLException, Ht
194199
}
195200

196201
@Test
197-
public void testAuthorizeWithAuthorizeObject() throws MalformedURLException, HttpCommunicationException {
202+
void testAuthorizeWithAuthorizeObject() throws MalformedURLException, HttpCommunicationException {
198203
Authorization authorization = getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId());
199204
authorization.setPaymentReference("pmt-ref");
200205
authorization.setAmount(new BigDecimal("1.0"));
@@ -207,7 +212,7 @@ public void testAuthorizeWithAuthorizeObject() throws MalformedURLException, Htt
207212

208213
@Disabled("Needs further configuration in Testdata")
209214
@Test
210-
public void testMarketplaceAuthorize() throws MalformedURLException, HttpCommunicationException {
215+
void testMarketplaceAuthorize() throws MalformedURLException, HttpCommunicationException {
211216
String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1;
212217
String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2;
213218

src/test/java/com/unzer/payment/business/BasketV1Test.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package com.unzer.payment.business;
22

33

4-
import com.unzer.payment.*;
4+
import com.unzer.payment.Authorization;
5+
import com.unzer.payment.Basket;
6+
import com.unzer.payment.BasketItem;
7+
import com.unzer.payment.Charge;
8+
import com.unzer.payment.Payment;
9+
import com.unzer.payment.PaymentException;
510
import com.unzer.payment.communication.HttpCommunicationException;
611
import com.unzer.payment.service.UrlUtil;
712
import org.junit.jupiter.api.Test;
@@ -13,12 +18,14 @@
1318

1419
import static com.unzer.payment.business.BasketV1TestData.getMaxTestBasketV1;
1520
import static com.unzer.payment.business.BasketV1TestData.getMinTestBasketV1;
16-
import static org.junit.jupiter.api.Assertions.*;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNotNull;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
1724

18-
public class BasketV1Test extends AbstractPaymentTest {
25+
class BasketV1Test extends AbstractPaymentTest {
1926

2027
@Test
21-
public void testCreateFetchBasket() {
28+
void testCreateFetchBasket() {
2229
Basket maxBasket = getMaxTestBasketV1();
2330
int basketItemCnt = maxBasket.getBasketItems().size();
2431
for (int i = 0; i < basketItemCnt; i++) {
@@ -76,7 +83,7 @@ private void assertBasketItemEquals(BasketItem expected, BasketItem actual) {
7683
}
7784

7885
@Test
79-
public void testCreateFetchMinBasket() {
86+
void testCreateFetchMinBasket() {
8087
Basket minBasket = getMinTestBasketV1();
8188
Basket basket = getUnzer().createBasket(minBasket);
8289
Basket basketFetched = getUnzer().fetchBasket(basket.getId());
@@ -86,7 +93,7 @@ public void testCreateFetchMinBasket() {
8693
}
8794

8895
@Test
89-
public void testUpdateBasket() {
96+
void testUpdateBasket() {
9097
Basket minBasket = getMinTestBasketV1();
9198
Basket basket = getUnzer().createBasket(minBasket);
9299
Basket basketFetched = getUnzer().fetchBasket(basket.getId());
@@ -99,7 +106,7 @@ public void testUpdateBasket() {
99106
}
100107

101108
@Test
102-
public void testUpdateBasketWithFetched() {
109+
void testUpdateBasketWithFetched() {
103110
Basket minBasket = getMinTestBasketV1();
104111
Basket basket = getUnzer().createBasket(minBasket);
105112
Basket basketFetched = getUnzer().fetchBasket(basket.getId());
@@ -111,7 +118,7 @@ public void testUpdateBasketWithFetched() {
111118
}
112119

113120
@Test
114-
public void testAuthorizationWithBasket()
121+
void testAuthorizationWithBasket()
115122
throws MalformedURLException, HttpCommunicationException {
116123
Basket basket = createMaxTestBasket();
117124
Authorization authorization =
@@ -133,7 +140,7 @@ private Basket createMaxTestBasket() throws PaymentException, HttpCommunicationE
133140
}
134141

135142
@Test
136-
public void testChargeWithBasket() throws MalformedURLException, HttpCommunicationException {
143+
void testChargeWithBasket() throws MalformedURLException, HttpCommunicationException {
137144
Basket basket = createMaxTestBasket();
138145
Charge chargeReq =
139146
getCharge(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, null, null,
@@ -150,7 +157,7 @@ public void testChargeWithBasket() throws MalformedURLException, HttpCommunicati
150157
}
151158

152159
@Test
153-
public void testBasketV2IsPriorVersion() {
160+
void testBasketV2IsPriorVersion() {
154161
Basket basket = new Basket()
155162
.setTotalValueGross(BigDecimal.TEN)
156163
.setAmountTotalGross(BigDecimal.ONE);

0 commit comments

Comments
 (0)