Skip to content

Migrate repository tests from TestRestTemplate to RestTestClient - #399

Merged
rashidi merged 3 commits into
masterfrom
copilot/replace-testresttemplate-with-resttestclient
Sep 10, 2026
Merged

rashidi merged 3 commits into
masterfrom
copilot/replace-testresttemplate-with-resttestclient

Conversation

Copilot AI commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

This updates the remaining REST integration tests and matching README snippets to use RestTestClient, replacing deprecated TestRestTemplate usage across the repository. It also ensures each affected module declares the required spring-boot-resttestclient test dependency.

  • Scope

    • Migrates the remaining TestRestTemplate / @AutoConfigureTestRestTemplate usages in:
      • data-mongodb-transactional
      • data-domain-events
      • data-rest-validation
      • cloud-jdbc-env-repo
      • test-slice-tests-rest
  • Test client migration

    • Replaces injected TestRestTemplate fields with RestTestClient
    • Swaps @AutoConfigureTestRestTemplate for @AutoConfigureRestTestClient
    • Rewrites request flows to the fluent RestTestClient API while keeping existing assertions and scenarios intact:
      • POST requests now use post().uri(...).contentType(...).body(...).exchange()
      • GET requests now use get().uri(...).exchange()
      • DELETE requests now use delete().uri(...).exchange()
      • basic auth now uses request headers via headers(h -> h.setBasicAuth(...))
  • Module dependency updates

    • Adds org.springframework.boot:spring-boot-resttestclient to the affected module that did not yet declare it:
      • test-slice-tests-rest/build.gradle.kts
  • Documentation alignment

    • Updates the Java snippets in the affected README.adoc files so the documented examples match the migrated test code

Example migration pattern:

restClient.get().uri("/users/{username}", "rashidi.zin")
        .headers(headers -> headers.setBasicAuth("rashidi.zin", "jU$7d3m0pL3a$eRe|ax"))
        .exchange()
        .expectStatus().isOk()
        .expectBody(UserWithoutId.class)
        .returnResult()
        .getResponseBody();

Co-authored-by: rashidi <380073+rashidi@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace all usages of TestRestTemplate with RestTestClient Migrate repository tests from TestRestTemplate to RestTestClient Sep 10, 2026
Copilot AI requested a review from rashidi September 10, 2026 02:00
@rashidi
rashidi marked this pull request as ready for review September 10, 2026 02:05
@rashidi
rashidi merged commit a9847d3 into master Sep 10, 2026
4 checks passed
@rashidi
rashidi deleted the copilot/replace-testresttemplate-with-resttestclient branch September 10, 2026 03:13
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.

2 participants