Skip to content

Conversation

@Aias00
Copy link
Contributor

@Aias00 Aias00 commented Dec 4, 2025

What's changed?

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

Copilot AI review requested due to automatic review settings December 4, 2025 08:52
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has checked 3565 files.

Valid Invalid Ignored Fixed
1837 10 1718 0
Click to see the invalid file list
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/ParamValidatorManagerTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/BooleanParamValidatorTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/HostParamValidatorAdapterTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/HostParamValidatorTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/JsonParamValidatorTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/NumberParamValidatorTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/OptionParamValidatorTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/PasswordParamValidatorTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/component/validator/impl/TextParamValidatorTest.java
  • hertzbeat-manager/src/test/java/org/apache/hertzbeat/manager/service/helper/MonitorImExportHelperTest.java
Use this command to fix any missing license headers
```bash

docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix

</details>

Aias00 and others added 5 commits December 4, 2025 16:58
…omponent/validator/ParamValidatorManagerTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/BooleanParamValidatorTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/HostParamValidatorAdapterTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/HostParamValidatorTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/JsonParamValidatorTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
Copy link
Contributor

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 pull request refactors the parameter validation logic in HertzBeat by introducing a validator pattern with dedicated parameter validator classes and comprehensive test coverage.

Key Changes:

  • Extracts inline validation logic from MonitorServiceImpl into dedicated validator classes using the Strategy pattern
  • Creates a ParamValidatorManager to coordinate validation across different parameter types
  • Extracts monitor import/export logic into a separate MonitorImExportHelper class for better separation of concerns

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
ParamValidator.java Defines the validator interface for parameter validation
ParamValidatorManager.java Manages and delegates validation to appropriate validators
TextParamValidator.java Validates text and textarea parameter types with length limits
PasswordParamValidator.java Handles password encryption and validation
OptionParamValidator.java Validates radio and checkbox options against defined choices
NumberParamValidator.java Validates numeric parameters and range constraints
JsonParamValidator.java Validates JSON format for metrics-field and key-value types
HostParamValidatorAdapter.java Delegates host validation to existing common validator
BooleanParamValidator.java Validates boolean parameter values
ArrayParamValidator.java Validates array parameters and strips brackets
MonitorImExportHelper.java Extracts import/export logic from MonitorServiceImpl for better modularity
MonitorServiceImpl.java Refactored to use ParamValidatorManager and MonitorImExportHelper, removing 100+ lines of inline validation code
MonitorServiceTest.java Updated to mock ParamValidatorManager and MonitorImExportHelper
MonitorImExportHelperTest.java Tests for the new import/export helper class
*ParamValidatorTest.java (multiple) Comprehensive unit tests for each validator implementation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 14 to 18
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

This test references a HostParamValidator class that does not exist in the main source code. The only host validator implementation is HostParamValidatorAdapter. Either create the HostParamValidator class or update this test to use HostParamValidatorAdapter instead.

Copilot uses AI. Check for mistakes.
Aias00 and others added 14 commits December 4, 2025 16:58
…omponent/validator/impl/NumberParamValidatorTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/OptionParamValidatorTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/PasswordParamValidatorTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…ervice/helper/MonitorImExportHelperTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/HostParamValidatorTest.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/ArrayParamValidatorTest.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/TextParamValidatorTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/BooleanParamValidator.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…ervice/impl/MonitorServiceImpl.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/ArrayParamValidator.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/ParamValidatorManager.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
…omponent/validator/impl/ArrayParamValidator.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: aias00 <liuhongyu@apache.org>
@tomsun28 tomsun28 added this to the 1.8.0 milestone Dec 4, 2025
@tomsun28 tomsun28 merged commit 7727d63 into master Dec 6, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants