Skip to content

Commit 9ead9a0

Browse files
authored
[CC-000] Adjust upl config url validation due upl api response changes. (#181)
1 parent 5d506a9 commit 9ead9a0

1 file changed

Lines changed: 22 additions & 38 deletions

File tree

src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInvoiceTest.java

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@
3434
import static org.junit.jupiter.api.Assertions.assertFalse;
3535
import static org.junit.jupiter.api.Assertions.assertNotNull;
3636
import static org.junit.jupiter.api.Assertions.assertNull;
37+
import static org.junit.jupiter.api.Assertions.assertTrue;
3738
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
3839

3940

4041
class PaylaterInvoiceTest extends AbstractPaymentTest {
42+
43+
public static final String UPL_CONFIG_DOMAIN = "https://test-payment.paylater.unzer.com/";
44+
4145
@Test
4246
void testCreatePaylaterType() {
4347
PaylaterInvoice paylaterInvoice = getUnzer().createPaymentType(new PaylaterInvoice());
@@ -418,71 +422,43 @@ class TestCase {
418422
final String name;
419423
final CustomerType customerType;
420424
final Locale locale;
421-
final PaylaterInvoiceConfig expectedConfig;
422425

423-
public TestCase(String name, CustomerType customerType, Locale locale,
424-
PaylaterInvoiceConfig expectedConfig) {
426+
public TestCase(String name, CustomerType customerType, Locale locale) {
425427
this.name = name;
426428
this.customerType = customerType;
427429
this.locale = locale;
428-
this.expectedConfig = expectedConfig;
429430
}
430431
}
431432

432433
return Stream.of(
433434
new TestCase(
434435
"B2B Germany",
435436
CustomerType.B2B,
436-
Locale.GERMANY,
437-
new PaylaterInvoiceConfig(
438-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacyconsent?channelId=unzerupl-invoice-b2b-b2c",
439-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacydeclaration?channelId=unzerupl-invoice-b2b-b2c",
440-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/termsandconditions?channelId=unzerupl-invoice-b2b-b2c"
441-
)
437+
Locale.GERMANY
442438
),
443439

444440
new TestCase(
445441
"B2C Germany",
446442
CustomerType.B2C,
447-
Locale.GERMANY,
448-
new PaylaterInvoiceConfig(
449-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacyconsent?channelId=unzerupl-invoice-b2b-b2c",
450-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacydeclaration?channelId=unzerupl-invoice-b2b-b2c",
451-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/termsandconditions?channelId=unzerupl-invoice-b2b-b2c"
452-
)
443+
Locale.GERMANY
453444
),
454445

455446
new TestCase(
456447
"B2C Italy",
457448
CustomerType.B2C,
458-
Locale.ITALY,
459-
new PaylaterInvoiceConfig(
460-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacyconsent?channelId=unzerupl-invoice-b2b-b2c",
461-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacydeclaration?channelId=unzerupl-invoice-b2b-b2c",
462-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/termsandconditions?channelId=unzerupl-invoice-b2b-b2c"
463-
)
449+
Locale.ITALY
464450
),
465451

466452
new TestCase(
467453
"Null locale",
468454
CustomerType.B2C,
469-
null,
470-
new PaylaterInvoiceConfig(
471-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacyconsent?channelId=unzerupl-invoice-b2b-b2c",
472-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacydeclaration?channelId=unzerupl-invoice-b2b-b2c",
473-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/termsandconditions?channelId=unzerupl-invoice-b2b-b2c"
474-
)
455+
null
475456
),
476457

477458
new TestCase(
478459
"Not a country",
479460
CustomerType.B2C,
480-
Locale.ENGLISH,
481-
new PaylaterInvoiceConfig(
482-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacyconsent?channelId=unzerupl-invoice-b2b-b2c",
483-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/dataprivacydeclaration?channelId=unzerupl-invoice-b2b-b2c",
484-
"https://test-payment.paylater.unzer.com/payolution-payment/infoport/termsandconditions?channelId=unzerupl-invoice-b2b-b2c"
485-
)
461+
Locale.ENGLISH
486462
)
487463
).map(tc -> dynamicTest(tc.name, () -> {
488464
Unzer unzer = getUnzer();
@@ -491,10 +467,18 @@ public TestCase(String name, CustomerType customerType, Locale locale,
491467
unzer.fetchPaylaterConfig(CustomerType.B2C, Locale.GERMANY);
492468

493469
assertNotNull(actualConfig);
494-
assertEquals(tc.expectedConfig.getDataPrivacyConsent(), actualConfig.getDataPrivacyConsent());
495-
assertEquals(tc.expectedConfig.getDataPrivacyDeclaration(),
496-
actualConfig.getDataPrivacyDeclaration());
497-
assertEquals(tc.expectedConfig.getTermsAndConditions(), actualConfig.getTermsAndConditions());
470+
471+
String consentUrl = actualConfig.getDataPrivacyConsent();
472+
String declarationURL = actualConfig.getDataPrivacyDeclaration();
473+
String termsUrl = actualConfig.getTermsAndConditions();
474+
475+
assertNotNull(consentUrl);
476+
assertNotNull(declarationURL);
477+
assertNotNull(termsUrl);
478+
479+
assertTrue(consentUrl.startsWith(UPL_CONFIG_DOMAIN));
480+
assertTrue(declarationURL.startsWith(UPL_CONFIG_DOMAIN));
481+
assertTrue(termsUrl.startsWith(UPL_CONFIG_DOMAIN));
498482
})
499483
).collect(Collectors.toList());
500484
}

0 commit comments

Comments
 (0)