-
Notifications
You must be signed in to change notification settings - Fork 217
Switch Operator Processors #3640
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
Switch Operator Processors #3640
Conversation
…es pipelines. - define "Switch" input. e.g. switch(event.switch_input) - define "cases" which output string types - define "default" case which evaluates if all other cases fail - creates "switch-filter-result" output - add SwitchOperatorProcessor to TransformationExtensionModuleExport
- added documentation.md based on generated template - added strings.en resources - added new icon of switch to indicate function of processor chore: Rename the processor to use the correct format of org.apache.org...
- Need to fix test issues of Mockito not being able to mock
- Update to return primitive data types based on user selection - Updated tests to cover functionality
…utput type options and examples
…enhanced output type handling
…r for enhanced switch functionality
…aces for improved clarity
|
Thanks a lot for the PR — these are great new processing elements, and your description makes it easy to review.
Would you like to add some unit tests for your elements? Hope this helps! |
…nput processors for improved structure and maintainability - Refactored to use AbstractSwitchOperatorProcessor to pull out common methods - Overall Renaming of methods and names for better consistency and descriptions of functionality - moved general implementation of onEvent() to AbstractSwitchOperatorProcessor which utilizes findMatchingResult which is then given class specific implementations
… add unit tests for boolean, numerical, and string input processors
… Operator with updated documentation and license headers - Updated documentation.md and strings.en to reflect the changes made in optimization refactor - Unit tests added to cover general functionality and edge cases - Utilized ProcessingElementTestExecutor for the unit tests - Added Licenses to top of Test files and new optimized classes
…iew and usage instructions
Hey @tenthe! Thank you for the testing recommendation, that was super useful and made writing the tests much simpler. Props to whoever wrote that suite! I have gone ahead and added unit tests for the processors and made quite a few updates that they helped me catch. From my testing it should be good to go at this point. |
tenthe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the changes.
I just had a minor comment, but I think the code looks good from my side.
I look forward to use the processors.
Cheers,
Philipp
| * @param staticPropertyExtractor Extractor for the current switch case group. | ||
| * @return A SwitchCaseEntry object. | ||
| */ | ||
| protected SwitchCaseEntry parseSwitchCaseEntry(StaticPropertyExtractor staticPropertyExtractor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be an abstract method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Switching it to abstract is causing the classes that extend it to refuse to implement the class.
But I am still refreshing my understanding of Java so I will default to your decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your response. This was just a small point I noticed while reviewing the code. I'll trigger the GitHub Action validation now. Once it passes, we can proceed with merging your PR.
76bdb8b to
31d5086
Compare
Purpose
Introduce Pipeline Element Processors that allow a user to implement the "Switch" operator. I have often found myself wanting to setup a pipeline that uses the "Switch" operator but have had to use a complicated set of boolean conditions to try and implement it or I eventually end up just using a JavaScript processor to use the switch statement. The processors reflect the following block.
The proposed updates introduce three processors, each which have the purpose of handling a different input type. I have implemented a Boolean Input processor, String input processor, and Numerical input processor. This is done primarily for the sake of cleaner code along with simplifying the detection of the incoming event property. These three processors could be combined into one "Switch Operator Processor" if there was the introduction of some "Conditional Requirements" component.
Remarks
I have written unit tests for the numerical processor locally but ran into issues when I transferred the updates from my custom extensions repo to the main streampipes codebase. If someone has input on the right way to write tests for streampipes or would like to write the unit tests themselves that would be welcome.
PR introduces (a) breaking change(s): no
PR introduces (a) deprecation(s): no