Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09054a9

Browse files
committed
remove deprecated keywords and methods (enhancement #11)
1 parent b5c06b3 commit 09054a9

File tree

5 files changed

+0
-425
lines changed

5 files changed

+0
-425
lines changed

src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java

-11
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,6 @@ public String getCurrentApplication() {
263263
}
264264
}
265265

266-
@Deprecated
267-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use `Get Current Application` keyword instead.\n\n"
268-
+ "Returns the class name of currently active JavaFX Application\n")
269-
public String currentApplication() {
270-
try {
271-
return getCurrentSessionApplicationName();
272-
} catch (Exception e) {
273-
throw new JavaFXLibraryNonFatalException("Problem getting current application name.", e);
274-
}
275-
}
276-
277266
@RobotKeyword("Returns if JavaFXLibrary is started as java agent.")
278267
public boolean isJavaAgent() {
279268
return TestFxAdapter.isAgent;

src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java

-222
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,6 @@
5454
@RobotKeywords
5555
public class ConvenienceKeywords extends TestFxAdapter {
5656

57-
@Deprecated
58-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n" +
59-
"finder that mimics _xpath_ style search.\n\n"
60-
+ "``query`` is a query locator, see `3.1 Locator syntax`.\n\n"
61-
+ "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
62-
+ "keyword returns null in case lookup returns nothing.\n\n"
63-
+ "\nExample:\n"
64-
+ " | ${node}= | Find With Path | .main-view[0] .split-pane[0] \\#node-id class=GridPane .toggle-button[3] sometext | ")
65-
@ArgumentNames({"query", "failIfNotFound=False"})
66-
public Object findWithPath(String query, boolean failIfNotFound){
67-
68-
try {
69-
return mapObject(findNode(query));
70-
71-
} catch (JavaFXLibraryNonFatalException e){
72-
if(failIfNotFound)
73-
throw new JavaFXLibraryNonFatalException("Unable to find anything with query: \"" + query + "\"");
74-
return "";
75-
76-
} catch (Exception e) {
77-
throw new JavaFXLibraryNonFatalException("Find operation failed for query: \"" + query + "\"", e);
78-
}
79-
}
80-
8157
@RobotKeyword("Brings the given stage to front\n\n"
8258
+ "``stage`` is an Object:Stage to be set in front of others, see `3.2 Using locators as keyword arguments`. \n\n")
8359
@ArgumentNames({ "stage" })
@@ -130,116 +106,6 @@ public void callObjectMethodInFxApplicationThread(Object object, String method,
130106
callMethod(object, method, finalArgs, true);
131107
}
132108

133-
@Deprecated
134-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n"
135-
+ "Returns the *first* node matching the query. \n\n"
136-
+ "``query`` is the Class name String to use in lookup.\n"
137-
+ "\nExample:\n"
138-
+ "| ${my node}= | Find | javafx.scene.control.Button | # button class |")
139-
@ArgumentNames({ "query" })
140-
public Object findClass(final String query) {
141-
try {
142-
Class<?> clazz = Class.forName(query);
143-
InstanceOfMatcher matcher = new InstanceOfMatcher(clazz);
144-
return mapObject(robot.lookup(matcher).query());
145-
} catch (Exception e) {
146-
RobotLog.trace("Problem has occurred during node lookup: " + e);
147-
return "";
148-
}
149-
}
150-
151-
@Deprecated
152-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find All` instead.\n\n"
153-
+ "Returns *all* descendant nodes of given node matching the query. \n\n"
154-
+ "``node`` is the starting point Object:Node from where to start looking, see `3.2 Using locators as keyword arguments`. \n\n"
155-
+ "``query`` is a query locator, see `3.1 Locator syntax`.\n\n"
156-
+ "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
157-
+ "keyword returns null in case lookup returns nothing.\n\n"
158-
+ "\nExample:\n"
159-
+ "| ${my nodes}= | Find All From Node | ${some node} | .css | \n"
160-
+ "See keyword `Find` for further examples of query usage.\n")
161-
@ArgumentNames({ "node", "query", "failIfNotFound=False" })
162-
public List<Object> findAllFromNode(Object node, String query, boolean failIfNotFound) {
163-
try {
164-
if ( node instanceof Node ) {
165-
RobotLog.info("Trying to find all nodes with query: \"" + query + "\" that are under starting " +
166-
"point node: \"" + node + "\", failIfNotFound= \"" + failIfNotFound + "\"");
167-
return mapObjects(((Node) node).lookupAll(query));
168-
}
169-
// fail in case no valid node argument.
170-
failIfNotFound = true;
171-
throw new JavaFXLibraryNonFatalException("Illegal argument type for node.");
172-
} catch (JavaFXLibraryNonFatalException e){
173-
if(failIfNotFound)
174-
throw e;
175-
return Collections.emptyList();
176-
177-
} catch (Exception e) {
178-
throw new JavaFXLibraryNonFatalException("Find all from node operation failed for node: \"" + node.toString() +
179-
"\" and query: " + query, e);
180-
}
181-
}
182-
183-
@Deprecated
184-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find All` instead.\n\n"
185-
+ "Returns *all* nodes matching query AND given pseudo-class state. \r\n"
186-
+ "``query`` is a query locator, see `3.1 Locator syntax`.\n\n"
187-
+ "``pseudo`` is a String value specifying pseudo class value.\n\n"
188-
+ "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
189-
+ "keyword returns null in case lookup returns nothing.\n\n"
190-
+ "\nExample:\n"
191-
+ "| ${my node}= | Find All With Pseudo Class | .check-box-tree-cell .check-box | selected | \n")
192-
@ArgumentNames({ "query", "pseudo", "failIfNotFound=False" })
193-
public List<Object> findAllWithPseudoClass(String query, String pseudo, boolean failIfNotFound) {
194-
RobotLog.info("Trying to find all nodes with query: \"" + query + "\" that has pseudoclass state as: \"" +
195-
pseudo + "\", failIfNotFound= \"" + failIfNotFound + "\"");
196-
try {
197-
Set<Node> nodes = robot.lookup(query).queryAll();
198-
Set<Node> matches = nodes.stream()
199-
.filter(n -> n.getPseudoClassStates().stream().
200-
map(PseudoClass::getPseudoClassName).anyMatch(pseudo::contains))
201-
.collect(Collectors.toSet());
202-
return mapObjects(matches);
203-
204-
} catch (JavaFXLibraryNonFatalException e){
205-
if(failIfNotFound)
206-
throw e;
207-
return Collections.emptyList();
208-
209-
} catch (Exception e) {
210-
throw new JavaFXLibraryNonFatalException("Find all with pseudo class operation failed for query: \"" +
211-
query + "\" and pseudo: \"" + pseudo + "\"", e);
212-
}
213-
}
214-
215-
@Deprecated
216-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n"
217-
+ "Returns the *first* descendant node of given node matching the query. \n\n"
218-
+ "``node`` is the starting point Object:Node from where to start looking, see `3.2 Using locators as keyword arguments`. \n\n"
219-
+ "``query`` is a query locator, see `3.1 Locator syntax`.\n\n"
220-
+ "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and "
221-
+ "keyword returns null in case lookup returns nothing.\n\n"
222-
+ "\nExample:\n"
223-
+ "| ${my node}= | Find From Node | ${some node} | .css |\n"
224-
+ "See keyword `Find` for further examples of query usage.\n")
225-
@ArgumentNames({ "node", "query", "failIfNotFound=False" })
226-
public Object findFromNode(Node node, String query, boolean failIfNotFound) {
227-
RobotLog.info("Trying to find: \"" + query + "\" from node: \"" + node + "\", failIfNotFound= \"" + failIfNotFound + "\"");
228-
try {
229-
Node childNode = node.lookup(query);
230-
return mapObject(childNode);
231-
232-
} catch (JavaFXLibraryNonFatalException e){
233-
if(failIfNotFound)
234-
throw e;
235-
return "";
236-
237-
} catch (Exception e) {
238-
throw new JavaFXLibraryNonFatalException("Find from node operation failed for node: \"" + node +
239-
"\" and query: " + query, e);
240-
}
241-
}
242-
243109
@RobotKeyword("Lists methods available for given node.\n"
244110
+ "``node`` is the Object:Node which methods to list, see `3.2 Using locators as keyword arguments`. \n\n"
245111
+ "When working with custom components you may use this keyword to discover methods you can call "
@@ -390,40 +256,6 @@ public Set<PseudoClass> getPseudoClassStates(Object locator) {
390256
}
391257
}
392258

