@@ -26,10 +26,10 @@ void setUp() {
2626 ScamBlockerConfig scamConfig = mock (ScamBlockerConfig .class );
2727 when (config .getScamBlocker ()).thenReturn (scamConfig );
2828
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" ));
3333 when (scamConfig .getHostWhitelist ()).thenReturn (Set .of ("discord.com" , "discord.media" ,
3434 "discordapp.com" , "discordapp.net" , "discordstatus.com" ));
3535 when (scamConfig .getHostBlacklist ()).thenReturn (Set .of ("bit.ly" , "discord.gg" , "teletype.in" ,
@@ -54,6 +54,18 @@ void detectsRealScam(String scamMessage) {
5454 assertTrue (isScamResult );
5555 }
5656
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+
5769 @ Test
5870 @ DisplayName ("Can detect messages that contain blacklisted websites as scam" )
5971 void detectsBlacklistedWebsite () {
@@ -227,4 +239,10 @@ private static List<String> provideRealScamMessages() {
227239 "Urgently looking for mods & collab managers https://discord.gg/cryptohireo" ,
228240 "Check this - https://transfer.sh/get/ajmkh3l7tzop/Setup.exe" );
229241 }
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+ }
230248}
0 commit comments