Skip to content

feature/digital-twin-part #1477

Closed
ds-vlisenco wants to merge 32 commits intoeclipse-tractusx:mainfrom
ds-vlisenco:main
Closed

feature/digital-twin-part #1477
ds-vlisenco wants to merge 32 commits intoeclipse-tractusx:mainfrom
ds-vlisenco:main

Conversation

@ds-vlisenco
Copy link

Refactor Integration Test with DigitalTwinPartApiSupport

Summary

This Pull Request introduces a new support class DigitalTwinPartApiSupport to handle all REST interactions related to /digitalTwinPart endpoints.
It improves test maintainability, reduces duplication, and aligns with the established testing architecture (e.g., AssetsApiSupport).

Goal

  • Extract REST call logic from DigitalTwinPartsControllerIT
  • Encapsulate interactions in a reusable DigitalTwinPartApiSupport class
  • Support flexible validation of status codes and response body extraction
  • Improve test readability and structure

What's Included

Added

  • DigitalTwinPartApiSupport.java under integration/common/support
    • Endpoints covered:
      • POST /api/administration/digitalTwinPart
      • POST /api/administration/digitalTwinPart/detail
      • POST /api/administration/digitalTwinPart/searchable-values
    • Features:
      • JWT-based authorization using JwtRole.ADMIN
      • expectedStatusCode parameter for validation
      • Generic response deserialization with TypeRef<T> / Class<T>
      • Internal exception handling for JoseException

Refactored

  • All test methods in DigitalTwinPartsControllerIT now use DigitalTwinPartApiSupport
  • Direct RestAssured calls removed from the test class

New Test Added

  • shouldReturnSearchableValuesForFieldName()
    • Verifies functionality of /searchable-values endpoint
    • Fully based on the refactored structure

Design Notes

  • Pattern and structure inspired by AssetsApiSupport
  • Used @Component and @RequiredArgsConstructor for clean DI
  • Logs retained for request/response debugging (.log().all())
  • Exception-safety provided by wrapping JoseException in RuntimeException

Acceptance Criteria Met

  • Support class exists in correct package
  • All /digitalTwinPart* calls extracted to support class
  • Methods validate status code and return full response
  • All tests pass and logic remains intact
  • One new test using support class added
  • Code reviewed and follows existing architectural standards

Related Issue

Closes #3 – Refactor Integration Test with DigitalTwinPartApiSupport

Added input validation to PolicyServiceImpl#getPolicy to throw IllegalArgumentException
when policy ID is null or blank. This ensures consistent error handling and aligns with
unit test expectations.

Also resolves failing test cases in PolicyServiceImplTest that check for invalid inputs.
Added input validation to PolicyServiceImpl#getPolicy to throw IllegalArgumentException
when policy ID is null or blank. This ensures consistent error handling and aligns with
unit test expectations.

Also resolves failing test cases in PolicyServiceImplTest that check for invalid inputs.
fix: add null checks to PolicyServiceImpl to handle invalid input
Introduced @nested classes to logically group tests by method
Added helper method createPolicyResponse to reduce duplication and simplify test setup
Fixed usage of PolicyResponse.policyId() to match record syntax (instead of incorrect getPolicyId())
Corrected construction of Payload and IrsPolicyResponse based on their actual constructors
Improved test assertions to verify actual field values instead of only presence or size
Preserved existing test coverage for all main methods
license header is provided
feature/policy-unit-test
license header is provided
…neration

feature/automate-test-data-generation
…neration

feature/automate-test-data-generation
…ation' into feature/automate-test-data-generation
…neration

feature/automate-test-data-generation
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