393-
// TODO: Should this be deleted? Find All From Node has the same functionality
394-
@Deprecated
395-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n"
396-
+ "Returns *all* descendant nodes of given node matching the given Java class name. \n\n"
397-
+ "``locator`` is either a _query_ or _Object_ for node whose children will be queried, see "
398-
+ "`3.2 Using locators as keyword arguments`. \n\n"
399-
+ "``className`` is the Java class name to look for.\n"
400-
+ "\nExample:\n"
401-
+ "| ${panes}= | Get Node Children By Class Name | ${some node} | BorderPane | \n"
402-
+ "Returns an empty list if none is found. \n")
403-
@ArgumentNames({ "node", "className" })
404-
public Set<Object> getNodeChildrenByClassName(Object locator, String className) {
405-
Node node = objectToNode(locator);
406-
RobotLog.info("Getting node: \"" + node + "\" children by class name: \"" + className + "\"");
407-
try {
408-
Set<Object> keys = new HashSet<>();
409-
Set childNodes = node.lookupAll("*");
410-
411-
for (Object o : childNodes) {
412-
Node childNode = (Node) o;
413-
if (childNode.getClass().getSimpleName().equals(className)) {
414-
RobotLog.trace("Classname: \"" + className + "\" found: \"" + childNode + "\"");
415-
keys.add(mapObject(childNode));
416-
}
417-
}
418-
return keys;
419-
} catch (Exception e) {
420-
if(e instanceof JavaFXLibraryNonFatalException)
421-
throw e;
422-
throw new JavaFXLibraryNonFatalException("Unable to get node children for node: \"" + node.toString() +
423-
"\" with class name: " + className, e);
424-
}
425-
}
426-
427259
@RobotKeyword("Returns text value of the Node. \n\n"
428260
+ "``locator`` is either a _query_ or _Object_ for a node whose getText method will be called, see "
429261
+ "`3. Locating JavaFX Nodes`. \n\n")
@@ -441,35 +273,6 @@ public String getNodeText(Object locator) {
441273
}
442274
}
443275

