2017-12-19 26 views
0

내 모의 호출은 다음과 같다 원시 값과 결합하는 경우에 예외가 발생할 수 있습니다매처 (matcher)가

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

원본 값과 일치하는 혼합 수 없기 때문입니다. matchers를 사용하면 모든 인수에 대해 matchers를 사용해야합니다.) (

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