回答編集履歴
2
コード例が不適切だったので修正
    
        answer	
    CHANGED
    
    | 
         @@ -1,4 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ```Java
         
     | 
| 
      
 2 
     | 
    
         
            +
            mockServer
         
     | 
| 
      
 3 
     | 
    
         
            +
              .expect(requestTo(callEndpoint))
         
     | 
| 
      
 4 
     | 
    
         
            +
              .andExpect(method(HttpMethod.GET))
         
     | 
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
              .andRespond(withBadRequest().body(jsonResponseBody));
         
     | 
| 
      
 6 
     | 
    
         
            +
            ```
         
     | 
| 
      
 7 
     | 
    
         
            +
            MockRestServiceServer の振る舞い定義を以上にしてはいかがでしょうか。
         
     | 
| 
       2 
8 
     | 
    
         | 
| 
       3 
9 
     | 
    
         
             
            `withBadRequest()`, `withServerError()` は `DefaultResponseCreator class` のファクトリなだけなので、
         
     | 
| 
       4 
10 
     | 
    
         
             
            `DefaultResponseCreator` の持つメソッド呼び出しからボディ、ヘッダーなどの要素を追加することが可能です。
         
     | 
1
内容について捕捉
    
        answer	
    CHANGED
    
    | 
         @@ -1,1 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            `.andRespond(withBadRequest().body(jsonResponseBody))` と MockRestServiceServer の振る舞いを定義してはいかがでしょうか。
         
     | 
| 
      
 1 
     | 
    
         
            +
            `.andRespond(withBadRequest().body(jsonResponseBody))` と MockRestServiceServer の振る舞いを定義してはいかがでしょうか。
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            `withBadRequest()`, `withServerError()` は `DefaultResponseCreator class` のファクトリなだけなので、
         
     | 
| 
      
 4 
     | 
    
         
            +
            `DefaultResponseCreator` の持つメソッド呼び出しからボディ、ヘッダーなどの要素を追加することが可能です。
         
     |