package com.stqa.pft.tests;

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

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



/**
 * Created by Andrew on 4/6/2017.
 */
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));
  }
}


@@ -122,16 +122,45 @@
 .Test;%0A%0A
+import java.util.Comparator;%0A
 import j
@@ -686,143 +686,109 @@
 );%0A%0A
-%0A
     
-int max = 0;%0A    for (GroupData g : after)%7B%0A      if (g.getId() %3E max)%7B%0A        max = g.getId();%0A      %7D%0A    %7D%0A    group.s
+group.setId(after.stream().max((o1, o2) -%3E Integer.compare(o1.getId(), o2.getId())).get().g
 etId(
-max
+)
 );%0A 

Add comparator and lambda