Skip to content

Conversation

Nadahar
Copy link
Contributor

@Nadahar Nadahar commented Jul 17, 2025

This is another split out from #4633. It should be safe to merge, it only provides tests for the existing classes RuleGSONParser and TemplateGSONParser, a small log tweak and changes HashSet to LinkedHashSet in the two tested classes to make iteration order predictable, which makes testing easier.

@Nadahar Nadahar requested a review from a team as a code owner July 17, 2025 14:09
@Nadahar Nadahar changed the title Add tests for rules and rule templates JSON parser Add tests for rules and rule templates JSON parsers Jul 17, 2025
@Nadahar Nadahar mentioned this pull request Jul 22, 2025
@holgerfriedrich holgerfriedrich requested a review from Copilot August 9, 2025 18:00
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive test coverage for the JSON parser classes RuleGSONParser and TemplateGSONParser in the openHAB automation module. It introduces test resource files and corresponding test classes to verify JSON parsing functionality.

  • Adds test resource files containing various rule and template JSON configurations for testing
  • Creates comprehensive test classes to validate JSON parsing behavior with different scenarios
  • Makes minor improvements to logging and collection ordering for better testability

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
FullRule.json Test resource file containing a comprehensive rule configuration with all possible fields
BasicRules.json Test resource file with simple rule configurations in array format
MultipleRuleTemplates.json Test resource file containing multiple rule templates with duplicate entries
FullRuleTemplate.json Test resource file with a complete rule template configuration
BasicRuleTemplate.json Test resource file with a minimal rule template configuration
TemplateGSONParserTest.java Test class for validating template JSON parsing functionality
RuleGSONParserTest.java Test class for validating rule JSON parsing functionality
AbstractFileProvider.java Updated logging messages for better clarity and debugging
TemplateGSONParser.java Changed HashSet to LinkedHashSet for predictable iteration order
RuleGSONParser.java Changed HashSet to LinkedHashSet for predictable iteration order

@Nadahar
Copy link
Contributor Author

Nadahar commented Sep 16, 2025

@holgerfriedrich This has been dormant for a while, while I expected it to be very uncontroversial. All it really does is add tests for some code that I have provided earlier, and some code that has been here for years.

I can rebase it on latest main if that is desirable/helpful, just let me know.

Copy link
Member

@holgerfriedrich holgerfriedrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@holgerfriedrich holgerfriedrich merged commit 9aa5972 into openhab:main Oct 8, 2025
4 checks passed
@Nadahar Nadahar deleted the rule-template-JSON-tests branch October 8, 2025 17:04
@holgerfriedrich holgerfriedrich added the enhancement An enhancement or new feature of the Core label Oct 8, 2025
@holgerfriedrich holgerfriedrich added this to the 5.1 milestone Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants