2016-08-18 8 views
1

私は外部呼び出しを模擬しようとしています。Spring統合フレームワークでResponseEntity <?>のJunit Mockitoテストケース

ResponseEntity<?> httpResponse = requestGateway.pushNotification(xtifyRequest);

requestGatewayインタフェースです。

public interface RequestGateway 
{ 
ResponseEntity<?> pushNotification(XtifyRequest xtifyRequest); 
} 

以下は、私がしようとしているテスト方法です。

@Test 
public void test() 
{ 


    ResponseEntity<?> r=new ResponseEntity<>(HttpStatus.ACCEPTED); 

    when(requestGateway.pushNotification(any(XtifyRequest.class))).thenReturn(r); 
} 

コンパイルエラーが無効type.even thougg rはタイプResponseEntityであるとして、それを言って、上記のステートメントであります。

誰でもこの問題を解決するのに手伝ってください。

答えて

4

ResponseEntity r=new ResponseEntity(HttpStatus.ACCEPTED); 
when(requestGateway.pushNotification(any(XtifyRequest.class))).thenReturn(r); 
をあざけるながら、あなたは代わりに、タイプ危険な方法

doReturn(r).when(requestGateway.pushNotification(any(XtifyRequest.class))); 

を使用するかは、型情報を削除することができます

関連する問題