SED-4497 referencing-a-keyword-from-an-ap-library-doesnt-work#611
SED-4497 referencing-a-keyword-from-an-ap-library-doesnt-work#611david-stephan wants to merge 6 commits intomasterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where keywords defined within an Automation Package (AP) library were not being correctly referenced, leading to functional failures. The changes introduce a robust mechanism to identify the origin of keywords (whether from the main AP or an associated library) during the scanning process. This allows for the correct assignment of the library JAR as the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where keywords from an automation package library were not working correctly. The fix involves a two-step process: first, identifying and marking keywords that originate from a library JAR during package reading, and second, using this marker to correctly set the script and library files for the keyword.
My review focuses on the implementation of this logic. The changes are well-structured and include corresponding test updates. I've suggested a minor refactoring in GeneralScriptFunction to improve code readability and reduce redundancy. Overall, the changes look good and effectively solve the described problem.
| if (getCustomField($_MARK_AS_KEYWORD_FROM_AUTOMATION_PACKAGE_LIBRARY) != null) { | ||
| getCustomFields().remove($_MARK_AS_KEYWORD_FROM_AUTOMATION_PACKAGE_LIBRARY); | ||
| if (ap.getAutomationPackageLibraryResourceRevision() != null && !ap.getAutomationPackageLibraryResourceRevision().isEmpty()) { | ||
| setScriptFile(new DynamicValue<>(ap.getAutomationPackageLibraryResourceRevision())); | ||
| } else { | ||
| throw new RuntimeException("Inconsistent state: the annotated Keyword '" + this.getAttribute(NAME) + "' was detected in an Automation Package Library, but the library resource does not exists."); | ||
| } | ||
| } else { | ||
| //Keyword annotated in main AP file | ||
| if (ap.getAutomationPackageResourceRevision() != null && !ap.getAutomationPackageResourceRevision().isEmpty()) { | ||
| setScriptFile(new DynamicValue<>(ap.getAutomationPackageResourceRevision())); | ||
| } else { | ||
| throw new RuntimeException("Inconsistent state: the annotated Keyword '" + this.getAttribute(NAME) + "' was detected in an Automation Package, but the package resource does not exists."); | ||
| } | ||
| if (ap.getAutomationPackageLibraryResourceRevision() != null && !ap.getAutomationPackageLibraryResourceRevision().isEmpty()) { | ||
| setLibrariesFile(new DynamicValue<>(ap.getAutomationPackageLibraryResourceRevision())); | ||
| } | ||
| } |
There was a problem hiding this comment.
This block of logic can be made more readable and less repetitive by extracting the resource revision strings and their non-empty checks into local variables. This would also be a good opportunity to correct a minor grammatical error in the exception messages (exists should be exist).
final String libraryRevision = ap.getAutomationPackageLibraryResourceRevision();
final boolean hasLibrary = libraryRevision != null && !libraryRevision.isEmpty();
if (getCustomField($_MARK_AS_KEYWORD_FROM_AUTOMATION_PACKAGE_LIBRARY) != null) {
getCustomFields().remove($_MARK_AS_KEYWORD_FROM_AUTOMATION_PACKAGE_LIBRARY);
if (hasLibrary) {
setScriptFile(new DynamicValue<>(libraryRevision));
} else {
throw new RuntimeException("Inconsistent state: the annotated Keyword '" + getAttribute(NAME) + "' was detected in an Automation Package Library, but the library resource does not exist.");
}
} else {
//Keyword annotated in main AP file
final String packageRevision = ap.getAutomationPackageResourceRevision();
if (packageRevision != null && !packageRevision.isEmpty()) {
setScriptFile(new DynamicValue<>(packageRevision));
} else {
throw new RuntimeException("Inconsistent state: the annotated Keyword '" + getAttribute(NAME) + "' was detected in an Automation Package, but the package resource does not exist.");
}
if (hasLibrary) {
setLibrariesFile(new DynamicValue<>(libraryRevision));
}
}There was a problem hiding this comment.
Code refactored
No description provided.