package ru.stqa.pft.addressbook.tests;

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

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

/**
 * Created by Olga on 01.03.2016.
 */
public class ContactDeletionTests extends TestBase {

    @BeforeMethod
    public void ensurePreconditions() {
        app.getNavigationHelper().gotoHome();
        if (app.getContactHelper().getAllContacts().size() == 0) {
            app.getContactHelper().createContact(new ContactData().setFirstname("Ivan").setLastname("Ivanov").
                    setCompany("Noosphere").setAddress("Shevchenko, 59").
                    setHomephone("56-373-22-89").setMobilephone("50-362-85-96").setGroup("test1"), true);
        }
    }

    @Test (enabled = true)
    public void testContactDeletion() {
        Contacts before = app.getContactHelper().getAllContacts();
        ContactData deletedContact = before.iterator().next();
        app.getContactHelper().deleteContact(deletedContact);
        Contacts after = app.getContactHelper().getAllContacts();
        assertThat(after.size(), equalTo(before.size() - 1));

        assertThat(after, equalTo(before.without(deletedContact)));
    }

    @Test (enabled = false)
    public void testAllContactsDeletion() {
        Contacts before = app.getContactHelper().getAllContacts();
        for (ContactData dc : before) {
            app.getContactHelper().deleteContact(dc);
        }
        Contacts after = app.getContactHelper().getAllContacts();
        assertThat(after.size(), equalTo(0));
    }

}

@@ -910,19 +910,20 @@
 abled = 
-tru
+fals
 e)%0A    p
@@ -1366,36 +1366,35 @@
 Test (enabled = 
-fals
+tru
 e)%0A    public vo
@@ -1436,280 +1436,49 @@
     
-Contacts before = app.getContactHelper().getAllContacts();%0A        for (ContactData dc : before) %7B%0A            app.getContactHelper().deleteContact(dc);%0A        %7D%0A        Contacts after = app.getContactHelper().getAllContacts();%0A        assertThat(after.size(), equalTo(0)
+app.getContactHelper().deleteAllContacts(
 );%0A 

Test testAllContactsDeletion corrected in ContactDeletionTests