Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
aa138926
Commit
aa138926
authored
11 years ago
by
Joël Krähemann
Browse files
Options
Downloads
Patches
Plain Diff
FXOLAT-208: Fixed FunctionalCatalogTest
parent
2f39dad2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/java/org/olat/util/CatalogTreeEntryPosition.vm
+32
-0
32 additions, 0 deletions
src/test/java/org/olat/util/CatalogTreeEntryPosition.vm
src/test/java/org/olat/util/FunctionalCourseUtil.java
+33
-30
33 additions, 30 deletions
src/test/java/org/olat/util/FunctionalCourseUtil.java
with
65 additions
and
30 deletions
src/test/java/org/olat/util/CatalogTreeEntryPosition.vm
0 → 100644
+
32
−
0
View file @
aa138926
offset = -1;
if(document.querySelector)
{
var selector = "
${
treeSelector
}
";
var path = "
${
treePath
}
";
/* make array out of path */
path = path.substring(1);
var item = path.split("/");
/* count items till path fits */
var selection = window.document.evaluate(selector, window.document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var i = 0;
var j = 0;
for(; i
<
selection.snapshotLength
&&
j
<
item.length
;
i
++){
var
current =
selection.snapshotItem(i);
if
(
current
!=
null
){
var
itemSelector =
"("
+
selector
+
")["
+
(
i
)
+
"]//
div
[
contains
(@
class
,
'
b_selectiontree_content
')
and
text()=
'" + item[j] + "'
]";
var
itemSelection =
window.document.evaluate(itemSelector,
window.document
,
null
,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE
,
null
);
if
(
itemSelection
!=
null
&&
itemSelection.snapshotLength
>
0)
{
j++;
}
}
}
offset = (i / 2) - (item.length - 1);
}
offset;
This diff is collapsed.
Click to expand it.
src/test/java/org/olat/util/FunctionalCourseUtil.java
+
33
−
30
View file @
aa138926
...
...
@@ -24,6 +24,7 @@ import java.io.StringWriter;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -887,38 +888,42 @@ public class FunctionalCourseUtil {
/*
* Determine best matching item by using regular expressions
*/
Matcher
categoryMatcher
=
categoryPattern
.
matcher
(
path
);
StringBuffer
itemLocator
=
new
StringBuffer
();
int
i
=
0
;
while
(
categoryMatcher
.
find
()){
itemLocator
.
append
(
"(<div[\\s]*class=\"b_selectiontree_content\"[\\s]*>[\\s]*"
+
categoryMatcher
.
group
(
1
)
+
"[\\s]*</div>[\\s]*)?[\\s]*"
);
i
++;
}
itemLocator
.
deleteCharAt
(
itemLocator
.
length
()
-
1
);
int
segmentCount
=
i
;
String
item
=
path
.
substring
(
path
.
lastIndexOf
(
'/'
)
+
1
);
itemLocator
.
append
(
"//div[contains(@class, 'b_selectiontree_item')]"
);
Pattern
itemPattern
=
Pattern
.
compile
(
itemLocator
.
toString
());
String
dom
=
browser
.
getHtmlSource
();
Matcher
itemMatcher
=
itemPattern
.
matcher
(
dom
);
VelocityContext
context
=
new
VelocityContext
();
context
.
put
(
"treeSelector"
,
itemLocator
.
toString
());
context
.
put
(
"treePath"
,
path
);
int
offset
=
1
;
boolean
foundPath
=
false
;
VelocityEngine
engine
=
null
;
engine
=
new
VelocityEngine
();
StringWriter
sw
=
new
StringWriter
();
Integer
offset
=
null
;
for
(;
itemMatcher
.
find
();
offset
++){
int
j
=
1
;
try
{
engine
.
evaluate
(
context
,
sw
,
"catalogTreeEntryPosition"
,
FunctionalEPortfolioUtil
.
class
.
getResourceAsStream
(
"CatalogTreeEntryPosition.vm"
));
offset
=
new
Integer
(
browser
.
getEval
(
sw
.
toString
()));
if
(
itemMatcher
.
group
(
0
)
!=
null
&&
!
itemMatcher
.
group
(
0
).
isEmpty
()){
foundPath
=
true
;
break
;
if
(
offset
.
intValue
()
==
-
1
){
return
(
null
);
}
}
if
(!
foundPath
){
return
(
null
);
}
catch
(
ParseErrorException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
MethodInvocationException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
ResourceNotFoundException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
/* create selector */
...
...
@@ -926,10 +931,8 @@ public class FunctionalCourseUtil {
selectorBuffer
.
append
(
"xpath=(//div[contains(@class, '"
)
.
append
(
"b_selectiontree_item"
)
.
append
(
"')]//div[contains(@class, 'b_selectiontree_content') and text()='"
)
.
append
(
item
)
.
append
(
"']/../..//input[@type='radio'])[position()='"
)
.
append
(
offset
)
.
append
(
"')]//input[@type='radio'])[position()='"
)
.
append
(
offset
.
intValue
())
.
append
(
"']"
);
return
(
selectorBuffer
.
toString
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment