/**
 *  A class to test the contact removal
 */

package ru.stqa.pft.addressbook.tests.ui.contacts;

import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.data.ContactData;
import ru.stqa.pft.addressbook.model.Contacts;
import ru.stqa.pft.addressbook.tests.ui.BaseTests;

import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static ru.stqa.pft.addressbook.generator.BaseGenerator.generateRandom;

public class ContactDeletionTests extends BaseTests {
    @BeforeMethod
    public void ensurePrecondition() {
        app.getNavigationHelper().gotoHomePage();

        //  Checking for the presence of at least one contact with the subsequent creation
        if (!app.getContactHelper().isThereAContact()) {
            ContactCreationTests.testContactCreationVer1(new ContactData());
        }
    }

    @Test
    // Base test deletion contact
    public void testContactDeletionVer1() {
        List<ContactData> beforeContactList = app.getContactHelper().getContactList();

        int index = generateRandom(beforeContactList.size());

        app.getContactHelper().selectContactByIndex(index);
        app.getContactHelper().deleteContact();

        // Check on the number of elements
        Assert.assertEquals(app.getContactHelper().getContactCount(), beforeContactList.size() - 1);

        List<ContactData> afterContactList = app.getContactHelper().getContactList();

        // Removing non-existent element
        beforeContactList.remove(index);

        // Check elements for identity verification
        Assert.assertEquals(beforeContactList, afterContactList);
    }

    @Test
    // Test deletion contact fluent implementation
    public void testContactDeletionVer2() {
        Contacts beforeContactSet = app.getContactHelper().all();

        ContactData deletedContact = beforeContactSet.iterator().next();

        app.getContactHelper().selectContactById(deletedContact.getContactId());
        app.getContactHelper().deleteContact();

        // Check on the number of elements
        assertThat(app.getContactHelper().getContactCount(), equalTo(beforeContactSet.size() - 1));

        Contacts afterContactSet = app.getContactHelper().all();

        // Check elements for identity verification
        assertThat(afterContactSet, equalTo(beforeContactSet.withOut(deletedContact)));
    }
}

@@ -736,20 +736,16 @@
 hecking 
-for 
 the pres
@@ -752,16 +752,26 @@
 ence of 
+base data 
 at least
@@ -786,37 +786,8 @@
 tact
- with the subsequent creation
 %0A   
@@ -799,23 +799,17 @@
 if (
-!
 app.get
-Contact
+Db
 Help
@@ -817,25 +817,30 @@
 r().
-isThereAC
+c
 ontact
+s
 ()
+.size() == 0
 ) %7B%0A
@@ -925,16 +925,231 @@
        %7D
+%0A%0A        //  Checking on the page there is at least one contact on the selector%0A        if (!app.getContactHelper().isThereAContact()) %7B%0A            System.out.println(%22On the page is not found contact%22);%0A        %7D
 %0A    %7D%0A%0A
@@ -2514,32 +2514,780 @@
 elper().all();%0A%0A
+        // Check elements for identity verification%0A        assertThat(afterContactSet, equalTo(beforeContactSet.withOut(deletedContact)));%0A    %7D%0A%0A    @Test%0A    // Deletion contact with access to the data from the database%0A    public void testContactDeletionVer3() %7B%0A        Contacts beforeContactSet = app.getDbHelper().contacts();%0A%0A        ContactData deletedContact = beforeContactSet.iterator().next();%0A%0A        app.getContactHelper().selectContactById(deletedContact.getContactId());%0A        app.getContactHelper().deleteContact();%0A%0A        // Check on the number of elements%0A        assertThat(app.getContactHelper().getContactCount(), equalTo(beforeContactSet.size() - 1));%0A%0A        Contacts afterContactSet = app.getDbHelper().contacts();%0A%0A
         // Check

Add new test implementation in classes ContactDeletionTests