commit f27c72d12f96d27dbd467ce2345404fda4706350
Author: Tomáš Šimandl <tomas.simandl@gmail.com>
Date:   Thu Nov 1 13:16:15 2018 +0100

    Repaired Seleninum tests - AutomaticGroupingTest

diff --git a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AssociatedArchetypeTest.java b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AssociatedArchetypeTest.java
index 8fa21c0..bbc2755 100644
--- a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AssociatedArchetypeTest.java
+++ b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AssociatedArchetypeTest.java
@@ -12,6 +12,9 @@ import org.openqa.selenium.WebElement;
 import java.util.Arrays;
 import java.util.List;
 
+/*
+ * Tests are not working because new graph is out of actual visible view.
+ */
 public class AssociatedArchetypeTest {
     static WebDriver browser;
 
diff --git a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AutomaticGroupingTest.java b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AutomaticGroupingTest.java
index 181e3db..8ed0a54 100644
--- a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AutomaticGroupingTest.java
+++ b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AutomaticGroupingTest.java
@@ -1,11 +1,7 @@
 package cz.zcu.kiv.imiger.tests.frontend;
 
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.*;
 import org.openqa.selenium.By;
-import org.openqa.selenium.NoSuchElementException;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 
@@ -15,36 +11,85 @@ import java.util.List;
 public class AutomaticGroupingTest {
     static WebDriver browser;
 
-    @BeforeAll
-    public static void initTest() {
+    @BeforeEach
+    public void initTest() {
         SeleniumUtil.prepareConfigFile("automaticGroupingConfigTest.json");
         browser = SeleniumUtil.init();
         SeleniumUtil.loadGraphData("automaticGroupingTest.json");
     }
 
     @Test
-    public void groups1(){
+    public void groupIncluded(){
         String groupName = "FirstGroupArchetype";
-        List<String> verticesIds = new ArrayList<>();
-        verticesIds.add("li1");
-        verticesIds.add("li3");
+        checkGroupExist(browser, groupName);
+    }
+
+    @Test
+    public void groupExcluded(){
+        String groupName = "FirstGroupArchetype";
+        List<String> verticesNames = new ArrayList<>();
+        verticesNames.add("First vertex from first group");
+        verticesNames.add("Second vertex from first group");
+
+        excludeFirstGroup(browser);
+        checkExcludedGroup(browser, groupName, verticesNames);
+    }
+
+    private void checkGroupExist(WebDriver browser, String groupName){
+        List<WebElement> groups = browser.findElement(By.cssSelector("[data-id='groups']"))
+                .findElements(By.className("node"));
+
+        Assertions.assertEquals(1, groups.size());
+
+        String actualGroupName = groups.get(0).findElement(By.tagName("foreignObject"))
+                .findElement(By.className("group-name")).getText();
 
-        checkGroupExisting(browser, groupName, verticesIds);
-        System.out.println("Group: " + groupName + " was not found.");
+        Assertions.assertEquals(groupName, actualGroupName);
     }
 
-    private void checkGroupExisting(WebDriver browser, String groupName, List<String> verticesIds){
-        WebElement group = browser.findElement(By.className("component group_vertices"));
-        System.out.println("Trying to locate vertexes in group");
-        for(String id : verticesIds){
-            group.findElement(By.id(id));
+    private void checkExcludedGroup(WebDriver browser, String groupName, List<String> verticesTexts){
+        List<WebElement> nodes = browser.findElement(By.id("excludedNodeListComponent"))
+                .findElement(By.className("node-list"))
+                .findElements(By.tagName("li"));
+
+        Assertions.assertEquals(3, nodes.size());
+        WebElement group = nodes.get(0);
+
+        String actualGroupName = group.findElement(By.className("group-name")).getText();
+        Assertions.assertEquals(groupName, actualGroupName);
+
+        for(int i = 1; i < nodes.size(); i ++){
+            Assertions.assertTrue(verticesTexts.contains(nodes.get(i).getText()));
         }
+    }
+
+    private void excludeFirstGroup(WebDriver browser){
+        List<WebElement> navList = browser.findElement(By.tagName("nav")).findElements(By.tagName("ul"));
 
-        System.out.println("Vertexes found.");
+        for( WebElement item : navList){
+            WebElement form = item.findElement(By.tagName("form"));
+            if (form != null){
+                String formName = form.getAttribute("name");
+                if (formName.equals("actionForm")) {
+                    item.findElements(By.tagName("label")).get(1).click();
+                    break;
+                }
+            }
+        }
+
+        List<WebElement> groups = browser.findElement(By.cssSelector("[data-id='groups']"))
+                .findElements(By.className("node"));
+
+        groups.get(0).findElement(By.tagName("rect")).click();
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 
-    @AfterAll
-    public static void finishTest() {
+    @AfterEach
+    public void finishTest() {
         SeleniumUtil.clear();
     }
 }
