commit 051dcb5186252c3f72e951e083e602ba6d0a7293
Author: Tomáš Šimandl <tomas.simandl@gmail.com>
Date:   Thu Oct 25 13:42:54 2018 +0200

    Repaired two selenium tests

diff --git a/sources/src/main/webapp/uploadFiles.jsp b/sources/src/main/webapp/uploadFiles.jsp
index bbc08d9..3db3f72 100644
--- a/sources/src/main/webapp/uploadFiles.jsp
+++ b/sources/src/main/webapp/uploadFiles.jsp
@@ -47,7 +47,7 @@
 						<label for="raw"><input type="radio" name="jsonFileFormat" value="raw" id="raw"> Raw JSON</label><br>
 					</div>
 
-					<button type="submit">Start visualization</button>
+					<button id="btnLoad" type="submit">Start visualization</button>
 				</form>
 			</div>
 
diff --git a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/ArchetypeIconConfigTest.java b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/ArchetypeIconConfigTest.java
index 27b66aa..b6240bf 100644
--- a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/ArchetypeIconConfigTest.java
+++ b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/ArchetypeIconConfigTest.java
@@ -21,73 +21,60 @@ public class ArchetypeIconConfigTest {
     }
 
     @Test
-    public void SpecifiedIcon1(){
-        locateTestingArchetypeIcon("vertex1");
+    public void SpecifiedValueDefinition(){
+        WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-SpecifiedIcon"));
+
+        System.out.println("Trying to locate an element with class 'testingArchetypeIcon'");
+        iconDef.findElement(By.className("testingArchetypeIcon"));
+        System.out.println("Element found.");
     }
 
     @Test
-    public void SpecifiedIcon2(){
-        Assertions.assertThrows(NoSuchElementException.class,
-                () -> checkUnspecifiedArchetypeSymbol("vertex1", "S"));
-
-        System.out.println("Default value not found on the vertex with specified archetype icon.");
+    public void UnspecifiedValueDefinition(){
+        emptyIconDefinition("UnspecifiedIcon");
     }
 
     @Test
-    public void UnspecifiedIcon1(){
-        Assertions.assertThrows(NoSuchElementException.class,
-                () -> locateTestingArchetypeIcon("vertex2"));
-
-        System.out.println("Element not found.");
+    public void SmileyValueDefinition(){
+        emptyIconDefinition("☺Smiley");
     }
 
     @Test
-    public void UnspecifiedIcon2(){
-        Assertions.assertThrows(NoSuchElementException.class,
-                () -> locateTestingArchetypeIcon("vertex3"));
-
-        System.out.println("Element not found.");
+    public void SpecifiedIcon(){
+        locateTestingArchetypeIcon("1","#vertexArchetypeIcon-SpecifiedIcon");
     }
 
     @Test
-    public void UnspecifiedIcon3(){
-        checkUnspecifiedArchetypeSymbol("vertex2", "U");
+    public void UnspecifiedIcon(){
+        locateTestingArchetypeIcon("2","#vertexArchetypeIcon-UnspecifiedIcon");
     }
 
     @Test
-    public void UnspecifiedIcon4(){
-        checkUnspecifiedArchetypeSymbol("vertex3", "☺");
+    public void SmileyIcon(){
+        locateTestingArchetypeIcon("3","#vertexArchetypeIcon-☺Smiley");
     }
 
     /**
      * Utility method for checking of the presence of the specified icon element
      * @param elementId Id of the element in which the search is done
+     * @param expectedHref expected href to icon in founded element
      */
-    private void locateTestingArchetypeIcon(String elementId) {
-        WebElement icon = browser.findElement(By.id(elementId))
-                .findElement(By.className("archetype"));
+    private void locateTestingArchetypeIcon(String elementId, String expectedHref) {
+        WebElement icon = browser.findElement(By.cssSelector("[data-id='vertices']"))
+                .findElement(By.cssSelector("[data-id='" + elementId + "']"))
+                .findElement(By.className("archetype-icon"));
 
-        System.out.println("Trying to locate an element with class 'testingArchetypeIcon'");
-        icon.findElement(By.className("testingArchetypeIcon"));
-        System.out.println("Element found.");
+        Assertions.assertEquals(expectedHref, icon.getAttribute("href"));
     }
 
-    /**
-     * Utility method for checking whether specified element contains the default archetype icon
-     * @param elementId Id of the element in which the test is done
-     * @param expectedText Expected text present in the icon
-     */
-    private void checkUnspecifiedArchetypeSymbol(String elementId, String expectedText) {
-        WebElement icon = browser.findElement(By.id(elementId))
-                .findElement(By.className("archetype"));
+    private void emptyIconDefinition(String iconName){
+        WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-" + iconName))
+                .findElement(By.tagName("text"));
 
-        System.out.println("Checking text of unspecified archetype icon");
-        Assertions.assertEquals(expectedText, icon.findElement(By.tagName("text")).getText(),
-                "Text of unspecified icon is different from the expected.");
-        System.out.println("Default text found.");
+        System.out.println("Testing if icon contains specific text");
+        Assertions.assertEquals(iconName.substring(0,1), iconDef.getText());
     }
 
-
     @AfterAll
     public static void finishTest() {
         SeleniumUtil.clear();
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 e714727..8fa21c0 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
@@ -24,81 +24,101 @@ public class AssociatedArchetypeTest {
 
     @Test
     public void visibilityOfAllIcons() {
-        checkVisibilityOfIcons("vertex1", Arrays.asList("2", "4"));
+        checkVisibilityOfIcons("1", Arrays.asList("2", "4"), Arrays.asList("2", "4"));
 
-        checkVisibilityOfIcons("vertex2",Arrays.asList("1"));
+        checkVisibilityOfIcons("2", Arrays.asList("1"), Arrays.asList("1"));
 
-        checkVisibilityOfIcons("vertex3",Arrays.asList("1"));
+        checkVisibilityOfIcons("3", Arrays.asList("1"),Arrays.asList("1"));
 
-        checkVisibilityOfIcons("vertex4",Arrays.asList("1", "3"));
+        checkVisibilityOfIcons("4", Arrays.asList("1", "3"), Arrays.asList("1", "3"));
 
-        checkVisibilityOfIcons("vertex5",Arrays.asList("4"));
+        checkVisibilityOfIcons("5", Arrays.asList("4"), Arrays.asList("4"));
     }
 
     @Test
     public void vertexHighlighting() {
         //associated vertices to V1
-        checkHighlightedVertices("archetype1_1", Arrays.asList("vertex2", "vertex3"));
-        checkHighlightedVertices("archetype1_3", Arrays.asList("vertex4"));
+        checkHighlightedVertices("1", "2", Arrays.asList("2", "3"));
+        checkHighlightedVertices("1", "4", Arrays.asList("4"));
 
         //associated vertices to V2
-        checkHighlightedVertices("archetype2_0", Arrays.asList("vertex1"));
+        checkHighlightedVertices("2", "1", Arrays.asList("1"));
 
         //associated vertices to V3
-        checkHighlightedVertices("archetype3_0", Arrays.asList("vertex1"));
+        checkHighlightedVertices("3", "1", Arrays.asList("1"));
 
         //associated vertices to V4
-        checkHighlightedVertices("archetype4_0", Arrays.asList("vertex1"));
-        checkHighlightedVertices("archetype4_2", Arrays.asList("vertex5"));
+        checkHighlightedVertices("4", "1", Arrays.asList("1"));
+        checkHighlightedVertices("4", "3", Arrays.asList("5"));
 
         //associated vertices to V5
-        checkHighlightedVertices("archetype5_3", Arrays.asList("vertex4"));
+        checkHighlightedVertices("5", "4", Arrays.asList("4"));
     }
 
     /**
      * Check if all the expected associated archetype icons are present
      * @param elementId Id of the vertex in the DOM
+     * @param expectedArchetypes names of expected archetypes
      * @param expectedArchetypeIconTexts Texts of all the associated archetype icons that are expected to occur
      */
-    private void checkVisibilityOfIcons(String elementId, List<String> expectedArchetypeIconTexts) {
+    private void checkVisibilityOfIcons(String elementId, List<String> expectedArchetypes, List<String> expectedArchetypeIconTexts) {
         System.out.println("Checking element " + elementId);
-        WebElement vertex = browser.findElement(By.id(elementId));
+        WebElement vertex = browser.findElement(By.cssSelector("[data-id='vertices']"))
+                .findElement(By.cssSelector("[data-id='" + elementId + "']"));
 
-        List<WebElement> associatedArchetypeIcons = vertex.findElements(By.className("associatedArchetype"));
+        List<WebElement> associatedArchetypeIcons = vertex.findElement(By.tagName("g")).
+                findElements(By.className("archetype-icon"));
 
         System.out.println("Associated archetypes: \n");
         Assertions.assertEquals(associatedArchetypeIcons.size(), expectedArchetypeIconTexts.size());
 
         for (int i = 0; i < expectedArchetypeIconTexts.size(); i++) {
             WebElement icon = associatedArchetypeIcons.get(i);
-            System.out.println("Icon id: " + icon.getAttribute("id"));
 
-            String archetypeIconText = icon.findElement(By.tagName("text")).getText();
-            System.out.println("Icon text: " + archetypeIconText +"\n");
+            String iconHref = icon.getAttribute("href");
+            System.out.println("Icon href: " + iconHref+"\n");
+            Assertions.assertEquals("#vertexArchetypeIcon-" + expectedArchetypes.get(i), iconHref);
 
-            Assertions.assertEquals(expectedArchetypeIconTexts.get(i), archetypeIconText);
+
+            WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-" + expectedArchetypes.get(i)));
+
+            System.out.println("Testing if icon contains specific text");
+            Assertions.assertEquals(expectedArchetypeIconTexts.get(i), iconDef.getText());
         }
     }
 
     /**
      * Check if all the expected vertices are highlighted when clicking on the associated archetype icon
-     * @param associatedArchetypeIconId Id of the associated archetype icon in the DOM
+     * @param vertexId Id of the vertex in viewport
+     * @param archetypeName name of associated archetype
      * @param expectedHighlightedVertexIds Ids of all the vertices that are expected to be highlighted
      */
-    private void checkHighlightedVertices(String associatedArchetypeIconId, List<String> expectedHighlightedVertexIds) {
-        System.out.println("\nChecking associated vertices for archetype icon with id: " + associatedArchetypeIconId);
-        WebElement associatedArchetypeIcon = browser.findElement(By.id(associatedArchetypeIconId));
+    private void checkHighlightedVertices(String vertexId, String archetypeName, List<String> expectedHighlightedVertexIds) {
+        System.out.println("\nChecking associated vertices of vertex: " + vertexId + " for archetype icon with : " + archetypeName);
+
+        WebElement vertex = browser.findElement(By.cssSelector("[data-id='vertices']"))
+                .findElement(By.cssSelector("[data-id='" + vertexId + "']"));
+
+        List<WebElement> associatedArchetypeIcons = vertex.findElement(By.tagName("g")).
+                findElements(By.className("archetype-icon"));
+
+        WebElement associatedArchetypeIcon = null;
+        for (WebElement icon : associatedArchetypeIcons) {
+            if(icon.getAttribute("href").endsWith(archetypeName)) {
+                associatedArchetypeIcon = icon;
+                break;
+            }
+        }
+        Assertions.assertNotNull(associatedArchetypeIcon);
         SeleniumUtil.svgClick(associatedArchetypeIcon);
 
-        List<WebElement> highlightedVertices = browser.findElements(By.className("colorHighlightArchetype"));
+        List<WebElement> highlightedVertices = browser.findElements(By.className("node--highlighted-archetype"));
 
         System.out.println("Number of highlighted vertices: " + highlightedVertices.size());
         Assertions.assertEquals(expectedHighlightedVertexIds.size(), highlightedVertices.size());
 
         for(int i = 0; i < highlightedVertices.size(); i++) {
-            WebElement vertex = highlightedVertices.get(i);
-            String id = vertex.getAttribute("id");
-
+            String id = highlightedVertices.get(i).getAttribute("data-id");
             System.out.println(id);
 
             Assertions.assertEquals(expectedHighlightedVertexIds.get(i), id);
diff --git a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/SeleniumUtil.java b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/SeleniumUtil.java
index bbb3cb8..d288e7d 100644
--- a/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/SeleniumUtil.java
+++ b/sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/SeleniumUtil.java
@@ -25,7 +25,7 @@ public class SeleniumUtil {
 
     private static final String GECKO_PATH = TEST_DIRECTORY + "\\geckodriver.exe";
 
-    private static final String URL = "http://localhost:8080";
+    private static final String URL = "http://localhost:8080/imiger/";
 
     private static final int DATA_LOAD_TIMEOUT = 20;
 
@@ -39,12 +39,12 @@ public class SeleniumUtil {
     }
 
     public static void loadGraphData(String filename) {
-        WebElement fileInput = browser.findElement(By.id("hidden_input"));
+        WebElement fileInput = browser.findElement(By.id("file"));
         fileInput.sendKeys(TEST_DIRECTORY + "\\data\\" + filename );
-        browser.findElement(By.className("load")).click();
+        browser.findElement(By.id("btnLoad")).click();
 
         WebDriverWait wait = new WebDriverWait(browser, DATA_LOAD_TIMEOUT);
-        wait.until(ExpectedConditions.presenceOfElementLocated(By.className("vertices")));
+        wait.until(ExpectedConditions.presenceOfElementLocated(By.id("viewport")));
 
         try {
             Thread.sleep(1000);
