2017-12-19 20 views
0

私のモック呼び出しは以下のようなものです生の値と組み合わされた場合、この例外が発生する可能性があります。マッチャーが

BDDMockito.given(restTemplate.exchange(url, 
    HttpMethod.POST, 
    BDDMockito.any(), 
    Response.class) 
).willReturn(responseEntity); 

が、私はエラーの下に取得しています。これについて私を助けてください???????

4 matchers expected, 1 recorded: 
-> at com.esrx.aggregation.service.servicecaller.GetSpecalityInventoryItemsCallerTest.getSpecalityInventoryItemsCallPositiveTest(GetSpecalityInventoryItemsCallerTest.java:67) 

This exception may occur if matchers are combined with raw values: 
    //incorrect: 
    someMethod(anyObject(), "raw String"); 
When using matchers, all arguments have to be provided by matchers. 
For example: 
    //correct: 
    someMethod(anyObject(), eq("String by matcher")); 

For more info see javadoc for Matchers class. 
, mergedContextConfiguration = [[email protected] testClass = GetSpecalityInventoryItemsCallerTest, locations = '{}', classes = '{class com.esrx.aggregation.application.Main, class com.esrx.aggregation.application.Main}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{classpath:/application.properties, classpath:/service.properties}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.sp[email protected]351d00c0, org.springfr[email protected]35d019a3, org.[email protected]0, org.springframework.boot[email protected]0, org.springframework.boot.test.autocon[email protected]78691363], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]]]. 
2017-12-19 15:59:53.085 INFO 10140 --- [  Thread-5] o.s.w.c.s.GenericWebApplicationContext : Closing org.s[email protected]5a62b2a4: startup date [Tue Dec 19 15:59:35 IST 2017]; parent: org.spring[email protected]3e6f3f28 

答えて

0

これは、マッチャーと生の値を混在させることができないためです。マッチャーを使用する場合は、すべての引数に対してマッチャーを使用する必要があります。

BDDMockito.given(restTemplate.exchange(Mockito.eq(url), Mockito.eq(HttpMethod.POST), BDDMockito.any(), Mockito.eq(Response.class))).willReturn(responseEntity) 
+0

BDDMockito.given(restTemplate.exchange(Mockito.anyString()、Mockito.any()、BDDMockito.any():あなたはまだあなたが()マッチャー.EQを使用することができ、正確な値と一致する場合、 \t \t \t \t BDDMockito。> any)))。willReturn(responseEntity);大変ありがとう!!!!! –

+0

よろしくお願いします!それがあなたを助けたら私の答え/ upvoteを受け入れなさい! – Plog

関連する問題