package com.example.tests;

import static org.testng.Assert.assertEquals;

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

import org.testng.annotations.Test;

public class GroupRemovalTests extends TestBase {

	@Test
	public void removeGroup() {
		app.getNavigationHelper().openMainPage();
	    app.getNavigationHelper().gotoGroupsPage();
	    
	    // save initial groups
	    List<GroupData> initialGroups = app.getGroupHelper().getGroups();
	    
	    Random rnd = new Random();
	    int index = rnd.nextInt(initialGroups.size() - 1);
	    
	    // actions
	    app.getGroupHelper().selectGroup(index);
	    app.getGroupHelper().submitDeleteGroups();
	    app.getGroupHelper().returnToGroupsPage();
	    
	    // save new groups
	    List<GroupData> newGroups = app.getGroupHelper().getGroups();
	    
	    // compare states
	    initialGroups.remove(index);
	    Collections.sort(initialGroups);
	    assertEquals(newGroups, initialGroups);
	}

}

@@ -480,16 +480,82 @@
   %0A%09    
+for (int i = 0; i %3C 25 && initialGroups.size() %3E 30; i++) %7B%0A%09    %09
 Random r
@@ -569,24 +569,25 @@
 w Random();%0A
+%09
 %09    int ind
@@ -630,22 +630,24 @@
 ) - 1);%0A
+%09
 %09    %0A
+%09
 %09    // 
@@ -654,16 +654,17 @@
 actions%0A
+%09
 %09    app
@@ -697,24 +697,25 @@
 oup(index);%0A
+%09
 %09    app.get
@@ -746,24 +746,25 @@
 teGroups();%0A
+%09
 %09    app.get
@@ -790,32 +790,75 @@
 nToGroupsPage();
+%09%0A%09%09    initialGroups.remove(index);%0A%09    %7D
 %0A%09    %0A%09    // s
@@ -937,32 +937,32 @@
 Groups();%0A%09    %0A
+
 %09    // compare 
@@ -972,42 +972,8 @@
 tes%0A
-%09    initialGroups.remove(index);%0A
 %09   

delete many groups