Skip to content

Commit fe0ae58

Browse files
committed
add PIT
1 parent 6aa3f47 commit fe0ae58

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

spring-boot-example/src/main/java/de/rieckpil/blog/pit/FraudDetector.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public class FraudDetector {
88
Set.of("WONDERLAND", "MARS", "URANUS");
99

1010
public boolean isFraudulentTransaction(double amount, String country) {
11-
// Any transaction above 10k is flagged
12-
if (amount > 10_000) {
11+
// Transactions from high-risk countries are flagged
12+
if (HIGH_RISK_COUNTRIES.contains(country)) {
1313
return true;
1414
}
1515

16-
// Transactions from high-risk countries are flagged
17-
if (HIGH_RISK_COUNTRIES.contains(country)) {
16+
// Any transaction above 10k is flagged
17+
if (amount > 10_000) {
1818
return true;
1919
}
2020

spring-boot-example/src/test/java/de/rieckpil/blog/pit/FraudDetectorTests.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,26 @@
1313
class FraudDetectorTest {
1414

1515
@Test
16-
void testHighAmountTransaction() {
16+
void highAmountTransactionShouldBeFraudulent() {
1717
FraudDetector detector = new FraudDetector();
18-
1918
assertTrue(detector.isFraudulentTransaction(15_000, "USA"));
2019
}
2120

2221
@Test
23-
void testHighRiskCountryTransaction() {
22+
void highRiskCountryTransactionShouldBeFraudulent() {
2423
FraudDetector detector = new FraudDetector();
25-
2624
assertTrue(detector.isFraudulentTransaction(500, "MARS"));
2725
}
2826

29-
@Test
30-
void testSafeTransaction() {
31-
FraudDetector cut = new FraudDetector();
32-
33-
assertFalse(cut.isFraudulentTransaction(200, "USA"));
34-
}
27+
// @Test
28+
// void lowAmountTransactionShouldNotBeFraudulent() {
29+
// FraudDetector detector = new FraudDetector();
30+
// assertFalse(detector.isFraudulentTransaction(1_000, "USA"));
31+
// }
32+
//
33+
// @Test
34+
// void thresholdAmountTransactionShouldNotBeFraudulent() {
35+
// FraudDetector detector = new FraudDetector();
36+
// assertFalse(detector.isFraudulentTransaction(10_000, "GER"));
37+
// }
3538
}

0 commit comments

Comments
 (0)