package com.example.tests;

import static org.testng.Assert.assertEquals;

import java.util.List;
import java.util.Random;

import org.testng.annotations.Test;

public class ContactRemovalTests extends TestBase {

	@Test
	public void removeContact() {
		app.getNavigationHelper().openMainPage();

		// save initial contacts list
		List<ContactData> initialContacts = app.getContactHelper().getContacts();
		
		//for (int i = 0; i < 25 && initialContacts.size() > 20; i++) {
			Random rnd = new Random();
			int index = rnd.nextInt(initialContacts.size() - 1);

			// actions
			app.getContactHelper().initContactEdit(index);
			app.getContactHelper().submitDeleteContact();
			app.getContactHelper().returnToHomePage();
			initialContacts.remove(index);
		//}

		// save new contact list
		List<ContactData> newContacts = app.getContactHelper().getContacts();

		// compare states
		assertEquals(newContacts, initialContacts);
	}
}

@@ -402,15 +402,11 @@
 ();%0A
-%09%09
 %0A%09%09
-//
 for 
@@ -747,15 +747,10 @@
 x);%0A
-%09%09//%7D%0A
 %0A
+%09
 %09%09//
@@ -766,32 +766,33 @@
  contact list%0A%09%09
+%09
 List%3CContactData
@@ -848,16 +848,17 @@
 s();%0A%0A%09%09
+%09
 // compa
@@ -867,16 +867,17 @@
  states%0A
+%09
 %09%09assert
@@ -914,13 +914,113 @@
 tacts);%0A
+%09%09%09%0A%09%09%09// prepare for next iteration%0A%09%09%09initialContacts = app.getContactHelper().getContacts();%0A%09%09%7D%0A
 %09%7D%0A%7D%0A

delete contacts till 10 left