package edu.cmu.sv.ws.ssnoc.test;

import com.eclipsesource.restfuse.*;
import com.eclipsesource.restfuse.annotation.Context;
import com.eclipsesource.restfuse.annotation.HttpTest;
import edu.cmu.sv.ws.ssnoc.common.logging.Log;
import edu.cmu.sv.ws.ssnoc.control.GroupSegregate;
import edu.cmu.sv.ws.ssnoc.data.po.ChatBuddyPO;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;

import java.util.HashSet;
import java.util.Set;

import static com.eclipsesource.restfuse.Assert.*;


public class GroupIDTest {

    @Test
    public void checkSegregatedGroupResultForFourUsers(){
        GroupSegregate gsControl = GroupSegregate.getInstance();

        Set<String> initialGroup = new HashSet<String>();
        initialGroup.add("A");
        initialGroup.add("B");
        initialGroup.add("C");
        initialGroup.add("D");

        gsControl.setFullUserList(initialGroup);
        Set<ChatBuddyPO> chatBoddyList = new HashSet<ChatBuddyPO>();
        ChatBuddyPO chatBuddyPO = new ChatBuddyPO();
        chatBuddyPO.setAuthorName("A");
        chatBuddyPO.setTargetName("B");
        chatBoddyList.add(chatBuddyPO);

        ChatBuddyPO chatBuddyPO2 = new ChatBuddyPO();
        chatBuddyPO2.setAuthorName("B");
        chatBuddyPO2.setTargetName("C");
        chatBoddyList.add(chatBuddyPO2);
        gsControl.setChatBuddyPOs(chatBoddyList);

        Set<Set<String>> result = gsControl.getSegregatedGroups(null);

        Set<String> list1 = new HashSet<String>();
        list1.add("A");
        list1.add("C");
        list1.add("D");

        Set<String> list2 = new HashSet<String>();
        list1.add("B");

        Set<String> list3 = new HashSet<String>();
        list1.add("C");
        list1.add("D");

        assertTrue(result.contains(list1));
        assertTrue(result.contains(list2));
        assertTrue(result.contains(list3));
    }

    @Test
    public void checkSegregatedGroupResultForFiveUsers(){
        GroupSegregate gsControl = GroupSegregate.getInstance();

        Set<String> initialGroup = new HashSet<String>();
        initialGroup.add("A");
        initialGroup.add("B");
        initialGroup.add("C");
        initialGroup.add("D");
        initialGroup.add("E");

        gsControl.setFullUserList(initialGroup);
        Set<ChatBuddyPO> chatBoddyList = new HashSet<ChatBuddyPO>();
        ChatBuddyPO chatBuddyPO = new ChatBuddyPO();
        chatBuddyPO.setAuthorName("A");
        chatBuddyPO.setTargetName("B");
        chatBoddyList.add(chatBuddyPO);

        ChatBuddyPO chatBuddyPO2 = new ChatBuddyPO();
        chatBuddyPO2.setAuthorName("B");
        chatBuddyPO2.setTargetName("C");
        chatBoddyList.add(chatBuddyPO2);
        gsControl.setChatBuddyPOs(chatBoddyList);

        ChatBuddyPO chatBuddyPO3 = new ChatBuddyPO();
        chatBuddyPO3.setAuthorName("D");
        chatBuddyPO3.setTargetName("E");
        chatBoddyList.add(chatBuddyPO2);
        gsControl.setChatBuddyPOs(chatBoddyList);

        Set<Set<String>> result = gsControl.getSegregatedGroups(null);

        Set<String> list1 = new HashSet<String>();
        list1.add("A");
        list1.add("C");
        list1.add("D");

        Set<String> list2 = new HashSet<String>();
        list1.add("A");
        list1.add("C");
        list1.add("E");

        Set<String> list3 = new HashSet<String>();
        list1.add("B");
        list1.add("D");

        Set<String> list4 = new HashSet<String>();
        list1.add("B");
        list1.add("E");

        assertTrue(result.contains(list1));
        assertTrue(result.contains(list2));
        assertTrue(result.contains(list3));
        assertTrue(result.contains(list4));
    }
}

@@ -651,24 +651,25 @@
 rFourUsers()
+ 
 %7B%0A        Gr
@@ -1678,33 +1678,33 @@
 ();%0A        list
-1
+2
 .add(%22B%22);%0A%0A    
@@ -1694,33 +1694,32 @@
 2.add(%22B%22);%0A
-%0A
         
 Set%3CString%3E 
@@ -1710,83 +1710,33 @@
     
-Set%3CString%3E list3 = new HashSet%3CString%3E();%0A        list1
+list2
 .add(%22
-C
+D
 %22);%0A
+%0A
         
 list
@@ -1731,33 +1731,48 @@
         
-list1.add(%22D%22
+assertEquals(result.size(), 2
 );%0A
-%0A
         
@@ -1855,52 +1855,8 @@
 ));%0A
-        assertTrue(result.contains(list3));%0A
     
@@ -3205,33 +3205,33 @@
 ();%0A        list
-1
+2
 .add(%22A%22);%0A     
@@ -3229,33 +3229,33 @@
 %22);%0A        list
-1
+2
 .add(%22C%22);%0A     
@@ -3253,33 +3253,33 @@
 %22);%0A        list
-1
+2
 .add(%22E%22);%0A%0A    
@@ -3329,33 +3329,33 @@
 ();%0A        list
-1
+3
 .add(%22B%22);%0A     
@@ -3353,33 +3353,33 @@
 %22);%0A        list
-1
+3
 .add(%22D%22);%0A%0A    
@@ -3433,25 +3433,25 @@
         list
-1
+4
 .add(%22B%22);%0A 
@@ -3457,25 +3457,25 @@
         list
-1
+4
 .add(%22E%22);%0A%0A
@@ -3466,32 +3466,72 @@
 ist4.add(%22E%22);%0A%0A
+        assertEquals(result.size(), 4);%0A
         assertTr

Modify unit test for segregated groups.