Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exceptions to do with init and intro keywords #71

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>11.0.3</version>
<version>11.0.19</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Expand Up @@ -52,8 +52,10 @@ public ServerMethods(RemoteServerServlet servlet) {
public List<String> get_keyword_names() {
try {
List<String> names = servlet.getLibrary().getKeywordNames();
if (names == null || names.size() == 0)
if (names == null || names.isEmpty())
throw new RuntimeException("No keywords found in the test library");
if (!names.contains("__intro__")) names.add("__intro__");
if (!names.contains("__init__")) names.add("__init__");
if (!names.contains("stop_remote_server")) names.add("stop_remote_server");
return names;
} catch (Throwable e) {
Expand Down Expand Up @@ -157,12 +159,12 @@ public Map<String, Object> run_keyword(String keyword, List<String> args) {
* @return A string array of argument specifications for the given keyword.
*/
public List<String> get_keyword_arguments(String keyword) {
if (keyword.equalsIgnoreCase("stop_remote_server")) {
return Arrays.asList();
}
if (keyword.equalsIgnoreCase("stop_remote_server")) return Collections.emptyList();
if (keyword.equalsIgnoreCase("__intro__")) return Collections.emptyList();
if (keyword.equalsIgnoreCase("__init__")) return Collections.emptyList();
try {
List<String> args = servlet.getLibrary().getKeywordArguments(keyword);
return args == null ? Arrays.<String>asList() : args;
return args == null ? Collections.emptyList() : args;
} catch (Throwable e) {
log.warn("", e);
throw new RuntimeException(e);
Expand All @@ -177,6 +179,9 @@ public List<String> get_keyword_arguments(String keyword) {
* @return A documentation string for the given keyword.
*/
public String get_keyword_documentation(String keyword) {
if (keyword.equalsIgnoreCase("__init__")) {
return "";
}
if (keyword.equalsIgnoreCase("stop_remote_server")) {
return "Stops the remote server.\n\nThe server may be configured so that users cannot stop it.";
}
Expand Down