package ru.sfwt.mt.addressbook.tests;

import org.testng.Assert;
import org.testng.annotations.Test;
import ru.sfwt.mt.addressbook.model.GroupData;

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("test1", null, null);
    app.getGroupHelper().createGroup(group);
    List<GroupData> after = app.getGroupHelper().getGroupList();
    Assert.assertEquals(after.size(), before.size() +1);


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

@@ -142,16 +142,45 @@
 pData;%0A%0A
+import java.util.Comparator;%0A
 import j
@@ -197,16 +197,16 @@
 ashSet;%0A
-
 import j
@@ -470,17 +470,17 @@
 ta(%22test
-1
+5
 %22, null,
@@ -658,16 +658,18 @@
 1);%0A%0A%0A  
+//
   int ma
@@ -677,16 +677,18 @@
  = 0;%0A  
+//
   for (G
@@ -707,24 +707,26 @@
  after) %7B%0A  
+//
     if (g.ge
@@ -742,16 +742,18 @@
 ax) %7B%0A  
+//
       ma
@@ -769,24 +769,26 @@
 Id();%0A  
+//
     %7D%0A  
   %7D%0A    
@@ -779,20 +779,23 @@
     %7D%0A  
+//
   %7D%0A
+%0A
     grou
@@ -802,19 +802,125 @@
 p.setId(
-max
+after.stream().max((Comparator%3CGroupData%3E) (o1, o2) -%3E Integer.compare(o1.getId(), o2.getId())).get().getId()
 );%0A    b

Create lambda instead of IF in GroupCreationTest