package ru.stqa.pft.addressbook.tests;

import org.testng.Assert;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.GroupData;

import java.util.HashSet;
import java.util.List;

public class GroupModificationTests extends TestBase {

    @Test
    public void testGroupModification() {
        app.getNavigationHelper().goToGroupsPage();
        List<GroupData> before = app.getGroupHelper().getGroupList();
        app.getGroupHelper().selectGroup(before.size() - 1);
        app.getGroupHelper().initGroupModification();
        GroupData group = new GroupData();
        group.setId((before.get(before.size() - 1).getId()));
        group.setName("Modified");
        group.setHeader("Modified");
        group.setFooter("Modified");
        app.getGroupHelper().fillGroupForm(group);
        app.getGroupHelper().submitGroupModification();
        app.getGroupHelper().returnToGroupsPage();
        List<GroupData> after = app.getGroupHelper().getGroupList();
        Assert.assertEquals(after.size(), before.size());

        before.remove(before.size() - 1);
        before.add(group);

        Assert.assertEquals(new HashSet<Object>(before), new HashSet<Object>(after));

        app.getSessionHelper().logout();

    }
}

@@ -144,16 +144,45 @@
 pData;%0A%0A
+import java.util.Comparator;%0A
 import j
@@ -1150,84 +1150,194 @@
     
-Assert.assertEquals(new HashSet%3CObject%3E(before), new HashSet%3CObject%3E(
+Comparator%3C? super GroupData%3E byId = (o1, o2) -%3E Integer.compare(o1.getId(), o2.getId());%0A        before.sort(byId);%0A        after.sort(byId);%0A%0A        Assert.assertEquals(before, 
 after)
-)
 ;%0A%0A 

change group modificationtest assert