444-
@Deprecated
445-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Find` instead.\n\n"
446-
+ "Returns height value of the node. \n\n"
447-
+ "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see "
448-
+ "`3. Locating JavaFX Nodes`. \n\n")
449-
@ArgumentNames({ "locator" })
450-
public String getNodeHeight(Object locator) {
451-
Node node = objectToNode(locator);
452-
try {
453-
Method[] methods = node.getClass().getMethods();
454-
for (Method m : methods) {
455-
if (m.getName().equals("getHeight")) {
456-
try {
457-
Object result = m.invoke(node, (Object) null);
458-
return result.toString();
459-
} catch (Exception e) {
460-
throw new JavaFXLibraryNonFatalException("Problem calling method: .getHeight(): " + e.getMessage(), e);
461-
}
462-
}
463-
}
464-
throw new JavaFXLibraryNonFatalException(
465-
"Get node height failed for node: \"" + node.toString() + "\". Element has no method getHeight()");
466-
} catch (Exception e) {
467-
if (e instanceof JavaFXLibraryNonFatalException)
468-
throw e;
469-
throw new JavaFXLibraryNonFatalException("Unable to get node height for node: " + node.toString(), e);
470-
}
471-
}
472-
473276
@RobotKeyword("Returns image name and path of the node. \n\n"
474277
+ "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see "
475278
+ "`3. Locating JavaFX Nodes`. \n\n"
@@ -535,31 +338,6 @@ public String getObjectClassName(Object locator) {
535338
}
536339
}
537340

538-
@Deprecated
539-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use keyword `Get Scene` instead.\n\n"
540-
+"Returns given locators Scene object. \n\n"
541-
+ "``locator`` is either a _query_ or a _Node_, see `3.2 Using locators as keyword arguments`\n\n")
542-
@ArgumentNames({ "locator" })
543-
public Object getNodesScene(Object locator) {
544-
try {
545-
if (locator instanceof Node){
546-
RobotLog.info("Getting a Scene object for a Node: \"" + locator + "\"");
547-
return mapObject(((Node) locator).getScene());
548-
} else if (locator instanceof String) {
549-
RobotLog.info("Getting a Scene object for a query: \"" + locator + "\"");
550-
Node node = objectToNode(locator);
551-
return mapObject(node.getScene());
552-
}
553-
554-
throw new JavaFXLibraryNonFatalException("Locator type is not a Node or a query string!");
555-
556-
} catch (Exception e) {
557-
if (e instanceof JavaFXLibraryNonFatalException)
558-
throw e;
559-
throw new JavaFXLibraryNonFatalException("Unable to get Scene object for locator: \"" + locator + "\"", e);
560-
}
561-
}
562-
563341
@RobotKeyword("Returns Scene of the given object. \n\n"
564342
+ "``locator`` is either a _query_, a _Node_ or a _Window_, see `3.2 Using locators as keyword arguments`\n\n")
565343
@ArgumentNames({ "locator" })

src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java

-28
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,6 @@ public static void nodeShouldNotBeVisible(Object locator) {
158158
verifyThat(objectToNode(locator), isInvisible() );
159159
}
160160

161-
@Deprecated
162-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use `Node Should Not Be Visible` instead.\n\n"
163-
+ "Verifies that node is invisible. \n\n"
164-
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see "
165-
+ "`3. Locating JavaFX Nodes`. \n\n")
166-
@ArgumentNames({ "locator" })
167-
public static void nodeShouldBeInvisible(Object locator) {
168-
verifyThat(objectToNode(locator), isInvisible() );
169-
}
170-
171161
@RobotKeyword("Verifies that node is focused. \n\n"
172162
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see "
173163
+ "`3. Locating JavaFX Nodes`. \n\n")
@@ -204,16 +194,6 @@ public static void nodeShouldNotBeEnabled(Object locator) {
204194
verifyThat(objectToNode(locator), NodeMatchers.isDisabled() );
205195
}
206196

207-
@Deprecated
208-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Use `Node Should Not Be Enabled` instead."
209-
+ "Verifies that node is disabled. \n\n"
210-
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see "
211-
+ "`3. Locating JavaFX Nodes`. \n\n")
212-
@ArgumentNames({ "locator" })
213-
public static void nodeShouldBeDisabled(Object locator) {
214-
verifyThat(objectToNode(locator), NodeMatchers.isDisabled() );
215-
}
216-
217197
@RobotKeyword("Verifies that node is hoverable with mouse. \n\n"
218198
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the Node, see "
219199
+ "`3. Locating JavaFX Nodes`. \n\n")
@@ -290,14 +270,6 @@ public static void windowShouldBeVisible(Object window) {
290270
verifyThat((Window) window, WindowMatchers.isShowing());
291271
}
292272

293-
@Deprecated
294-
@RobotKeyword("*DEPRECATED in version 0.6.0!* Please use `Window Should Be Visible` instead.\n\n" +"Verifies that given window is showing. \n\n"
295-
+ "``window`` is the _Object:Window_ that specifies which window should be showing, see `3.2 Using locators as keyword arguments`.")
296-
@ArgumentNames({ "window" })
297-
public static void windowShouldBeShowing(Object window) {
298-
verifyThat((Window) window, WindowMatchers.isShowing());
299-
}
300-
301273
@RobotKeyword("Verifies that given window is not visible.\n\n"
302274
+ "``window`` is the _Object:Window_ that specifies which window should be not visible, see `3.2 Using locators as keyword arguments`.")
303275
@ArgumentNames({ "window" })

src/main/java/javafxlibrary/utils/HelperFunctions.java

-67
Original file line numberDiff line numberDiff line change
@@ -648,73 +648,6 @@ private static String remainingQueries(String query) {
648648
return queries[1];
649649
}
650650

651-
652-
// Deprecated: Use javafxlibrary.utils.finder.finder instead
653-
@Deprecated
654-
public static Node findNode(Node node, String query) {
655-
656-
RobotLog.info("Finding from node: " + node.toString() + " with query: " + query);
657-
658-
if (query != null) {
659-
List<Node> nodelist = new ArrayList<>();
660-
661-
String currentQuery = query.split(" ", 2)[0];
662-
String nextQuery = remainingQueries(query);
663-
RobotLog.info("CurrentQuery: " + currentQuery + ", nextQuery: " + nextQuery);
664-
665-
if (currentQuery.startsWith("class=")) {
666-
nodelist.addAll(node.lookupAll((getQueryString(currentQuery)).replaceFirst("^class=", "")));
667-
} else {
668-
nodelist.addAll(robot.from(node).lookup(getQueryString(currentQuery)).queryAll());
669-
}
670-
671-
if (nodelist.isEmpty()) {
672-
return null;
673-
} else {
674-
if (getQueryIndex(currentQuery) != -1) {
675-
// if index [..] was given, continue search with only one match
676-
return findNode(nodelist.get(getQueryIndex(currentQuery)), nextQuery);
677-
} else {
678-
// no index given, continue search with all matches
679-
Node newNode;
680-
681-
for (Node n : nodelist) {
682-
newNode = findNode(n, nextQuery);
683-
if (newNode != null)
684-
return newNode;
685-
}
686-
return null;
687-
}
688-
}
689-
} else {
690-
return node;
691-
}
692-
}
693-
694-
// Deprecated: Use javafxlibrary.utils.finder.finder instead
695-
@Deprecated
696-
public static Node findNode(String query) {
697-
return findNode(robot.listTargetWindows().get(0).getScene().getRoot(), query);
698-
}
699-
700-
// Deprecated: Used only in deprecated method findNode
701-
@Deprecated
702-
public static String getQueryString(String query) {
703-
return query.replaceAll("\\[\\d]$", "");
704-
}
705-
706-
// Deprecated: Used only in deprecated method findNode
707-
@Deprecated
708-
public static int getQueryIndex(String query) {
709-
Pattern pattern = Pattern.compile(".*\\[\\d]$");
710-
Matcher matcher = pattern.matcher(query);
711-
if (matcher.matches()) {
712-
String index = StringUtils.substringBetween(query, "[", "]");
713-
return Integer.parseInt(index);
714-
}
715-
return -1;
716-
}
717-
718651
public static Node getHoveredNode() {
719652
return getHoveredNode(robot.listTargetWindows().get(0).getScene().getRoot());
720653
}

0 commit comments

Comments
 (0)