@@ -26,10 +26,10 @@ void setUp() {
26
26
ScamBlockerConfig scamConfig = mock (ScamBlockerConfig .class );
27
27
when (config .getScamBlocker ()).thenReturn (scamConfig );
28
28
29
- when (scamConfig .getSuspiciousKeywords ())
30
- . thenReturn ( Set . of ( "nitro " , "boob " , "sexy " , "sexi " , "esex " , "steam " , "gift " , "onlyfans " ,
31
- "bitcoin " , "btc " , "promo " , "trader " , "trading " , "whatsapp " , "crypto" , "claim " ,
32
- "teen" , "adobe" , "hack" , "steamcommunity" , " freenitro" , "usd" , "earn" , ".exe" ));
29
+ when (scamConfig .getSuspiciousKeywords ()). thenReturn ( Set . of ( "nitro" , "boob" , "sexy" , "sexi" ,
30
+ "esex " , "steam " , "gift " , "onlyfans " , "bitcoin " , "btc " , "promo " , "trader" , "trading " ,
31
+ "whatsapp " , "crypto " , "claim " , "teen " , "adobe " , "hack " , "steamcommunity " ,
32
+ " freenitro" , "usd" , "^ earn" , ".exe" ));
33
33
when (scamConfig .getHostWhitelist ()).thenReturn (Set .of ("discord.com" , "discord.media" ,
34
34
"discordapp.com" , "discordapp.net" , "discordstatus.com" ));
35
35
when (scamConfig .getHostBlacklist ()).thenReturn (Set .of ("bit.ly" , "discord.gg" , "teletype.in" ,
@@ -54,6 +54,18 @@ void detectsRealScam(String scamMessage) {
54
54
assertTrue (isScamResult );
55
55
}
56
56
57
+ @ ParameterizedTest
58
+ @ MethodSource ("provideRealFalsePositiveMessages" )
59
+ @ DisplayName ("Can ignore real false positive messages" )
60
+ void ignoresFalsePositives (String falsePositiveMessage ) {
61
+ // GIVEN a real false positive message
62
+ // WHEN analyzing it
63
+ boolean isScamResult = scamDetector .isScam (falsePositiveMessage );
64
+
65
+ // THEN does not flag it as scam
66
+ assertFalse (isScamResult );
67
+ }
68
+
57
69
@ Test
58
70
@ DisplayName ("Can detect messages that contain blacklisted websites as scam" )
59
71
void detectsBlacklistedWebsite () {
@@ -227,4 +239,10 @@ private static List<String> provideRealScamMessages() {
227
239
"Urgently looking for mods & collab managers https://discord.gg/cryptohireo" ,
228
240
"Check this - https://transfer.sh/get/ajmkh3l7tzop/Setup.exe" );
229
241
}
242
+
243
+ private static List <String > provideRealFalsePositiveMessages () {
244
+ return List
245
+ .of ("""
246
+ https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/anonymous-types""" );
247
+ }
230
248
}
0 commit comments