回答編集履歴

2

コード例が不適切だったので修正

2020/08/08 04:03

投稿

kiino
kiino

スコア539

test CHANGED
@@ -1,4 +1,16 @@
1
+ ```Java
2
+
3
+ mockServer
4
+
5
+ .expect(requestTo(callEndpoint))
6
+
7
+ .andExpect(method(HttpMethod.GET))
8
+
1
- `.andRespond(withBadRequest().body(jsonResponseBody))` と MockRestServiceServer の振る舞いを定義してはいかがでしょうか。
9
+ .andRespond(withBadRequest().body(jsonResponseBody));
10
+
11
+ ```
12
+
13
+ MockRestServiceServer の振る舞い定義を以上にしてはいかがでしょうか。
2
14
 
3
15
 
4
16
 

1

内容について捕捉

2020/08/08 04:03

投稿

kiino
kiino

スコア539

test CHANGED
@@ -1 +1,7 @@
1
1
  `.andRespond(withBadRequest().body(jsonResponseBody))` と MockRestServiceServer の振る舞いを定義してはいかがでしょうか。
2
+
3
+
4
+
5
+ `withBadRequest()`, `withServerError()` は `DefaultResponseCreator class` のファクトリなだけなので、
6
+
7
+ `DefaultResponseCreator` の持つメソッド呼び出しからボディ、ヘッダーなどの要素を追加することが可能です。