File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed
main/java/de/rieckpil/blog/pit
test/java/de/rieckpil/blog/pit Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 453
453
<version >1.2.1</version >
454
454
</dependency >
455
455
</dependencies >
456
+ <configuration >
457
+ <targetClasses >
458
+ <param >de.rieckpil.blog.pit.*</param >
459
+ </targetClasses >
460
+ <targetTests >
461
+ <param >de.rieckpil.blog.pit.*Test</param >
462
+ </targetTests >
463
+ </configuration >
456
464
</plugin >
457
465
</plugins >
458
466
</build >
Original file line number Diff line number Diff line change
1
+ package de .rieckpil .blog .pit ;
2
+
3
+ import java .util .Set ;
4
+
5
+ public class FraudDetector {
6
+
7
+ private static final Set <String > HIGH_RISK_COUNTRIES =
8
+ Set .of ("WONDERLAND" , "MARS" , "URANUS" );
9
+
10
+ public boolean isFraudulentTransaction (double amount , String country ) {
11
+ // Any transaction above 10k is flagged
12
+ if (amount > 10_000 ) {
13
+ return true ;
14
+ }
15
+
16
+ // Transactions from high-risk countries are flagged
17
+ if (HIGH_RISK_COUNTRIES .contains (country )) {
18
+ return true ;
19
+ }
20
+
21
+ return false ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ package de .rieckpil .blog .pit ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+
5
+ import static org .junit .jupiter .api .Assertions .*;
6
+
7
+ import static org .assertj .core .api .Assertions .assertThat ;
8
+ import static org .junit .jupiter .api .Assertions .*;
9
+ import static org .mockito .ArgumentMatchers .*;
10
+ import static org .mockito .Mockito .when ;
11
+ import static org .mockito .Mockito .verify ;
12
+
13
+ class FraudDetectorTest {
14
+
15
+ @ Test
16
+ void testHighAmountTransaction () {
17
+ FraudDetector detector = new FraudDetector ();
18
+
19
+ assertTrue (detector .isFraudulentTransaction (15_000 , "USA" ));
20
+ }
21
+
22
+ @ Test
23
+ void testHighRiskCountryTransaction () {
24
+ FraudDetector detector = new FraudDetector ();
25
+
26
+ assertTrue (detector .isFraudulentTransaction (500 , "MARS" ));
27
+ }
28
+
29
+ @ Test
30
+ void testSafeTransaction () {
31
+ FraudDetector cut = new FraudDetector ();
32
+
33
+ assertFalse (cut .isFraudulentTransaction (200 , "USA" ));
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments