Skip to content

[Refactor] Refactor document result validation structure#22

Merged
BGMSound merged 5 commits intomainfrom
develop
May 14, 2025
Merged

[Refactor] Refactor document result validation structure#22
BGMSound merged 5 commits intomainfrom
develop

Conversation

@BGMSound
Copy link
Owner

@BGMSound BGMSound requested a review from Copilot May 14, 2025 06:42
@BGMSound BGMSound changed the title [Refactor] Refactor result validation structure [Refactor] Refactor document result validation structure May 14, 2025
Copy link

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 refactors the result validation structure to unify common validation logic for DocumentResult into the abstract layer and updates package structures accordingly.

  • Introduces new validation methods (expect and expectValue) in the Reactive and Mvc document result implementations.
  • Renames JsonResultMatcher to ExpectedJsonValue and updates related aggregation logic.
  • Moves controllers and test classes to a dedicated "controller" package to better organize the code.

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

File Description
documentify-sample/reactive-sample/src/main/kotlin/io/github/bgmsound/documentify/sample/reactive/controller/SampleController.kt Updated package declaration and refined REST controller method.
Several test files under documentify-sample/mvc-sample/src/test/kotlin/io/github/bgmsound/documentify/sample/mvc/documentation/ Updated import paths to reflect new controller package structure.
documentify-project/documentify-reactive and documentify-project/documentify-mvc emitter classes Refactored validation methods from validateJsonPath to expect and expectValue.
documentify-project/documentify-core/emitter and specification classes Renamed JsonResultMatcher to ExpectedJsonValue and updated API calls accordingly.
Comments suppressed due to low confidence (1)

documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/specification/schema/ResourceSpec.kt:32

  • [nitpick] If the companion accessor allows it, consider using 'Link.newLink(rel)' directly for improved readability.
val link = Link.Companion.newLink(rel)

val value = matcher.expectedValue
if (jsonPath.endsWith("[*]")) {
if (value !is List<*>) {
throw IllegalArgumentException("sample value type must be List")
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

Consider enhancing the error message to include the actual type of the received value for easier debugging of type mismatches.

Suggested change
throw IllegalArgumentException("sample value type must be List")
throw IllegalArgumentException("sample value type must be List, but was ${value::class.simpleName}")

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Test Results

17 tests   17 ✅  13s ⏱️
 9 suites   0 💤
 9 files     0 ❌

Results for commit 2302476.

@github-actions
Copy link

Code Coverage Report

Overall Project 37.59% -2.69% 🍏
Files changed 31.41% 🍏

Module Coverage
Kover Gradle Plugin XML report for :documentify-sample:reactive-sample 100% 🍏
Kover Gradle Plugin XML report for :documentify-sample:mvc-sample 85.15% 🍏
Kover Gradle Plugin XML report for : 71.31% -1.5% 🍏
Kover Gradle Plugin XML report for :documentify-project:documentify-core 0.53% -4.96%
Kover Gradle Plugin XML report for :documentify-project:documentify-mvc 0.49% -3.18%
Kover Gradle Plugin XML report for :documentify-project:documentify-reactive 0.46% -1.71%
Files
Module File Coverage
Kover Gradle Plugin XML report for :documentify-sample:reactive-sample SampleController.kt 100% 🍏
Kover Gradle Plugin XML report for :documentify-sample:mvc-sample ComplexSampleController.kt 100% 🍏
SampleController.kt 100% 🍏
NestedSampleController.kt 100% 🍏
UnnestedSampleController.kt 100% 🍏
UseCaseBindingController.kt 53.33% 🍏
ErrorController.kt 28.13% 🍏
Kover Gradle Plugin XML report for : MvcDocumentResult.kt 100% 🍏
ExpectedJsonValue.kt 100% 🍏
AbstractDocumentResult.kt 80.85% -16.49% 🍏
DocumentSpec.kt 73.21% 🍏
ReactiveDocumentResult.kt 73.08% -26.92% 🍏
ResourceSpec.kt 70.34% -7.42% 🍏
Kover Gradle Plugin XML report for :documentify-project:documentify-core AbstractDocumentResult.kt 0% -46.28%
ExpectedJsonValue.kt 0% -41.18%
DocumentSpec.kt 0% 🍏
ResourceSpec.kt 0% -12.58%
Kover Gradle Plugin XML report for :documentify-project:documentify-mvc MvcDocumentResult.kt 0% -70.27%
Kover Gradle Plugin XML report for :documentify-project:documentify-reactive ReactiveDocumentResult.kt 0% -57.69%

@BGMSound BGMSound merged commit 9675961 into main May 14, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant