package ru.stqa.pft.addressbook.tests;

import org.apache.commons.lang3.RandomStringUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.GroupData;
import ru.stqa.pft.addressbook.model.Groups;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.Assert.assertEquals;

public class GroupDeletionTests extends TestBase {
  @BeforeMethod
  public void ensurePreconditions() {
    app.goTo().GroupPage();
    if (app.group().all().size() == 0) {
      app.group().create(new GroupData().withName(RandomStringUtils.randomAlphabetic(10)));
    }
  }

  @Test
  public void testGroupDeletion() {
    Groups before = app.group().all();
    GroupData deletedGroup = before.iterator().next();
    app.group().delete(deletedGroup);
    assertEquals(app.group().count(), (before.size() - 1));
    Groups after = app.group().all();
    assertThat(after, equalTo(before.without(deletedGroup)));
  }
}

@@ -578,27 +578,27 @@
 if (app.
-group().all
+db().groups
 ().size(
@@ -603,24 +603,54 @@
 e() == 0) %7B%0A
+      app.goTo().GroupPage();%0A
       app.gr
@@ -804,35 +804,35 @@
 efore = app.
-group().all
+db().groups
 ();%0A    Grou
@@ -874,24 +874,52 @@
 r().next();%0A
+    app.goTo().GroupPage();%0A
     app.grou
@@ -1031,19 +1031,19 @@
 app.
-group().all
+db().groups
 ();%0A

update GroupDeletionTests