<commit_before>package ru.stqa.pft.addressbook.tests;

import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.ContactData;
import ru.stqa.pft.addressbook.model.Contacts;

import java.io.File;
import java.util.Set;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

public class ContactCreationTests extends TestBase{

    @Test
    public void testContactCreation() {
        app.goTo().homePage();
        Contacts before = app.contact().getAll();
        File photo = new File("src/test/resources/473.gif");
        ContactData contact = new ContactData().withName("name").withMiddleName("maname").withLastName("<NAME>")
                .withNickname("nickname").withTitle("title").withCompany("company").withAddress("address")
                .withMobilePhone("11111").withEmail("<EMAIL>").withHomepage("www.homepage.com").withWorkPhone("33333")
                .withHomePhone("44444").withPhoto(photo);
        app.contact().create(contact);
        Set<ContactData> after = app.contact().getAll();
        assertThat(after.size(),equalTo(before.size()+1));
        assertThat(before.withAdded(contact.withId(after.stream().mapToInt((g)->g.getId()).max().getAsInt())),equalTo(after));

    }


}
<commit_msg>Contacts tests data providers are added<commit_after>package ru.stqa.pft.addressbook.tests;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.thoughtworks.xstream.XStream;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.ContactData;
import ru.stqa.pft.addressbook.model.Contacts;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

public class ContactCreationTests extends TestBase{

    @DataProvider
    public Iterator<Object[]> validContactsXML() throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/contacts.xml")));
        String xml ="";
        String line = reader.readLine();
        while (line != null && !line.equals("")) {
            xml+=line;
            line = reader.readLine();
        }
        XStream xstream = new XStream();
        xstream.processAnnotations(ContactData.class);
        List<ContactData> contacts = (List<ContactData>) xstream.fromXML(xml);
        return contacts.stream().map(g-> new Object[] {g}).collect(Collectors.toList()).iterator();
    }

    @DataProvider
    public Iterator<Object[]> validContactsJson() throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/contacts.json")));
        String json ="";
        String line = reader.readLine();
        while (line != null && !line.equals("")) {
            json+=line;
            line = reader.readLine();
        }
        Gson gson = new Gson();

        List<ContactData> contacts = gson.fromJson(json, new TypeToken<List<ContactData>>(){}.getType());
        return contacts.stream().map(g-> new Object[] {g}).collect(Collectors.toList()).iterator();
    }

    @Test(dataProvider = "validContactsJson")
    public void testContactCreation(ContactData contact) {
        app.goTo().homePage();
        Contacts before = app.contact().getAll();
        contact.withPhoto(new File(contact.getPhotoPath()));
        app.contact().create(contact);
        Set<ContactData> after = app.contact().getAll();
        assertThat(after.size(),equalTo(before.size()+1));
        assertThat(before.withAdded(contact.withId(after.stream().mapToInt((g)->g.getId()).max().getAsInt())),equalTo(after));

    }


}

{'fraction_non_alphanumeric': 0.14668039114770973, 'fraction_numerical': 0.0051466803911477095, 'mean_word_length': 3.769325153374233, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 4}, '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': '7155318', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1139, 'n_words': 190}