<commit_before>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("<EMAIL>")
                .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);
    }

}
<commit_msg>fix problem with max id in contacts creation test<commit_after>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()
                .withFirstname(rnd.getFirstnameEng())
                .withMiddlename("E.")
                .withLastname(rnd.getSurnameEng())
                .withTitle("Dr.")
                .withAddress(rnd.getAddressEng())
                .withHomePhone("9(2131)324-33-33")
                .withEmail("<EMAIL>")
                .withGroup(groupName);
        app.contact().create(contact);

        // assertions

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

        contact.withId(contactsAfter.stream().mapToInt((c) -> c.getId()).max().getAsInt());
        contactsBefore.add(contact);
        Assert.assertEquals(contactsAfter, contactsBefore);
    }

}

{'fraction_non_alphanumeric': 0.12598655363928676, 'fraction_numerical': 0.008184741303712365, 'mean_word_length': 2.655982905982906, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1094155', 'n_tokens_mistral': 1008, 'n_tokens_neox': 971, 'n_words': 155}