package ru.sfwt.mt.addressbook.tests;

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

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

public class AddressCreationTests extends TestBase{

  @Test
  public void testAddressCreation() {
    app.getNavigationHelper().gotoHomePage();
    List<AddressData> before = app.getContactHelper().getAddressList();
    app.getNavigationHelper().gotoAddreessCreationPage();
    AddressData address = new AddressData("name", "last", null, null, null, null, null, null, null,"test1");
    app.getContactHelper().createAddress(address);
    app.getNavigationHelper().gotoHomePage();
    List<AddressData> after = app.getContactHelper().getAddressList();
    Assert.assertEquals(after.size(), before.size() + 1);

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

}

@@ -144,16 +144,45 @@
 sData;%0A%0A
+import java.util.Comparator;%0A
 import j
@@ -838,16 +838,18 @@
 );%0A%0A    
+//
 int max 
@@ -857,16 +857,18 @@
  0;%0A    
+//
 for (Add
@@ -893,16 +893,18 @@
 ) %7B%0A    
+//
   if (g.
@@ -924,16 +924,18 @@
 ) %7B%0A    
+//
     max 
@@ -951,24 +951,26 @@
 ();%0A    
+//
   %7D%0A    
 %7D%0A    ad
@@ -965,31 +965,434 @@
     
+//
 %7D%0A    
-address.setId(max
+//Comparator%3C? super AddressData%3E byId = (Comparator%3CAddressData%3E) (o1, o2) -%3E Integer.compare(o1.getId(), o2.getId());%0A    //int max1 = after.stream().max((Comparator%3CAddressData%3E) (o1, o2) -%3E Integer.compare(o1.getId(), o2.getId())).get().getId();%0A    //address.setId(max1);%0A    address.setId(after.stream().max((Comparator%3CAddressData%3E) (o1, o2) -%3E%0A            Integer.compare(o1.getId(), o2.getId())).get().getId()
 );%0A 

Create lambda instead of If in AddressCreationTests