package com.ksu.addressbook.tests;

import com.ksu.addressbook.model.GroupData;
import org.testng.Assert;
import org.testng.annotations.Test;

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

public class GroupCreationTests extends TestBase{

    @Test
    public void testGroupCreation() {

        app.getNavigationHelper().goToGroupPage();
        List<GroupData> before = app.getGroupHelper().getGroupList();
        GroupData group = new GroupData("Group1", "The first Group", "My first group");
        app.getGroupHelper().createGroup(group);
        List<GroupData> after = app.getGroupHelper().getGroupList();
        Assert.assertEquals(after.size(), before.size() + 1);

        int max = 0;
        for (GroupData g: after){
            max = g.getId() > max ? g.getId() : max;
        }
        group.setId(max);
        before.add(group);
        Assert.assertEquals(new HashSet<GroupData>(before), new HashSet<GroupData>(after));
    }

}

@@ -136,16 +136,45 @@
 .Test;%0A%0A
+import java.util.Comparator;%0A
 import j
@@ -213,16 +213,47 @@
 il.List;
+%0Aimport java.util.zip.Inflater;
 %0A%0Apublic
@@ -736,16 +736,35 @@
  + 1);%0A%0A
+//        Way 1:%0A//
         
@@ -776,16 +776,18 @@
 ax = 0;%0A
+//
         
@@ -812,16 +812,18 @@
 after)%7B%0A
+//
         
@@ -867,16 +867,18 @@
  : max;%0A
+//
         
@@ -883,31 +883,570 @@
   %7D%0A
-        group.setId(max
+%0A//        Way 2:%0A//        Comparator%3C? super GroupData%3E byId = new Comparator%3CGroupData%3E() %7B%0A//            @Override%0A//            public int compare(GroupData o1, GroupData o2) %7B%0A//                return Integer.compare(o1.getId(), o2.getId());%0A//            %7D%0A//        %7D ;%0A//        int max = after.stream().max(byId).get().getId();%0A%0A//        Way 3:%0A//        Comparator%3C? super GroupData%3E byId = (o1, o2) -%3E Integer.compare(o1.getId(), o2.getId());%0A%0A        group.setId(after.stream().max((o1, o2) -%3E Integer.compare(o1.getId(), o2.getId())).get().getId()
 );%0A 

Change the way of getting max groupId (loop changed to stream max with lambda)