Revize b14ebc24
Přidáno uživatelem Patrik Harag před více než 5 roky(ů)
sources/imiger-core/pom.xml | ||
---|---|---|
160 | 160 |
|
161 | 161 |
<!-- testing --> |
162 | 162 |
<dependency> |
163 |
<groupId>org.seleniumhq.selenium</groupId> |
|
164 |
<artifactId>selenium-java</artifactId> |
|
165 |
<version>3.12.0</version> |
|
166 |
<scope>test</scope> |
|
167 |
</dependency> |
|
168 |
<dependency> |
|
169 |
<groupId>org.junit.jupiter</groupId> |
|
170 |
<artifactId>junit-jupiter-api</artifactId> |
|
171 |
<version>5.3.2</version> |
|
163 |
<groupId>junit</groupId> |
|
164 |
<artifactId>junit</artifactId> |
|
165 |
<version>4.12</version> |
|
172 | 166 |
<scope>test</scope> |
173 | 167 |
</dependency> |
174 | 168 |
|
sources/imiger-core/src/test/java/cz/zcu/kiv/imiger/tests/frontend/ArchetypeIconConfigTest.java | ||
---|---|---|
1 |
package cz.zcu.kiv.imiger.tests.frontend; |
|
2 |
|
|
3 |
import org.apache.logging.log4j.LogManager; |
|
4 |
import org.apache.logging.log4j.Logger; |
|
5 |
import org.junit.jupiter.api.AfterAll; |
|
6 |
import org.junit.jupiter.api.Assertions; |
|
7 |
import org.junit.jupiter.api.BeforeAll; |
|
8 |
import org.junit.jupiter.api.Test; |
|
9 |
import org.openqa.selenium.By; |
|
10 |
import org.openqa.selenium.WebDriver; |
|
11 |
import org.openqa.selenium.WebElement; |
|
12 |
|
|
13 |
class ArchetypeIconConfigTest { |
|
14 |
private static final Logger logger = LogManager.getLogger(); |
|
15 |
private static WebDriver browser; |
|
16 |
|
|
17 |
@BeforeAll |
|
18 |
static void initTest() { |
|
19 |
SeleniumUtil.prepareConfigFile("archetypeIconConfigTest.json"); |
|
20 |
browser = SeleniumUtil.init(); |
|
21 |
SeleniumUtil.switchToRaw(); |
|
22 |
SeleniumUtil.loadGraphData("RawArchetypeIconTest.json"); |
|
23 |
} |
|
24 |
|
|
25 |
@Test |
|
26 |
void SpecifiedValueDefinition(){ |
|
27 |
WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-SpecifiedIcon")); |
|
28 |
|
|
29 |
logger.debug("Trying to locate an element with class 'testingArchetypeIcon'"); |
|
30 |
iconDef.findElement(By.className("testingArchetypeIcon")); |
|
31 |
logger.debug("Element found."); |
|
32 |
} |
|
33 |
|
|
34 |
@Test |
|
35 |
void UnspecifiedValueDefinition(){ |
|
36 |
emptyIconDefinition("UnspecifiedIcon"); |
|
37 |
} |
|
38 |
|
|
39 |
@Test |
|
40 |
void SmileyValueDefinition(){ |
|
41 |
emptyIconDefinition("☺Smiley"); |
|
42 |
} |
|
43 |
|
|
44 |
@Test |
|
45 |
void SpecifiedIcon(){ |
|
46 |
locateTestingArchetypeIcon("1","#vertexArchetypeIcon-SpecifiedIcon"); |
|
47 |
} |
|
48 |
|
|
49 |
@Test |
|
50 |
void UnspecifiedIcon(){ |
|
51 |
locateTestingArchetypeIcon("2","#vertexArchetypeIcon-UnspecifiedIcon"); |
|
52 |
} |
|
53 |
|
|
54 |
@Test |
|
55 |
void SmileyIcon(){ |
|
56 |
locateTestingArchetypeIcon("3","#vertexArchetypeIcon-☺Smiley"); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Utility method for checking of the presence of the specified icon element |
|
61 |
* @param elementId Id of the element in which the search is done |
|
62 |
* @param expectedHref expected href to icon in founded element |
|
63 |
*/ |
|
64 |
private void locateTestingArchetypeIcon(String elementId, String expectedHref) { |
|
65 |
WebElement icon = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
66 |
.findElement(By.cssSelector("[data-id='" + elementId + "']")) |
|
67 |
.findElement(By.className("archetype-icon")); |
|
68 |
|
|
69 |
Assertions.assertEquals(expectedHref, icon.getAttribute("href")); |
|
70 |
} |
|
71 |
|
|
72 |
private void emptyIconDefinition(String iconName){ |
|
73 |
WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-" + iconName)) |
|
74 |
.findElement(By.tagName("text")); |
|
75 |
|
|
76 |
logger.debug("Testing if icon contains specific text"); |
|
77 |
Assertions.assertEquals(iconName.substring(0,1), iconDef.getText()); |
|
78 |
} |
|
79 |
|
|
80 |
@AfterAll |
|
81 |
static void finishTest() { |
|
82 |
SeleniumUtil.clear(); |
|
83 |
} |
|
84 |
} |
sources/imiger-core/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AssociatedArchetypeTest.java | ||
---|---|---|
1 |
package cz.zcu.kiv.imiger.tests.frontend; |
|
2 |
|
|
3 |
import org.apache.logging.log4j.LogManager; |
|
4 |
import org.apache.logging.log4j.Logger; |
|
5 |
import org.junit.jupiter.api.AfterAll; |
|
6 |
import org.junit.jupiter.api.Assertions; |
|
7 |
import org.junit.jupiter.api.BeforeAll; |
|
8 |
import org.junit.jupiter.api.Test; |
|
9 |
import org.openqa.selenium.By; |
|
10 |
import org.openqa.selenium.WebDriver; |
|
11 |
import org.openqa.selenium.WebElement; |
|
12 |
|
|
13 |
import java.util.Arrays; |
|
14 |
import java.util.List; |
|
15 |
|
|
16 |
|
|
17 |
class AssociatedArchetypeTest { |
|
18 |
private static final Logger logger = LogManager.getLogger(); |
|
19 |
private static WebDriver browser; |
|
20 |
|
|
21 |
@BeforeAll |
|
22 |
static void initTest() { |
|
23 |
SeleniumUtil.prepareConfigFile("emptyConfig.json"); |
|
24 |
browser = SeleniumUtil.init(); |
|
25 |
SeleniumUtil.switchToRaw(); |
|
26 |
SeleniumUtil.loadGraphData("RawAssociatedArchetypeTest.json"); |
|
27 |
} |
|
28 |
|
|
29 |
@Test |
|
30 |
void visibilityOfAllIcons() { |
|
31 |
checkVisibilityOfIcons("1", Arrays.asList("2", "4"), Arrays.asList("2", "4")); |
|
32 |
|
|
33 |
checkVisibilityOfIcons("2", Arrays.asList("1"), Arrays.asList("1")); |
|
34 |
|
|
35 |
checkVisibilityOfIcons("3", Arrays.asList("1"),Arrays.asList("1")); |
|
36 |
|
|
37 |
checkVisibilityOfIcons("4", Arrays.asList("1", "3"), Arrays.asList("1", "3")); |
|
38 |
|
|
39 |
checkVisibilityOfIcons("5", Arrays.asList("4"), Arrays.asList("4")); |
|
40 |
} |
|
41 |
|
|
42 |
@Test |
|
43 |
void vertexHighlighting() { |
|
44 |
//associated vertices to V1 |
|
45 |
checkHighlightedVertices("1", "2", Arrays.asList("2", "3")); |
|
46 |
checkHighlightedVertices("1", "4", Arrays.asList("4")); |
|
47 |
|
|
48 |
//associated vertices to V2 |
|
49 |
checkHighlightedVertices("2", "1", Arrays.asList("1")); |
|
50 |
|
|
51 |
//associated vertices to V3 |
|
52 |
checkHighlightedVertices("3", "1", Arrays.asList("1")); |
|
53 |
|
|
54 |
//associated vertices to V4 |
|
55 |
checkHighlightedVertices("4", "1", Arrays.asList("1")); |
|
56 |
checkHighlightedVertices("4", "3", Arrays.asList("5")); |
|
57 |
|
|
58 |
//associated vertices to V5 |
|
59 |
checkHighlightedVertices("5", "4", Arrays.asList("4")); |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Check if all the expected associated archetype icons are present |
|
64 |
* @param elementId Id of the vertex in the DOM |
|
65 |
* @param expectedArchetypes names of expected archetypes |
|
66 |
* @param expectedArchetypeIconTexts Texts of all the associated archetype icons that are expected to occur |
|
67 |
*/ |
|
68 |
private void checkVisibilityOfIcons(String elementId, List<String> expectedArchetypes, List<String> expectedArchetypeIconTexts) { |
|
69 |
logger.debug("Checking element " + elementId); |
|
70 |
WebElement vertex = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
71 |
.findElement(By.cssSelector("[data-id='" + elementId + "']")); |
|
72 |
|
|
73 |
List<WebElement> associatedArchetypeIcons = vertex.findElement(By.tagName("g")). |
|
74 |
findElements(By.className("archetype-icon")); |
|
75 |
|
|
76 |
logger.debug("Associated archetypes: \n"); |
|
77 |
Assertions.assertEquals(associatedArchetypeIcons.size(), expectedArchetypeIconTexts.size()); |
|
78 |
|
|
79 |
for (int i = 0; i < expectedArchetypeIconTexts.size(); i++) { |
|
80 |
WebElement icon = associatedArchetypeIcons.get(i); |
|
81 |
|
|
82 |
String iconHref = icon.getAttribute("href"); |
|
83 |
logger.debug("Icon href: " + iconHref+"\n"); |
|
84 |
Assertions.assertEquals("#vertexArchetypeIcon-" + expectedArchetypes.get(i), iconHref); |
|
85 |
|
|
86 |
|
|
87 |
WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-" + expectedArchetypes.get(i))); |
|
88 |
|
|
89 |
logger.debug("Testing if icon contains specific text"); |
|
90 |
Assertions.assertEquals(expectedArchetypeIconTexts.get(i), iconDef.getText()); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Check if all the expected vertices are highlighted when clicking on the associated archetype icon |
|
96 |
* @param vertexId Id of the vertex in viewport |
|
97 |
* @param archetypeName name of associated archetype |
|
98 |
* @param expectedHighlightedVertexIds Ids of all the vertices that are expected to be highlighted |
|
99 |
*/ |
|
100 |
private void checkHighlightedVertices(String vertexId, String archetypeName, List<String> expectedHighlightedVertexIds) { |
|
101 |
logger.debug("\nChecking associated vertices of vertex: " + vertexId + " for archetype icon with : " + archetypeName); |
|
102 |
|
|
103 |
WebElement vertex = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
104 |
.findElement(By.cssSelector("[data-id='" + vertexId + "']")); |
|
105 |
|
|
106 |
List<WebElement> associatedArchetypeIcons = vertex.findElement(By.tagName("g")). |
|
107 |
findElements(By.className("archetype-icon")); |
|
108 |
|
|
109 |
WebElement associatedArchetypeIcon = null; |
|
110 |
for (WebElement icon : associatedArchetypeIcons) { |
|
111 |
if(icon.getAttribute("href").endsWith(archetypeName)) { |
|
112 |
associatedArchetypeIcon = icon; |
|
113 |
break; |
|
114 |
} |
|
115 |
} |
|
116 |
Assertions.assertNotNull(associatedArchetypeIcon); |
|
117 |
SeleniumUtil.svgClick(associatedArchetypeIcon); |
|
118 |
|
|
119 |
List<WebElement> highlightedVertices = browser.findElements(By.className("node--highlighted-archetype")); |
|
120 |
|
|
121 |
logger.debug("Number of highlighted vertices: " + highlightedVertices.size()); |
|
122 |
Assertions.assertEquals(expectedHighlightedVertexIds.size(), highlightedVertices.size()); |
|
123 |
|
|
124 |
for(int i = 0; i < highlightedVertices.size(); i++) { |
|
125 |
String id = highlightedVertices.get(i).getAttribute("data-id"); |
|
126 |
logger.debug(id); |
|
127 |
|
|
128 |
Assertions.assertEquals(expectedHighlightedVertexIds.get(i), id); |
|
129 |
} |
|
130 |
|
|
131 |
SeleniumUtil.svgClick(associatedArchetypeIcon); |
|
132 |
} |
|
133 |
|
|
134 |
@AfterAll |
|
135 |
static void finishTest() { |
|
136 |
SeleniumUtil.clear(); |
|
137 |
} |
|
138 |
} |
sources/imiger-core/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AutomaticGroupingTest.java | ||
---|---|---|
1 |
package cz.zcu.kiv.imiger.tests.frontend; |
|
2 |
|
|
3 |
import org.junit.jupiter.api.*; |
|
4 |
import org.openqa.selenium.By; |
|
5 |
import org.openqa.selenium.WebDriver; |
|
6 |
import org.openqa.selenium.WebElement; |
|
7 |
|
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
class AutomaticGroupingTest { |
|
12 |
private static WebDriver browser; |
|
13 |
|
|
14 |
@BeforeEach |
|
15 |
void initTest() { |
|
16 |
SeleniumUtil.prepareConfigFile("automaticGroupingConfigTest.json"); |
|
17 |
browser = SeleniumUtil.init(); |
|
18 |
SeleniumUtil.loadGraphData("automaticGroupingTest.json"); |
|
19 |
} |
|
20 |
|
|
21 |
@Test |
|
22 |
void groupIncluded(){ |
|
23 |
String groupName = "FirstGroupArchetype"; |
|
24 |
checkGroupExist(browser, groupName); |
|
25 |
} |
|
26 |
|
|
27 |
@Test |
|
28 |
void groupExcluded(){ |
|
29 |
String groupName = "FirstGroupArchetype"; |
|
30 |
List<String> verticesNames = new ArrayList<>(); |
|
31 |
verticesNames.add("First vertex from first group"); |
|
32 |
verticesNames.add("Second vertex from first group"); |
|
33 |
|
|
34 |
excludeFirstGroup(browser); |
|
35 |
checkExcludedGroup(browser, groupName, verticesNames); |
|
36 |
} |
|
37 |
|
|
38 |
private void checkGroupExist(WebDriver browser, String groupName){ |
|
39 |
List<WebElement> groups = browser.findElement(By.cssSelector("[data-id='groups']")) |
|
40 |
.findElements(By.className("node")); |
|
41 |
|
|
42 |
Assertions.assertEquals(1, groups.size()); |
|
43 |
|
|
44 |
String actualGroupName = groups.get(0).findElement(By.tagName("foreignObject")) |
|
45 |
.findElement(By.className("group-name")).getText(); |
|
46 |
|
|
47 |
Assertions.assertEquals(groupName, actualGroupName); |
|
48 |
} |
|
49 |
|
|
50 |
private void checkExcludedGroup(WebDriver browser, String groupName, List<String> verticesTexts){ |
|
51 |
List<WebElement> nodes = browser.findElement(By.id("excludedNodeListComponent")) |
|
52 |
.findElement(By.className("node-list")) |
|
53 |
.findElements(By.tagName("li")); |
|
54 |
|
|
55 |
Assertions.assertEquals(3, nodes.size()); |
|
56 |
WebElement group = nodes.get(0); |
|
57 |
|
|
58 |
String actualGroupName = group.findElement(By.className("group-name")).getText(); |
|
59 |
Assertions.assertEquals(groupName, actualGroupName); |
|
60 |
|
|
61 |
for(int i = 1; i < nodes.size(); i ++){ |
|
62 |
Assertions.assertTrue(verticesTexts.contains(nodes.get(i).getText())); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
private void excludeFirstGroup(WebDriver browser){ |
|
67 |
SeleniumUtil.switchToExcludeMode(); |
|
68 |
|
|
69 |
List<WebElement> groups = browser.findElement(By.cssSelector("[data-id='groups']")) |
|
70 |
.findElements(By.className("node")); |
|
71 |
|
|
72 |
SeleniumUtil.svgRectClick(groups.get(0)); |
|
73 |
} |
|
74 |
|
|
75 |
@AfterEach |
|
76 |
void finishTest() { |
|
77 |
SeleniumUtil.clear(); |
|
78 |
} |
|
79 |
} |
sources/imiger-core/src/test/java/cz/zcu/kiv/imiger/tests/frontend/DetailsTest.java | ||
---|---|---|
1 |
package cz.zcu.kiv.imiger.tests.frontend; |
|
2 |
|
|
3 |
import org.junit.jupiter.api.AfterAll; |
|
4 |
import org.junit.jupiter.api.Assertions; |
|
5 |
import org.junit.jupiter.api.BeforeAll; |
|
6 |
import org.junit.jupiter.api.Test; |
|
7 |
import org.openqa.selenium.By; |
|
8 |
import org.openqa.selenium.WebDriver; |
|
9 |
import org.openqa.selenium.WebElement; |
|
10 |
|
|
11 |
class DetailsTest { |
|
12 |
|
|
13 |
private static WebDriver browser; |
|
14 |
|
|
15 |
@BeforeAll |
|
16 |
static void initTest() { |
|
17 |
SeleniumUtil.prepareConfigFile("emptyConfig.json"); |
|
18 |
browser = SeleniumUtil.init(); |
|
19 |
SeleniumUtil.switchToRaw(); |
|
20 |
SeleniumUtil.loadGraphData("RawDetailTest.json"); |
|
21 |
} |
|
22 |
|
|
23 |
@Test |
|
24 |
void vertexDetail(){ |
|
25 |
checkPopover(vertexPopover("V1"),"V1 (3)\nD: E\nB: W\nA: Q"); |
|
26 |
|
|
27 |
checkPopover(vertexPopover("V2"),"V2 (2)\nD: E\nC: Q\nB: W"); |
|
28 |
|
|
29 |
checkPopover(vertexPopover("V3"),"V3 (1)\nD: Q\nC: W\nA: E"); |
|
30 |
} |
|
31 |
|
|
32 |
@Test |
|
33 |
void edgeDetail() { |
|
34 |
checkPopover(edgePopover("1"),"Edge details\nedgeArchetype1\nD: E\nC: W"); |
|
35 |
|
|
36 |
checkPopover(edgePopover("2"),"Edge details\nedgeArchetype1\nD: E\nB: W\nA: Q\nedgeArchetype2\nD: D\nB: S\nA: A"); |
|
37 |
|
|
38 |
checkPopover(edgePopover("3"),"Edge details\nedgeArchetype2\nC: T\nB: R"); |
|
39 |
} |
|
40 |
|
|
41 |
|
|
42 |
private WebElement edgePopover(String edgeId) { |
|
43 |
WebElement arrow = browser.findElement(By.cssSelector("[data-id='edges']")) |
|
44 |
.findElement(By.cssSelector("[data-id='" + edgeId + "']")) |
|
45 |
.findElement(By.className("arrow")); |
|
46 |
|
|
47 |
SeleniumUtil.svgClickWithOffset(arrow, 3, 0); |
|
48 |
return browser.findElement(By.className("edge-popover")); |
|
49 |
} |
|
50 |
|
|
51 |
private WebElement vertexPopover(String vertexElementName) { |
|
52 |
WebElement archetypeIcon = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
53 |
.findElement(By.cssSelector("[data-name='" + vertexElementName + "']")) |
|
54 |
.findElement(By.className("archetype-icon")); |
|
55 |
|
|
56 |
SeleniumUtil.svgClick(archetypeIcon); |
|
57 |
return browser.findElement(By.className("vertex-popover")); |
|
58 |
} |
|
59 |
|
|
60 |
private void checkPopover(WebElement popoverElement, String expectedText) { |
|
61 |
String text = popoverElement.getText(); |
|
62 |
Assertions.assertEquals(expectedText, text); |
|
63 |
} |
|
64 |
|
|
65 |
@AfterAll |
|
66 |
static void finishTest() { |
|
67 |
SeleniumUtil.clear(); |
|
68 |
} |
|
69 |
} |
sources/imiger-core/src/test/java/cz/zcu/kiv/imiger/tests/frontend/GroupStatsChangingTest.java | ||
---|---|---|
1 |
package cz.zcu.kiv.imiger.tests.frontend; |
|
2 |
|
|
3 |
import org.apache.logging.log4j.LogManager; |
|
4 |
import org.apache.logging.log4j.Logger; |
|
5 |
import org.junit.jupiter.api.AfterAll; |
|
6 |
import org.junit.jupiter.api.Assertions; |
|
7 |
import org.junit.jupiter.api.BeforeAll; |
|
8 |
import org.junit.jupiter.api.Test; |
|
9 |
import org.openqa.selenium.By; |
|
10 |
import org.openqa.selenium.WebDriver; |
|
11 |
import org.openqa.selenium.WebElement; |
|
12 |
|
|
13 |
import java.util.*; |
|
14 |
|
|
15 |
class GroupStatsChangingTest { |
|
16 |
private static final Logger logger = LogManager.getLogger(); |
|
17 |
private static WebDriver browser; |
|
18 |
|
|
19 |
@BeforeAll |
|
20 |
static void initTest() { |
|
21 |
SeleniumUtil.prepareConfigFile("emptyConfig.json"); |
|
22 |
browser = SeleniumUtil.init(); |
|
23 |
SeleniumUtil.switchToRaw(); |
|
24 |
SeleniumUtil.loadGraphData("RawAssociatedArchetypeTest.json"); |
|
25 |
} |
|
26 |
|
|
27 |
@Test |
|
28 |
void ChangingStats() { |
|
29 |
String groupId; |
|
30 |
SeleniumUtil.switchToExcludeMode(); |
|
31 |
WebElement firstExcludedVertex = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
32 |
.findElement(By.cssSelector("[data-id='3']")); |
|
33 |
|
|
34 |
SeleniumUtil.svgRectClick(firstExcludedVertex); |
|
35 |
logger.debug("Exclude vertex3 to group as first vertex of group"); |
|
36 |
|
|
37 |
excludeToExistingGroup("2"); |
|
38 |
logger.debug("Exclude vertex2 to group"); |
|
39 |
|
|
40 |
//get data-id of fgroup |
|
41 |
groupId = browser.findElement(By.id("excludedNodeListComponent")) |
|
42 |
.findElement(By.className("node")).getAttribute("data-id"); |
|
43 |
|
|
44 |
Map<String, String> map = new HashMap<>(); |
|
45 |
map.put("1", "2"); |
|
46 |
map.put("3", "1"); |
|
47 |
compareExpectedValues(groupId, map); |
|
48 |
|
|
49 |
// EXCLUDING VERTICES FROM GROUPS IS NOT SUPPORTED YET |
|
50 |
// excludeToExistingGroup("1"); |
|
51 |
// compareExpectedValues(groupId, new ArrayList<String>(Arrays.asList("2","2","0","2"))); |
|
52 |
// logger.debug("Exclude vertex1 to group"); |
|
53 |
// |
|
54 |
// logger.debug("Remove vertex2 to group"); |
|
55 |
// removeVertexFromGroup("li2"); |
|
56 |
// compareExpectedValues(groupId, new ArrayList<String>(Arrays.asList("1","2","0","2"))); |
|
57 |
// |
|
58 |
// logger.debug("Switch off stats for vertex1"); |
|
59 |
// toogleVertexInGroup("li1"); |
|
60 |
// compareExpectedValues(groupId, new ArrayList<String>(Arrays.asList("1","0","0","0"))); |
|
61 |
// |
|
62 |
// logger.debug("Switch off stats for vertex3"); |
|
63 |
// toogleVertexInGroup("li3"); |
|
64 |
// compareExpectedValues(groupId, new ArrayList<String>(Arrays.asList("0","0","0","0"))); |
|
65 |
// |
|
66 |
// logger.debug("Switch on stats for vertex1"); |
|
67 |
// toogleVertexInGroup("li3"); |
|
68 |
// excludeToExistingGroup("vertex2"); |
|
69 |
// compareExpectedValues(groupId, new ArrayList<String>(Arrays.asList("2","0","0","0"))); |
|
70 |
// |
|
71 |
// //finaly test just one vertex in group |
|
72 |
// String archetypePrefix = "v_archetype_4_"; |
|
73 |
// SeleniumUtil.switchToExcludeMode(); |
|
74 |
// WebElement singleEcludedVertex = browser.findElement(By.id("vertex4")); |
|
75 |
// logger.debug("Exclude vertex4 to group as first vertex of group"); |
|
76 |
// SeleniumUtil.svgClick(singleEcludedVertex); |
|
77 |
// |
|
78 |
// logger.debug("Checking group statistics"); |
|
79 |
// String actualValue1 = browser.findElement(By.id(archetypePrefix + "0")).findElement(By.tagName("text")).getText(); |
|
80 |
// String actualValue2 = browser.findElement(By.id(archetypePrefix + "2")).findElement(By.tagName("text")).getText(); |
|
81 |
// Assertions.assertEquals(actualValue1, "2"); |
|
82 |
// Assertions.assertEquals(actualValue2, "1"); |
|
83 |
// |
|
84 |
// logger.debug("Expected: 2 - Real: " + actualValue1); |
|
85 |
// logger.debug("Expected: 1 - Real: " + actualValue2); |
|
86 |
|
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Exclude vertex from graph to group |
|
91 |
* @param vertexId id of vertex to exclude |
|
92 |
*/ |
|
93 |
private void excludeToExistingGroup(String vertexId){ |
|
94 |
WebElement secondExcludedVertex = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
95 |
.findElement(By.cssSelector("[data-id='" + vertexId + "']")); |
|
96 |
|
|
97 |
SeleniumUtil.svgContextClick(secondExcludedVertex.findElement(By.tagName("rect"))); |
|
98 |
WebElement selectedGroup = browser.findElement(By.className("context-menu")).findElements(By.tagName("li")).get(0); |
|
99 |
selectedGroup.click(); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Remove vertex from group back to graph |
|
104 |
* @param vertexId id of vertex |
|
105 |
*/ |
|
106 |
private void removeVertexFromGroup(String vertexId){ |
|
107 |
WebElement removeVertex = browser.findElement(By.id(vertexId)).findElement(By.className("deleteItemGroup")); |
|
108 |
SeleniumUtil.svgClick(removeVertex); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Toogle stats for vertex |
|
113 |
* @param vertexId id of vertex |
|
114 |
*/ |
|
115 |
private void toogleVertexInGroup(String vertexId){ |
|
116 |
WebElement removeVertex = browser.findElement(By.id(vertexId)).findElement(By.className("toggleStat")); |
|
117 |
SeleniumUtil.svgClick(removeVertex); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* comparison of real values with expected values |
|
122 |
* @param groupId id of group |
|
123 |
* @param expectedValues list of expected values |
|
124 |
*/ |
|
125 |
private void compareExpectedValues(String groupId, Map<String, String> expectedValues){ |
|
126 |
logger.debug("Checking group statistics"); |
|
127 |
String archetypePrefix = "#vertexArchetypeIcon-"; |
|
128 |
|
|
129 |
WebElement nodeList = browser.findElement(By.id("excludedNodeListComponent")) |
|
130 |
.findElement(By.className("node-list")); |
|
131 |
|
|
132 |
for (String key : expectedValues.keySet()) { |
|
133 |
|
|
134 |
List<WebElement> gList = nodeList.findElement(By.cssSelector("[href='" + archetypePrefix + key + "']")) |
|
135 |
.findElements(By.xpath("//parent::*[name()='g']")); |
|
136 |
|
|
137 |
|
|
138 |
String actualValue = gList.get(gList.size() - 1) |
|
139 |
.findElement(By.tagName("text")).getText(); |
|
140 |
|
|
141 |
Assertions.assertEquals(actualValue, expectedValues.get(key)); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
@AfterAll |
|
146 |
static void finishTest() { |
|
147 |
SeleniumUtil.clear(); |
|
148 |
} |
|
149 |
} |
sources/imiger-core/src/test/java/cz/zcu/kiv/imiger/tests/frontend/SeleniumUtil.java | ||
---|---|---|
1 |
package cz.zcu.kiv.imiger.tests.frontend; |
|
2 |
|
|
3 |
import org.apache.logging.log4j.LogManager; |
|
4 |
import org.apache.logging.log4j.Logger; |
|
5 |
import org.openqa.selenium.By; |
|
6 |
import org.openqa.selenium.WebDriver; |
|
7 |
import org.openqa.selenium.WebElement; |
|
8 |
import org.openqa.selenium.firefox.FirefoxDriver; |
|
9 |
import org.openqa.selenium.interactions.Actions; |
|
10 |
import org.openqa.selenium.support.ui.ExpectedConditions; |
|
11 |
import org.openqa.selenium.support.ui.WebDriverWait; |
|
12 |
|
|
13 |
import java.io.IOException; |
|
14 |
import java.nio.file.Files; |
|
15 |
import java.nio.file.Paths; |
|
16 |
|
|
17 |
class SeleniumUtil { |
|
18 |
private static final Logger logger = LogManager.getLogger(); |
|
19 |
private static final String TEST_DIRECTORY = System.getProperty("user.dir") + "\\src\\test\\resources"; |
|
20 |
|
|
21 |
/** |
|
22 |
* Path to the config location folder |
|
23 |
* Path should be the same as in web.xml file |
|
24 |
* Please change to your location |
|
25 |
*/ |
|
26 |
private static final String APP_CONFIG_LOCATION = "C:\\Users\\Tomas\\Sources\\swi\\IMiGEr\\config"; |
|
27 |
|
|
28 |
private static final String GECKO_PATH = TEST_DIRECTORY + "\\geckodriver.exe"; |
|
29 |
|
|
30 |
private static final String URL = "http://localhost:8080/imiger/"; |
|
31 |
|
|
32 |
private static final int DATA_LOAD_TIMEOUT = 20; |
|
33 |
|
|
34 |
private static WebDriver browser; |
|
35 |
|
|
36 |
static WebDriver init() { |
|
37 |
System.setProperty("webdriver.gecko.driver", GECKO_PATH); |
|
38 |
browser = new FirefoxDriver(); |
|
39 |
browser.get(URL); |
|
40 |
return browser; |
|
41 |
} |
|
42 |
|
|
43 |
static void loadGraphData(String filename) { |
|
44 |
WebElement fileInput = browser.findElement(By.id("file")); |
|
45 |
fileInput.sendKeys(TEST_DIRECTORY + "\\data\\" + filename ); |
|
46 |
browser.findElement(By.id("btnLoad")).click(); |
|
47 |
|
|
48 |
WebDriverWait wait = new WebDriverWait(browser, DATA_LOAD_TIMEOUT); |
|
49 |
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("viewport"))); |
|
50 |
|
|
51 |
try { |
|
52 |
Thread.sleep(1000); |
|
53 |
} catch (InterruptedException e) { |
|
54 |
logger.warn("Thread.sleep caused exception: ", e); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
static void prepareConfigFile(String configFile) { |
|
59 |
try { |
|
60 |
Files.deleteIfExists(Paths.get(APP_CONFIG_LOCATION + "\\config.json")); |
|
61 |
Files.createLink(Paths.get(APP_CONFIG_LOCATION + "\\config.json"), |
|
62 |
Paths.get(TEST_DIRECTORY + "\\config\\" + configFile)); |
|
63 |
} catch (IOException e) { |
|
64 |
logger.error("Can not prepare configuration file: ", e); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
static void switchToRaw(){ |
|
69 |
browser.findElement(By.id("raw")).click(); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* Turn on exclude mode for vertex exclude |
|
74 |
*/ |
|
75 |
static void switchToExcludeMode(){ |
|
76 |
browser.findElement(By.id("exclude")).click(); |
|
77 |
|
|
78 |
try { |
|
79 |
Thread.sleep(1000); |
|
80 |
} catch (InterruptedException e) { |
|
81 |
logger.warn("Thread.sleep caused exception: ", e); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
static void svgRectClick(WebElement toClick){ |
|
86 |
toClick.findElement(By.tagName("rect")).click(); |
|
87 |
|
|
88 |
try { |
|
89 |
Thread.sleep(1000); |
|
90 |
} catch (InterruptedException e) { |
|
91 |
logger.warn("Thread.sleep caused exception: ", e); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
static void svgRectContextClick(WebElement toClick){ |
|
96 |
Actions builder = new Actions(browser); |
|
97 |
builder.contextClick(toClick.findElement(By.tagName("rect"))).build().perform(); |
|
98 |
|
|
99 |
try { |
|
100 |
Thread.sleep(1000); |
|
101 |
} catch (InterruptedException e) { |
|
102 |
logger.warn("Thread.sleep caused exception: ", e); |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
static void svgClick(WebElement toClick) { |
|
107 |
svgClickWithOffset(toClick, 0, 0); |
|
108 |
} |
|
109 |
|
|
110 |
static void svgClickWithOffset(WebElement toClick, int xOffset, int yOffset) { |
|
111 |
Actions builder = new Actions(browser); |
|
112 |
builder.moveToElement(toClick).moveByOffset(xOffset,yOffset).click().build().perform(); |
|
113 |
|
|
114 |
try { |
|
115 |
Thread.sleep(1000); |
|
116 |
} catch (InterruptedException e) { |
|
117 |
logger.warn("Thread.sleep caused exception: ", e); |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Right mouse click |
|
123 |
* @param toClick element for click |
|
124 |
*/ |
|
125 |
static void svgContextClick(WebElement toClick) { |
|
126 |
Actions builder = new Actions(browser); |
|
127 |
builder.moveToElement(toClick).contextClick().build().perform(); |
|
128 |
|
|
129 |
try { |
|
130 |
Thread.sleep(1000); |
|
131 |
} catch (InterruptedException e) { |
|
132 |
logger.warn("Thread.sleep caused exception: ", e); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
static void clear() { |
|
137 |
browser.close(); |
|
138 |
} |
|
139 |
} |
sources/imiger-core/src/test/resources/config/archetypeIconConfigTest.json | ||
---|---|---|
1 |
{ |
|
2 |
"defaultFilter": { |
|
3 |
"vertexArchetypeFilter": { |
|
4 |
"archetypes": [ ], |
|
5 |
"matchType": "non_matching" |
|
6 |
}, |
|
7 |
|
|
8 |
"edgeArchetypeFilter": { |
|
9 |
"archetypes": [ |
|
10 |
|
|
11 |
], |
|
12 |
"matchType": "non_matching" |
|
13 |
}, |
|
14 |
|
|
15 |
"vertexAttributeFilters": [], |
|
16 |
|
|
17 |
"edgeAttributeFilters": [] |
|
18 |
}, |
|
19 |
|
|
20 |
"defaultGroupArchetypes": [], |
|
21 |
|
|
22 |
"archetypeIcons": [ |
|
23 |
{ |
|
24 |
name: "SpecifiedIcon", |
|
25 |
value: "<rect class=\"testingArchetypeIcon\" width=\"12\" height=\"15\" x=\"0\" y =\"0\" stroke=\"none\" fill=\"green\"/>" |
|
26 |
} |
|
27 |
] |
|
28 |
} |
sources/imiger-core/src/test/resources/config/automaticGroupingConfigTest.json | ||
---|---|---|
1 |
{ |
|
2 |
"defaultFilter": { |
|
3 |
"vertexArchetypeFilter": { |
|
4 |
"archetypes": [ ], |
|
5 |
"matchType": "non_matching" |
|
6 |
}, |
|
7 |
|
|
8 |
"edgeArchetypeFilter": { |
|
9 |
"archetypes": [ |
|
10 |
|
|
11 |
], |
|
12 |
"matchType": "non_matching" |
|
13 |
}, |
|
14 |
|
|
15 |
"vertexAttributeFilters": [], |
|
16 |
|
|
17 |
"edgeAttributeFilters": [] |
|
18 |
}, |
|
19 |
|
|
20 |
"defaultGroupArchetypes": ["FirstGroupArchetype"], |
|
21 |
|
|
22 |
"archetypeIcons": [] |
|
23 |
} |
sources/imiger-core/src/test/resources/config/emptyConfig.json | ||
---|---|---|
1 |
{ |
|
2 |
"defaultFilter": { |
|
3 |
"vertexArchetypeFilter": { |
|
4 |
"archetypes": [ ], |
|
5 |
"matchType": "non_matching" |
|
6 |
}, |
|
7 |
|
|
8 |
"edgeArchetypeFilter": { |
|
9 |
"archetypes": [ |
|
10 |
|
|
11 |
], |
|
12 |
"matchType": "non_matching" |
|
13 |
}, |
|
14 |
|
|
15 |
"vertexAttributeFilters": [], |
|
16 |
|
|
17 |
"edgeAttributeFilters": [] |
|
18 |
}, |
|
19 |
|
|
20 |
"defaultGroupArchetypes": [], |
|
21 |
|
|
22 |
"archetypeIcons": [] |
|
23 |
} |
sources/imiger-core/src/test/resources/data/RawArchetypeIconTest.json | ||
---|---|---|
1 |
{"attributeTypes":[],"edgeArchetypes":[{"name":"edge","text":""}],"vertexArchetypes":[{"icon":"<rect class=\"testingArchetypeIcon\" width=\"12\" height=\"15\" x=\"0\" y =\"0\" stroke=\"none\" fill=\"green\"/>","name":"SpecifiedIcon","text":""},{"icon":"","name":"UnspecifiedIcon","text":""},{"icon":"<text y=\"8\" fill=\"red\">☺</text>","name":"Smiley","text":""}],"vertices":[{"archetype":0,"attributes":[],"id":1,"text":"","name":"Vertex with specified icon","position":{"x":640.5,"y":408.25}},{"archetype":1,"attributes":[],"id":2,"text":"","name":"Vertex with unspecified icon","position":{"x":826.25,"y":536.75}},{"archetype":2,"attributes":[],"id":3,"text":"","name":"Vertex with smiley as archetype icon","position":{"x":438,"y":537.75}}],"edges":[{"subedgeInfo":[{"archetype":0,"attributes":[],"id":1}],"from":1,"to":3,"text":"","id":1},{"subedgeInfo":[{"archetype":0,"attributes":[],"id":0}],"from":1,"to":2,"text":"","id":2}],"possibleEnumValues":{},"groups":[],"sideBar":[],"highlightedVertex":"","highlightedEdge":""} |
sources/imiger-core/src/test/resources/data/RawAssociatedArchetypeTest.json | ||
---|---|---|
1 |
{"attributeTypes":[],"edgeArchetypes":[{"name":"edge","text":""}],"vertexArchetypes":[{"icon":"","name":"1","text":""},{"icon":"","name":"2","text":""},{"icon":"","name":"3","text":""},{"icon":"","name":"4","text":""}],"vertices":[{"archetype":0,"attributes":[],"id":1,"text":"","name":"V1","position":{"x":989.5,"y":684}},{"archetype":1,"attributes":[],"id":2,"text":"","name":"V2","position":{"x":985.75,"y":871.5}},{"archetype":1,"attributes":[],"id":3,"text":"","name":"V3","position":{"x":988,"y":540}},{"archetype":3,"attributes":[],"id":4,"text":"","name":"V4","position":{"x":694,"y":678.25}},{"archetype":2,"attributes":[],"id":5,"text":"","name":"V5","position":{"x":702.75,"y":755}}],"edges":[{"subedgeInfo":[{"archetype":0,"attributes":[],"id":0}],"from":1,"to":2,"text":"","id":1},{"subedgeInfo":[{"archetype":0,"attributes":[],"id":4}],"from":4,"to":5,"text":"","id":2},{"subedgeInfo":[{"archetype":0,"attributes":[],"id":2}],"from":1,"to":4,"text":"","id":3},{"subedgeInfo":[{"archetype":0,"attributes":[],"id":1}],"from":3,"to":1,"text":"","id":4},{"subedgeInfo":[{"archetype":0,"attributes":[],"id":3}],"from":4,"to":1,"text":"","id":5}],"possibleEnumValues":{},"groups":[],"sideBar":[],"highlightedVertex":"","highlightedEdge":""} |
sources/imiger-core/src/test/resources/data/RawDetailTest.json | ||
---|---|---|
1 |
{"attributeTypes":[{"dataType":"STRING","name":"D","text":"0"},{"dataType":"STRING","name":"C","text":"1"},{"dataType":"STRING","name":"B","text":"2"},{"dataType":"STRING","name":"A","text":"3"}],"edgeArchetypes":[{"name":"edgeArchetype1","text":""},{"name":"edgeArchetype2","text":""}],"vertexArchetypes":[{"icon":"","name":"1","text":""},{"icon":"","name":"2","text":""},{"icon":"","name":"3","text":""}],"vertices":[{"archetype":2,"attributes":[["D","E"],["B","W"],["A","Q"]],"id":1,"text":"","name":"V1","position":{"x":753.25,"y":693.75}},{"archetype":1,"attributes":[["D","E"],["C","Q"],["B","W"]],"id":2,"text":"","name":"V2","position":{"x":534.25,"y":897.5}},{"archetype":0,"attributes":[["D","Q"],["C","W"],["A","E"]],"id":3,"text":"","name":"V3","position":{"x":961.25,"y":899.75}}],"edges":[{"subedgeInfo":[{"archetype":0,"attributes":[["D","E"],["C","W"]],"id":3}],"from":1,"to":3,"text":"","id":1},{"subedgeInfo":[{"archetype":0,"attributes":[["D","E"],["B","W"],["A","Q"]],"id":1},{"archetype":1,"attributes":[["D","D"],["B","S"],["A","A"]],"id":2}],"from":1,"to":2,"text":"","id":2},{"subedgeInfo":[{"archetype":1,"attributes":[["C","T"],["B","R"]],"id":4}],"from":3,"to":1,"text":"","id":3}],"possibleEnumValues":{},"groups":[],"sideBar":[],"highlightedVertex":"","highlightedEdge":""} |
sources/imiger-core/src/test/resources/data/automaticGroupingTest.json | ||
---|---|---|
1 |
{ |
|
2 |
"attributeTypes": [ |
|
3 |
|
|
4 |
], |
|
5 |
"vertexArchetypes": [ |
|
6 |
{ |
|
7 |
"name": "FirstGroupArchetype", |
|
8 |
"text": "" |
|
9 |
}, |
|
10 |
{ |
|
11 |
"name": "NonGroupArchetype", |
|
12 |
"text": "" |
|
13 |
} |
|
14 |
], |
|
15 |
"edgeArchetypes": [ |
|
16 |
{ |
|
17 |
"name": "edge", |
|
18 |
"text": "" |
|
19 |
} |
|
20 |
], |
|
21 |
"vertices": [ |
|
22 |
{ |
|
23 |
"archetype": 0, |
|
24 |
"attributes": {}, |
|
25 |
"id": 1, |
|
26 |
"text": "", |
|
27 |
"title": "First vertex from first group" |
|
28 |
}, |
|
29 |
{ |
|
30 |
"archetype": 1, |
|
31 |
"attributes": {}, |
|
32 |
"id": 2, |
|
33 |
"text": "", |
|
34 |
"title": "Non group vertex" |
|
35 |
}, |
|
36 |
{ |
|
37 |
"archetype": 0, |
|
38 |
"attributes": {}, |
|
39 |
"id": 3, |
|
40 |
"text": "", |
|
41 |
"title": "Second vertex from first group" |
|
42 |
}, |
|
43 |
{ |
|
44 |
"archetype": 1, |
|
45 |
"attributes": {}, |
|
46 |
"id": 4, |
|
47 |
"text": "", |
|
48 |
"title": "Non group vertex" |
|
49 |
}, |
|
50 |
{ |
|
51 |
"archetype": 1, |
|
52 |
"attributes": {}, |
|
53 |
"id": 5, |
|
54 |
"text": "", |
|
55 |
"title": "Non group vertex" |
|
56 |
} |
|
57 |
], |
|
58 |
"edges": [ |
|
59 |
{ |
|
60 |
"archetype": 0, |
|
61 |
"from": 1, |
|
62 |
"attributes": {}, |
|
63 |
"id": 0, |
|
64 |
"to": 2, |
|
65 |
"text": "" |
|
66 |
}, |
|
67 |
{ |
|
68 |
"archetype": 0, |
|
69 |
"from": 1, |
|
70 |
"attributes": {}, |
|
71 |
"id": 1, |
|
72 |
"to": 3, |
|
73 |
"text": "" |
|
74 |
}, |
|
75 |
{ |
|
76 |
"archetype": 0, |
|
77 |
"from": 2, |
|
78 |
"attributes": {}, |
|
79 |
"id": 1, |
|
80 |
"to": 5, |
|
81 |
"text": "" |
|
82 |
}, |
|
83 |
{ |
|
84 |
"archetype": 0, |
|
85 |
"from": 2, |
|
86 |
"attributes": {}, |
|
87 |
"id": 1, |
|
88 |
"to": 4, |
|
89 |
"text": "" |
|
90 |
}, |
|
91 |
{ |
|
92 |
"archetype": 0, |
|
93 |
"from": 5, |
|
94 |
"attributes": {}, |
|
95 |
"id": 1, |
|
96 |
"to": 4, |
|
97 |
"text": "" |
|
98 |
}, |
|
99 |
{ |
|
100 |
"archetype": 0, |
|
101 |
"from": 4, |
|
102 |
"attributes": {}, |
|
103 |
"id": 1, |
|
104 |
"to": 2, |
|
105 |
"text": "" |
|
106 |
}, |
|
107 |
] |
|
108 |
} |
Také k dispozici: Unified diff
Remove obsolete selenium tests (#7266)