package ru.sfwt.mt.addressbook.tests;

import org.testng.annotations.Test;
import ru.sfwt.mt.addressbook.model.GroupData;
import ru.sfwt.mt.addressbook.model.Groups;

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

public class GroupCreationTests extends TestBase{

  @Test
  public void testGroupCreation() {
    app.goTo().groupPage();
    Groups before = app.group().all();
    GroupData group = new GroupData().withName("test2");
    app.group().create(group);
    assertThat(app.group().count(), equalTo(before.size() +1));
    Groups after = app.group().all();
    assertThat(after, equalTo(
            before.withAdded(group.withId(after.stream().mapToInt((g) -> g.getId()).max().getAsInt()))));
  }

  @Test
  public void testBadGroupCreation() {
    app.goTo().groupPage();
    Groups before = app.group().all();
    GroupData group = new GroupData().withName("test2'");
    app.group().create(group);
    assertThat(app.group().count(), equalTo(before.size()));
    Groups after = app.group().all();
    assertThat(after, equalTo(before));
  }
}

@@ -28,24 +28,109 @@
 ook.tests;%0A%0A
+import org.testng.annotations.DataProvider;%0Aimport org.testng.annotations.Listeners;%0A
 import org.t
@@ -153,16 +153,16 @@
 s.Test;%0A
-
 import r
@@ -241,24 +241,103 @@
 el.Groups;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A%0A
 import stati
@@ -477,28 +477,525 @@
 stBase%7B%0A%0A  @
-Test
+DataProvider%0A  public Iterator%3CObject%5B%5D%3E validGroups() %7B%0A    List%3CObject%5B%5D%3E list = new ArrayList%3CObject%5B%5D%3E();%0A    list.add(new Object%5B%5D%7Bnew GroupData().withName(%22test1%22).withHeader(%22header1%22).withFooter(%22footer1%22)%7D);%0A    list.add(new Object%5B%5D%7Bnew GroupData().withName(%22test2%22).withHeader(%22header2%22).withFooter(%22footer2%22)%7D);%0A    list.add(new Object%5B%5D%7Bnew GroupData().withName(%22test3%22).withHeader(%22header3%22).withFooter(%22footer3%22)%7D);%0A    return list.iterator();%0A  %7D%0A%0A  @Test(dataProvider = %22validGroups%22)
 %0A  public vo
@@ -1007,32 +1007,47 @@
 stGroupCreation(
+GroupData group
 ) %7B%0A    app.goTo
@@ -1105,65 +1105,8 @@
 ();%0A
-    GroupData group = new GroupData().withName(%22test2%22);%0A
     
@@ -1371,21 +1371,22 @@
 ()))));%0A
-
   %7D%0A%0A
+%0A
   @Test%0A

Create @DataProvider in GroupCreationTests