package ru.stqa.pft.addressbook.tests;

import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.GroupData;
import ru.stqa.pft.addressbook.model.Groups;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;

public class GroupCreationTests extends TestBase {

    @Test (enabled = true)
    public void testGroupCreation() {
        app.getNavigationHelper().gotoGroupPage();
        Groups before = app.getGroupHelper().getAllGroups();
        GroupData group = new GroupData().setName("test1").setHeader("test2").setFooter("test3");
        app.getGroupHelper().createGroup(group);
        assertThat(app.getGroupHelper().getGroupCount(), equalTo(before.size() + 1));
        Groups after = app.getGroupHelper().getAllGroups();

        //получаем из потока список идентификаторов, ищем максимальный и преобразуем его в int, потом сравниваем копии множеств
        assertThat(after, equalTo(
                before.withAdded(group.setId(after.stream().mapToInt((g) -> g.getId()).max().getAsInt()))));
    }

    @Test (enabled = true)
    public void testBadGroupCreation() {
        app.getNavigationHelper().gotoGroupPage();
        Groups before = app.getGroupHelper().getAllGroups();
        GroupData group = new GroupData().setName("test1");
        app.getGroupHelper().createGroup(group);
        assertThat(app.getGroupHelper().getGroupCount(), equalTo(before.size()));
        Groups after = app.getGroupHelper().getAllGroups();

        assertThat(after, equalTo(before));
    }
}

@@ -1053,16 +1053,78 @@
 %0A    %7D%0A%0A
+    // %D0%BF%D0%B0%D0%B4%D0%B0%D1%8E%D1%89%D0%B8%D0%B9 %D1%82%D0%B5%D1%81%D1%82, %D1%82%D0%B0%D0%BA %D0%BA%D0%B0%D0%BA %D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D0%B5%D1%82%D1%81%D1%8F %22%D0%BD%D0%B5%D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D0%BB%D1%8C%D0%BD%D0%B0%D1%8F%22 %D0%B3%D1%80%D1%83%D0%BF%D0%BF%D0%B0%0A
     @Tes
@@ -1128,35 +1128,36 @@
 Test (enabled = 
-tru
+fals
 e)%0A    public vo
@@ -1397,32 +1397,140 @@
 teGroup(group);%0A
+        // %D1%85%D0%B5%D1%88%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5 - %D0%B1%D1%8B%D1%81%D1%82%D1%80%D0%B0%D1%8F %D0%BF%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0 %D0%BA%D0%BE%D0%BB-%D0%B2%D0%B0 %D0%B3%D1%80%D1%83%D0%BF%D0%BF %D0%B4%D0%BE %D0%B8 %D0%BF%D0%BE%D1%81%D0%BB%D0%B5 %D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D1%8F, %D0%BF%D0%BE%D0%BC%D0%BE%D0%B3%D0%B0%D0%B5%D1%82 %D1%83%D1%81%D0%BA%D0%BE%D1%80%D0%B8%D1%82%D1%8C %D0%BF%D0%B0%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5 %D1%82%D0%B5%D1%81%D1%82%D0%B0%0A
         assertTh

Comment added to GroupCreationTests