package com.example.tests;

import java.util.Collections;
import java.util.List;
import static org.testng.Assert.assertEquals;

import org.testng.annotations.Test;

public class GroupCreationTests extends TestBase {
  @Test
  public void testNonEmptyGroupCreation() throws Exception {
	app.getNavigationHelper().openMainPage();
    app.getNavigationHelper().gotoGroupsPage();
    
    // save old state
    List<GroupData> initialGroups = app.getGroupHelper().getGroups();
    
    // actions
    app.getGroupHelper().initGroupCreation();
    GroupData group = new GroupData();
    group.name = "test-group-4";
    group.header = "HEADER\ntest-group-4";
    group.footer = "FOOTER\ntest-group-4";
	app.getGroupHelper().fillGroupForm(group);
    app.getGroupHelper().submitGroupForm();
    app.getGroupHelper().returnToGroupsPage();
    
    // get new state
    List<GroupData> newGroups = app.getGroupHelper().getGroups();
    
    // compare states
    initialGroups.add(group);
    Collections.sort(initialGroups);
    assertEquals(newGroups, initialGroups);
  }
  
  //@Test
  public void testEmptyGroupCreation() throws Exception {
	app.getNavigationHelper().openMainPage();
    app.getNavigationHelper().gotoGroupsPage();
    app.getGroupHelper().initGroupCreation();
	app.getGroupHelper().fillGroupForm(new GroupData("", "", ""));
    app.getGroupHelper().submitGroupForm();
    app.getGroupHelper().returnToGroupsPage();
  }
}

@@ -490,54 +490,8 @@
 ons%0A
-    app.getGroupHelper().initGroupCreation();%0A
     
@@ -644,16 +644,62 @@
 oup-4%22;%0A
+    app.getGroupHelper().initGroupCreation();%0A
 %09app.get
@@ -1064,18 +1064,16 @@
  %7D%0A  %0A  
-//
 @Test%0A  
@@ -1211,32 +1211,203 @@
 toGroupsPage();%0A
+    %0A    // save initial groups%0A    List%3CGroupData%3E initialGroups = app.getGroupHelper().getGroups();%0A    %0A    // actions%0A    GroupData group = new GroupData(%22%22, %22%22, %22%22);%0A
     app.getGroup
@@ -1476,33 +1476,13 @@
 orm(
-new GroupData(%22%22, %22%22, %22%22)
+group
 );%0A 
@@ -1571,14 +1571,246 @@
 Page();%0A
+    %0A    // save new groups%0A    List%3CGroupData%3E newGroups = app.getGroupHelper().getGroups();%0A    %0A    // compare states%0A    initialGroups.add(group);%0A    Collections.sort(initialGroups);%0A    assertEquals(newGroups, initialGroups);%0A
   %7D%0A%7D%0A

add assert to testEmptyGroupCreation()