MockServer Module
RECORDO
During the first test run or in the absence of a file, all real interactions are recorded into a file.
Once the file is saved, it is automatically utilized for mocking purposes.
Setup
HTTP Interceptor
Recordo adds an interceptor to your HTTP client to capture and replay HTTP requests and responses.
At present, three HTTP clients are supported:
Spring RestTemplate
OkHttp Client
Apache HTTP Client
Recordo searches for an HTTP client in the application context. If you are not using the Spring Framework or if you don't have an HTTP client or have multiple ones, you can specify which HTTP client to use by explicitly adding the @EnableRecordo
annotation.
If you need to use multiple MockServers for different HTTP clients, you can specify the HTTP client bean or the name of the test class field in the `httpClient` annotation parameter.
@Autowired
@EnableRecordo
private RestTemplate restTemplate;
@Autowired
@EnableRecordo
private OkHttpClient okHttpClient;
@Autowired
@EnableRecordo
private HttpClient httpClient;
OpenFeign Client definition example
You can use an HTTP client that has been intercepted underneath OpenFeign or other high-level clients.
@Bean
public okhttp3.OkHttpClient okHttpClient() {
return new okhttp3.OkHttpClient();
}
@Bean
public feign.Client feignClient(OkHttpClient okHttpClient) {
return new feign.okhttp.OkHttpClient(okHttpClient);
}
@Bean
public HttpClient apacheHttpClient() {
return HttpClients.createDefault();
}
@Bean
public feign.Client feignClient(HttpClient apacheHttpClient) {
return new feign.httpclient.ApacheHttpClient(httpClient);
}
Annotation Parameters
The @MockServer
annotation has 4 parameters:
value
String
The value
property in the MockServer annotation can specify both file and folder paths:
File Path (
.json
): Records and replays multiple requests in a single file.Folder Path (No
.json
): Creates individual JSON files for each request in the folder.
urlPattern
String
The mapping matches URLs using the following rules:
?
matches one character
*
matches zero or more characters
**
matches zero or more directories in a path
httpClient
String
Name of RestTemplate, OkHttp, or Apache HTTP Client bean or test class field
objectMapper
String
Name of ObjectMapper bean or test class field
Examples
Single Server
@Test
@MockServer("/mock_servers/get_gists.json")
void should_retrieve_gists() {
...
List<GistResponse> gists = gitHubClient.getGists();
...
}
[
{
"request": {
"method": "GET",
"url": "https://api.github.com/gists",
"headers": {
"authorization": "********",
"accept": "application/json, application/*+json"
},
"body": null
},
"response": {
"protocol": "HTTP/1.1",
"statusCode": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json; charset=utf-8"
},
"body": [
{
"url": "https://api.github.com/gists/77c974bae1167df5c880f4849b7e001c",
"forks_url": "https://api.github.com/gists/77c974bae1167df5c880f4849b7e001c/forks",
"commits_url": "https://api.github.com/gists/77c974bae1167df5c880f4849b7e001c/commits",
"id": "77c974bae1167df5c880f4849b7e001c",
"node_id": "MDQ6R2lzdDc3Yzk3NGJhZTExNjdkZjVjODgwZjQ4NDliN2UwMDFj",
"git_pull_url": "https://gist.github.com/77c974bae1167df5c880f4849b7e001c.git",
"git_push_url": "https://gist.github.com/77c974bae1167df5c880f4849b7e001c.git",
"html_url": "https://gist.github.com/77c974bae1167df5c880f4849b7e001c",
"files": {
"hello_world.txt": {
"filename": "hello_world.txt",
"type": "text/plain",
"language": "Text",
"raw_url": "https://gist.githubusercontent.com/vadimdeineka/77c974bae1167df5c880f4849b7e001c/raw/d66c8d4d32962340839b015b7849e067d0f79479/hello_world.txt",
"size": 14
}
},
"public": false,
"created_at": "2020-06-26T14:19:30Z",
"updated_at": "2020-06-26T14:19:32Z",
"description": "Hello World!",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/77c974bae1167df5c880f4849b7e001c/comments",
"owner": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars3.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"truncated": false
}
]
}
}
]
@Test
@MockServer("/mock_servers/create_and_delete_gist.json") // File Path
void should_create_and_delete_gist() {
...
GistResponse response = gitHubClient.createGist(gist);
Gist created = gitHubClient.getGist(response.getId());
gitHubClient.deleteGist(response.getId());
...
}
[
{
"request": {
"method": "POST",
"url": "https://api.github.com/gists",
"headers": {
"authorization": "********",
"content-type": "application/json",
"accept": "application/json, application/*+json"
},
"body": {
"description": "Hello World!",
"files": {
"hello_world.txt": {
"content": "Hello \nWorld\n!"
}
}
}
},
"response": {
"protocol": "HTTP/1.1",
"statusCode": 201,
"statusText": "Created",
"headers": {
"content-type": "application/json; charset=utf-8",
"location": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca"
},
"body": {
"url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca",
"forks_url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca/forks",
"commits_url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca/commits",
"id": "4c16188cd8b6bc2de6ea2eec953ed7ca",
"node_id": "MDQ6R2lzdDRjMTYxODhjZDhiNmJjMmRlNmVhMmVlYzk1M2VkN2Nh",
"git_pull_url": "https://gist.github.com/4c16188cd8b6bc2de6ea2eec953ed7ca.git",
"git_push_url": "https://gist.github.com/4c16188cd8b6bc2de6ea2eec953ed7ca.git",
"html_url": "https://gist.github.com/4c16188cd8b6bc2de6ea2eec953ed7ca",
"files": {
"hello_world.txt": {
"filename": "hello_world.txt",
"type": "text/plain",
"language": "Text",
"raw_url": "https://gist.githubusercontent.com/vadimdeineka/4c16188cd8b6bc2de6ea2eec953ed7ca/raw/d66c8d4d32962340839b015b7849e067d0f79479/hello_world.txt",
"size": 14,
"truncated": false,
"content": "Hello \nWorld\n!"
}
},
"public": false,
"created_at": "2020-07-06T08:34:56Z",
"updated_at": "2020-07-06T08:34:56Z",
"description": "Hello World!",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca/comments",
"owner": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars3.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"forks": [],
"history": [],
"truncated": false
}
}
},
{
"request": {
"method": "GET",
"url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca",
"headers": {
"authorization": "********",
"accept": "application/json, application/*+json"
},
"body": null
},
"response": {
"protocol": "HTTP/1.1",
"statusCode": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json; charset=utf-8"
},
"body": {
"url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca",
"forks_url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca/forks",
"commits_url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca/commits",
"id": "4c16188cd8b6bc2de6ea2eec953ed7ca",
"node_id": "MDQ6R2lzdDRjMTYxODhjZDhiNmJjMmRlNmVhMmVlYzk1M2VkN2Nh",
"git_pull_url": "https://gist.github.com/4c16188cd8b6bc2de6ea2eec953ed7ca.git",
"git_push_url": "https://gist.github.com/4c16188cd8b6bc2de6ea2eec953ed7ca.git",
"html_url": "https://gist.github.com/4c16188cd8b6bc2de6ea2eec953ed7ca",
"files": {
"hello_world.txt": {
"filename": "hello_world.txt",
"type": "text/plain",
"language": "Text",
"raw_url": "https://gist.githubusercontent.com/vadimdeineka/4c16188cd8b6bc2de6ea2eec953ed7ca/raw/d66c8d4d32962340839b015b7849e067d0f79479/hello_world.txt",
"size": 14,
"truncated": false,
"content": "Hello \nWorld\n!"
}
},
"public": false,
"created_at": "2020-07-06T08:34:56Z",
"updated_at": "2020-07-06T08:34:56Z",
"description": "Hello World!",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca/comments",
"owner": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars3.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"forks": [],
"history": [],
"truncated": false
}
}
},
{
"request": {
"method": "DELETE",
"url": "https://api.github.com/gists/4c16188cd8b6bc2de6ea2eec953ed7ca",
"headers": {
"authorization": "********",
"accept": "application/json, application/*+json"
},
"body": null
},
"response": {
"protocol": "HTTP/1.1",
"statusCode": 204,
"statusText": "No Content",
"headers": {},
"body": null
}
}
]
@Test
@MockServer("/mock_servers/gists/") // Folder Path
void should_create_and_delete_gist() {
...
GistResponse response = gitHubClient.createGist(gist);
Gist created = gitHubClient.getGist(response.getId());
gitHubClient.deleteGist(response.getId());
...
}
{
"request": {
"method": "POST",
"url": "https://api.github.com/gists",
"headers": {
"authorization": "********",
"accept": "*/*"
},
"body": {
"description": "Hello World!",
"files": {
"hello_world.txt": {
"content": "Hello \nWorld\n!"
}
}
}
},
"response": {
"protocol": "h2",
"statusCode": 201,
"headers": {
"content-type": "application/json; charset=utf-8",
"location": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622"
},
"body": {
"url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622",
"forks_url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/forks",
"commits_url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/commits",
"id": "31e4458e2fbb1e073787790766268622",
"node_id": "G_kwDOAJSfK9oAIDMxZTQ0NThlMmZiYjFlMDczNzg3NzkwNzY2MjY4NjIy",
"git_pull_url": "https://gist.github.com/31e4458e2fbb1e073787790766268622.git",
"git_push_url": "https://gist.github.com/31e4458e2fbb1e073787790766268622.git",
"html_url": "https://gist.github.com/vadimdeineka/31e4458e2fbb1e073787790766268622",
"files": {
"hello_world.txt": {
"filename": "hello_world.txt",
"type": "text/plain",
"language": "Text",
"raw_url": "https://gist.githubusercontent.com/vadimdeineka/31e4458e2fbb1e073787790766268622/raw/d66c8d4d32962340839b015b7849e067d0f79479/hello_world.txt",
"size": 14,
"truncated": false,
"content": "Hello \nWorld\n!"
}
},
"public": false,
"created_at": "2024-03-22T10:32:21Z",
"updated_at": "2024-03-22T10:32:22Z",
"description": "Hello World!",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/comments",
"owner": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"forks": [],
"history": [
{
"user": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"version": "8763d463517eef559e7fd7daf653ffc5c1e7245f",
"committed_at": "2024-03-22T10:32:21Z",
"change_status": {
"total": 3,
"additions": 3,
"deletions": 0
},
"url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/8763d463517eef559e7fd7daf653ffc5c1e7245f"
}
],
"truncated": false
}
}
}
{
"request": {
"method": "GET",
"url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622?rand=hello%20world",
"headers": {
"authorization": "********",
"accept": "*/*"
}
},
"response": {
"protocol": "h2",
"statusCode": 200,
"headers": {
"content-type": "application/json; charset=utf-8"
},
"body": {
"url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622",
"forks_url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/forks",
"commits_url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/commits",
"id": "31e4458e2fbb1e073787790766268622",
"node_id": "G_kwDOAJSfK9oAIDMxZTQ0NThlMmZiYjFlMDczNzg3NzkwNzY2MjY4NjIy",
"git_pull_url": "https://gist.github.com/31e4458e2fbb1e073787790766268622.git",
"git_push_url": "https://gist.github.com/31e4458e2fbb1e073787790766268622.git",
"html_url": "https://gist.github.com/vadimdeineka/31e4458e2fbb1e073787790766268622",
"files": {
"hello_world.txt": {
"filename": "hello_world.txt",
"type": "text/plain",
"language": "Text",
"raw_url": "https://gist.githubusercontent.com/vadimdeineka/31e4458e2fbb1e073787790766268622/raw/d66c8d4d32962340839b015b7849e067d0f79479/hello_world.txt",
"size": 14,
"truncated": false,
"content": "Hello \nWorld\n!"
}
},
"public": false,
"created_at": "2024-03-22T10:32:21Z",
"updated_at": "2024-03-22T10:32:22Z",
"description": "Hello World!",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/comments",
"owner": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"forks": [],
"history": [
{
"user": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"version": "3e02b0d2032e3972744b9393c0287b41dcda6959",
"committed_at": "2024-03-22T10:32:22Z",
"change_status": {
"total": 0,
"additions": 0,
"deletions": 0
},
"url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/3e02b0d2032e3972744b9393c0287b41dcda6959"
},
{
"user": {
"login": "vadimdeineka",
"id": 9740075,
"node_id": "MDQ6VXNlcjk3NDAwNzU=",
"avatar_url": "https://avatars.githubusercontent.com/u/9740075?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vadimdeineka",
"html_url": "https://github.com/vadimdeineka",
"followers_url": "https://api.github.com/users/vadimdeineka/followers",
"following_url": "https://api.github.com/users/vadimdeineka/following{/other_user}",
"gists_url": "https://api.github.com/users/vadimdeineka/gists{/gist_id}",
"starred_url": "https://api.github.com/users/vadimdeineka/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/vadimdeineka/subscriptions",
"organizations_url": "https://api.github.com/users/vadimdeineka/orgs",
"repos_url": "https://api.github.com/users/vadimdeineka/repos",
"events_url": "https://api.github.com/users/vadimdeineka/events{/privacy}",
"received_events_url": "https://api.github.com/users/vadimdeineka/received_events",
"type": "User",
"site_admin": false
},
"version": "8763d463517eef559e7fd7daf653ffc5c1e7245f",
"committed_at": "2024-03-22T10:32:21Z",
"change_status": {
"total": 3,
"additions": 3,
"deletions": 0
},
"url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622/8763d463517eef559e7fd7daf653ffc5c1e7245f"
}
],
"truncated": false
}
}
}
{
"request": {
"method": "DELETE",
"url": "https://api.github.com/gists/31e4458e2fbb1e073787790766268622",
"headers": {
"authorization": "********",
"accept": "*/*"
}
},
"response": {
"protocol": "h2",
"statusCode": 204
}
}
Multiple HTTP clients
@Autowired
private RestTemplate bookServerRestTemplate;
@Autowired
private RestTemplate authorServerRestTemplate;
@Test
@MockServer(httpClient = "bookServerRestTemplate", value = "/mockserver/multiservers/books-server.rest.json")
@MockServer(httpClient = "authorServerRestTemplate", value = "/mockserver/multiservers/authors-server.rest.json")
void should_retrieve_books() {
...
List<Book> allBooks = restClient.get("https://books.server/books", listOf(Book.class));
List<Author> allAuthors = restClient.get("https://authors.server/authors", listOf(Author.class));
Book book = restClient.get("https://books.server/books/129649986932158", typeOf(Book.class));
Author author = restClient.get("https://authors.server/authors/1", typeOf(Author.class));
...
}
Multiple Servers
@Test
@MockServer(urlPattern = "https://books.server/**", value = "/mockserver/multiservers/books-server.rest.json")
@MockServer(urlPattern = "https://authors.server/**", value = "/mockserver/multiservers/authors-server.rest.json")
void should_retrieve_books() {
...
List<Book> allBooks = restClient.get("https://books.server/books", listOf(Book.class));
List<Author> allAuthors = restClient.get("https://authors.server/authors", listOf(Author.class));
Book book = restClient.get("https://books.server/books/129649986932158", typeOf(Book.class));
Author author = restClient.get("https://authors.server/authors/1", typeOf(Author.class));
...
}
[
{
"request": {
"method": "GET",
"url": "https://books.server/books",
"headers": {
"accept": "application/json, application/*+json"
}
},
"response": {
"statusCode": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json; charset=utf-8"
},
"body": [
{
"id": 129649986932158,
"author": {
"id": 129649985822335,
"firstName": "3vRRjH5Eir",
"lastName": "v4qcdNu87_"
},
"title": "lIEE41TMJh"
},
{
"id": 129649988384959,
"author": {
"id": 129649987758738,
"firstName": "0ddAM5PDcp",
"lastName": "Q2DXdR9DdB"
},
"title": "Oin7c_WtHq"
}
]
}
},
{
"request": {
"method": "GET",
"url": "https://books.server/books/129649986932158",
"headers": {
"accept": "application/json, application/*+json"
}
},
"response": {
"statusCode": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json; charset=utf-8"
},
"body": {
"id": 129649986932158,
"author": {
"id": 129649985822335,
"firstName": "3vRRjH5Eir",
"lastName": "v4qcdNu87_"
},
"title": "lIEE41TMJh"
}
}
}
]
[
{
"request": {
"method": "GET",
"url": "https://authors.server/authors",
"headers": {
"accept": "application/json, application/*+json"
}
},
"response": {
"statusCode": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json; charset=utf-8"
},
"body": [
{
"id": 1,
"firstName": "William",
"lastName": "Shakespeare"
}
]
}
},
{
"request": {
"method": "GET",
"url": "https://authors.server/authors/1",
"headers": {
"accept": "application/json, application/*+json"
}
},
"response": {
"statusCode": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json; charset=utf-8"
},
"body": {
"id": 1,
"firstName": "William",
"lastName": "Shakespeare"
}
}
}
]
Last updated