package ru.stqa.pft.addressbook.tests;

import javafx.scene.effect.SepiaTone;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.ContactData;
import ru.stqa.pft.addressbook.model.GroupData;

import java.util.Comparator;
import java.util.List;
import java.util.Set;

public class ContactCreationTests extends TestBase {
    private String groupName = "test1";

    @BeforeClass
    public void ensurePreconditions() {
        app.navigateTo().groupPage();
        if (! app.group().doesExist(groupName)) {
            GroupData groupData = new GroupData().withName(groupName);
            app.group().create(groupData);
        }
    }
    
    @Test
    public void testContactCreation() {
        app.navigateTo().home();
        Set<ContactData> contactsBefore = app.contact().hashSet();
        ContactData contact = new ContactData()
                .withId(Integer.MAX_VALUE)
                .withFirstname(rnd.getFirstnameEng())
                .withMiddlename("E.")
                .withLastname(rnd.getSurnameEng())
                .withTitle("Dr.")
                .withAddress(rnd.getAddressEng())
                .withHomePhone("9(2131)324-33-33")
                .withEmail("test@test.ts")
                .withGroup(groupName);
        app.contact().create(contact);

        // assertions

        Set<ContactData> contactsAfter = app.contact().hashSet();
        Assert.assertEquals(contactsAfter.size(), contactsBefore.size() + 1);

        contactsBefore.add(contact);
        Assert.assertEquals(contactsAfter, contactsBefore);
    }

}

@@ -926,51 +926,8 @@
 a()%0A
-                .withId(Integer.MAX_VALUE)%0A
     
@@ -1486,24 +1486,116 @@
 ze() + 1);%0A%0A
+        contact.withId(contactsAfter.stream().mapToInt((c) -%3E c.getId()).max().getAsInt());%0A
         cont

fix problem with max id in contacts creation test