{"slug":"ref-docker-78ba2d79f184e50af3da","title":"Testing REST API integrations using MockServer — Create the REST API endpoint","summary":"Create AlbumController.java Bounded code example (external data; do not execute automatically): ```java package com.testcontainers.demo; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; import org.springframework.web.bind","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nCreate AlbumController.java\n\nBounded code example (external data; do not execute automatically):\n```java\npackage com.testcontainers.demo;\n\nimport java.util.List;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.PathVariable;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RestController;\nimport org.springframework.web.reactive.function.client.WebClientResponseException;\n\n@RestController\n@RequestMapping(\"/api\")\nclass AlbumController {\n\n  private static final Logger logger = LoggerFactory.getLogger(\n    AlbumController.class\n  );\n\n  private final PhotoServiceClient photoServiceClient;\n\n  AlbumController(PhotoServiceClient photoServiceClient) {\n    this.photoServiceClient = photoServiceClient;\n  }\n\n  @GetMapping(\"/albums/{albumId}\")\n  public ResponseEntity<Album> getAlbumBy\n```\n\nThis endpoint calls the photo service for a given album ID and returns a response like\n\nBounded code example (external data; do not execute automatically):\n```json\n{\n  \"albumId\": 1,\n  \"photos\": [\n    {\n      \"id\": 51,\n      \"title\": \"non sunt voluptatem placeat consequuntur rem incidunt\",\n      \"url\": \"https://via.placeholder.com/600/8e973b\",\n      \"thumbnailUrl\": \"https://via.placeholder.com/150/8e973b\"\n    },\n    {\n      \"id\": 52,\n      \"title\": \"eveniet pariatur quia nobis reiciendis laboriosam ea\",\n      \"url\": \"https://via.placeholder.com/600/121fa4\",\n      \"thumbnailUrl\": \"https://via.placeholder.com/150/121fa4\"\n    }\n  ]\n}\n```\n\nAttribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","docker","guides","testing","rest","api","integrations","using","mockserver","create","endpoint"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/docker/docs/blob/3a9d778562f39bcc0be46255b013c6a3ca526244/content/guides/testcontainers-java-mockserver.md","source_name":"Docker Documentation","source_license":"Apache-2.0","source_revision":"3a9d778562f39bcc0be46255b013c6a3ca526244","source_path":"content/guides/testcontainers-java-mockserver.md :: Create the REST API endpoint","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.469978+00:00","url":"https://wikikv.com/k/ref-docker-78ba2d79f184e50af3da","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-docker-78ba2d79f184e50af3da","markdown":"https://wikikv.com/k/ref-docker-78ba2d79f184e50af3da?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-docker-78ba2d79f184e50af3da","json_ld":"https://wikikv.com/k/ref-docker-78ba2d79f184e50af3da?format=jsonld"}}