// Path: vilebot/src/main/java/com/oldterns/vilebot/util/MangleNicks.java
// public class MangleNicks
// {
// 
//     public static String mangleNicks( MessageEvent event, String message )
//     {
//         return mangleNicks( event.getChannel().getUsersNicks(), message );
//     }
// 
//     public static String mangleNicks( JoinEvent event, String message )
//     {
//         return mangleNicks( event.getChannel().getUsersNicks(), message );
//     }
// 
//     public static String mangleNicks( PrivateMessageEvent event, String message )
//     {
//         return mangleNicks( ImmutableSortedSet.of( Objects.requireNonNull( event.getUser() ).getNick() ), message );
//     }
// 
//     public static String mangleNicks( GenericMessageEvent event, String message )
//     {
//         if ( event instanceof MessageEvent )
//         {
//             return mangleNicks( (MessageEvent) event, message );
//         }
//         else if ( event instanceof JoinEvent )
//         {
//             return mangleNicks( (JoinEvent) event, message );
//         }
//         else if ( event instanceof PrivateMessageEvent )
//         {
//             return mangleNicks( (PrivateMessageEvent) event, message );
//         }
//         else
//         {
//             return mangleNicks( ImmutableSortedSet.of(), message );
//         }
//     }
// 
//     private static String mangleNicks( ImmutableSortedSet<String> nicks, String message )
//     {
// 
//         if ( nicks.isEmpty() )
//         {
//             return message;
//         }
// 
//         StringBuilder reply = new StringBuilder();
//         for ( String word : message.split( " " ) )
//         {
//             reply.append( " " );
//             reply.append( inside( nicks, word ) ? mangled( word ) : word );
//         }
//         return reply.toString().trim();
//     }
// 
//     private static String mangled( String word )
//     {
//         return new StringBuilder( word ).reverse().toString();
//     }
// 
//     private static boolean inside( ImmutableSortedSet<String> nicks, String word )
//     {
//         for ( String nick : nicks )
//         {
//             if ( word.contains( nick ) )
//             {
//                 return true;
//             }
//         }
//         return false;
//     }
// }


import com.google.common.collect.ImmutableSortedSet;
import com.oldterns.vilebot.util.MangleNicks;
import org.junit.Before;
import org.junit.Test;
import org.pircbotx.Channel;
import org.pircbotx.PircBotX;
import org.pircbotx.hooks.events.JoinEvent;
import org.pircbotx.hooks.events.MessageEvent;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package vilebot.util;



public class MangleNicksTest
{

    private MessageEvent rcvPrivMsg;

    private JoinEvent rcvJoin;

    private ImmutableSortedSet<String> nickList = ImmutableSortedSet.of( "salman", "sasiddiq" );

    @Before
    public void setup()
    {
        Channel chan = mock( Channel.class );
        rcvPrivMsg = mock( MessageEvent.class );
        rcvJoin = mock( JoinEvent.class );
        when( rcvPrivMsg.getChannel() ).thenReturn( chan );
        when( rcvJoin.getChannel() ).thenReturn( chan );
        when( chan.getUsersNicks() ).thenReturn( nickList );
    }

    @Test
    public void noNicks()
    {
        String messageText = "i am the karma police";
        String returnText1 = MangleNicks.mangleNicks( rcvPrivMsg, messageText );
        String returnText2 = MangleNicks.mangleNicks( rcvJoin, messageText );

        assertEquals( returnText1, messageText );
        assertEquals( returnText2, messageText );
    }

    @Test
    public void oneNick()
    {
        String messageText = "salman is a man of many bots";
// Path: vilebot/src/main/java/com/oldterns/vilebot/util/MangleNicks.java
// public class MangleNicks
// {
// 
//     public static String mangleNicks( MessageEvent event, String message )
//     {
//         return mangleNicks( event.getChannel().getUsersNicks(), message );
//     }
// 
//     public static String mangleNicks( JoinEvent event, String message )
//     {
//         return mangleNicks( event.getChannel().getUsersNicks(), message );
//     }
// 
//     public static String mangleNicks( PrivateMessageEvent event, String message )
//     {
//         return mangleNicks( ImmutableSortedSet.of( Objects.requireNonNull( event.getUser() ).getNick() ), message );
//     }
// 
//     public static String mangleNicks( GenericMessageEvent event, String message )
//     {
//         if ( event instanceof MessageEvent )
//         {
//             return mangleNicks( (MessageEvent) event, message );
//         }
//         else if ( event instanceof JoinEvent )
//         {
//             return mangleNicks( (JoinEvent) event, message );
//         }
//         else if ( event instanceof PrivateMessageEvent )
//         {
//             return mangleNicks( (PrivateMessageEvent) event, message );
//         }
//         else
//         {
//             return mangleNicks( ImmutableSortedSet.of(), message );
//         }
//     }
// 
//     private static String mangleNicks( ImmutableSortedSet<String> nicks, String message )
//     {
// 
//         if ( nicks.isEmpty() )
//         {
//             return message;
//         }
// 
//         StringBuilder reply = new StringBuilder();
//         for ( String word : message.split( " " ) )
//         {
//             reply.append( " " );
//             reply.append( inside( nicks, word ) ? mangled( word ) : word );
//         }
//         return reply.toString().trim();
//     }
// 
//     private static String mangled( String word )
//     {
//         return new StringBuilder( word ).reverse().toString();
//     }
// 
//     private static boolean inside( ImmutableSortedSet<String> nicks, String word )
//     {
//         for ( String nick : nicks )
//         {
//             if ( word.contains( nick ) )
//             {
//                 return true;
//             }
//         }
//         return false;
//     }
// }


// Path: vilebot/src/test/java/vilebot/util/MangleNicksTest.java
import com.google.common.collect.ImmutableSortedSet;
import com.oldterns.vilebot.util.MangleNicks;
import org.junit.Before;
import org.junit.Test;
import org.pircbotx.Channel;
import org.pircbotx.PircBotX;
import org.pircbotx.hooks.events.JoinEvent;
import org.pircbotx.hooks.events.MessageEvent;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

package vilebot.util;



public class MangleNicksTest
{

    private MessageEvent rcvPrivMsg;

    private JoinEvent rcvJoin;

    private ImmutableSortedSet<String> nickList = ImmutableSortedSet.of( "salman", "sasiddiq" );

    @Before
    public void setup()
    {
        Channel chan = mock( Channel.class );
        rcvPrivMsg = mock( MessageEvent.class );
        rcvJoin = mock( JoinEvent.class );
        when( rcvPrivMsg.getChannel() ).thenReturn( chan );
        when( rcvJoin.getChannel() ).thenReturn( chan );
        when( chan.getUsersNicks() ).thenReturn( nickList );
    }

    @Test
    public void noNicks()
    {
        String messageText = "i am the karma police";
        String returnText1 = MangleNicks.mangleNicks( rcvPrivMsg, messageText );
        String returnText2 = MangleNicks.mangleNicks( rcvJoin, messageText );

        assertEquals( returnText1, messageText );
        assertEquals( returnText2, messageText );
    }

    @Test
    public void oneNick()
    {
        String messageText = "salman is a man of many bots";
        String returnText1 = MangleNicks.mangleNicks( rcvPrivMsg, messageText );