<commit_before>package com.gosch.addressbook.tests;

import com.gosch.addressbook.models.ContactData;
import com.gosch.addressbook.models.GroupData;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

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

public class ContactCreationTests extends TestBase {

    private final GroupData groupData1 = new GroupData().withName("test1");

    @BeforeMethod
    public void ensurePreconditions() {
        app.goTo().groupPage();
        if (!app.group().list().contains(groupData1)) {
            app.group().create(new GroupData().withName(groupData1.getName()));
        }
    }

    @Test(enabled = true)
    public void ContactCreationTests() {
        app.goTo().homePage();
        List<ContactData> before = app.contact().list();

        app.goTo().contactCreationPage();
        ContactData contact = new ContactData()
                .withFirstName("Georgi")
                .withLastName("Voronov")
                .withMobile("53089127")
                .withEmail("<EMAIL>")
                .withGroup(groupData1.getName());
        app.contact().create(contact, true);

        List<ContactData> after = app.contact().list();
        Assert.assertEquals(after.size(), before.size() + 1);

        contact.withId(after.stream().max((c1, c2) -> Integer.compare(c1.getId(), c2.getId())).get().getId());
        before.add(contact);
        Comparator<? super ContactData> byId = (g1, g2) -> Integer.compare(g1.getId(), g2.getId());
        before.sort(byId);
        after.sort(byId);
        Assert.assertEquals(before, after);
    }

}<commit_msg>Contacts: Optimized preconditions for ContactCreationTest<commit_after>package com.gosch.addressbook.tests;

import com.gosch.addressbook.models.ContactData;
import com.gosch.addressbook.models.GroupData;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

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

public class ContactCreationTests extends TestBase {

    private final String groupName = "test1";

    @BeforeMethod
    public void ensurePreconditions() {
        app.goTo().groupPage();
        if (!app.group().list().stream().anyMatch(item -> groupName.equals(item.getName()))) {
            app.group().create(new GroupData().withName(groupName));
        }
    }

    @Test(enabled = true)
    public void ContactCreationTests() {
        app.goTo().homePage();
        List<ContactData> before = app.contact().list();

        app.goTo().contactCreationPage();
        ContactData contact = new ContactData()
                .withFirstName("Georgi")
                .withLastName("Voronov")
                .withMobile("53089127")
                .withEmail("<EMAIL>")
                .withGroup(groupName);
        app.contact().create(contact, true);

        List<ContactData> after = app.contact().list();
        Assert.assertEquals(after.size(), before.size() + 1);

        contact.withId(after.stream().max((c1, c2) -> Integer.compare(c1.getId(), c2.getId())).get().getId());
        before.add(contact);
        Comparator<? super ContactData> byId = (g1, g2) -> Integer.compare(g1.getId(), g2.getId());
        before.sort(byId);
        after.sort(byId);
        Assert.assertEquals(before, after);
    }

}
{'fraction_non_alphanumeric': 0.14822546972860126, 'fraction_numerical': 0.011929615269907545, 'mean_word_length': 2.9320046893317704, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, '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': '4234739', 'n_tokens_mistral': 992, 'n_tokens_neox': 968, 'n_words': 164}