2
웹 태그로 전달 된 인수를 캡처하려고합니다. 그러나 IntelliJ가 계속 잘못된 것을 말하고 있습니다.Entity 인수를 mockito의 webtarget.request.put에 입력하십시오.
Entity.class를 캡처 할 수 없습니까, 아니면 잘못 했습니까?
코드
private WebTarget webTarget;
response = target.request("application/hal+json").put(Entity.entity(inputString, MediaType.APPLICATION_JSON_TYPE));
내 테스트를
@RunWith(MockitoJUnitRunner.class)
public class ConnectorClientTest {
@Mock
WebTarget webTarget;
@Mock
Invocation.Builder builder;
@InjectMocks
ConnectorClient connectorClient;
@Before
public void setUp() throws Exception {
Response response = null;
when(webTarget.path(any())).thenReturn(webTarget);
when(webTarget.path(any())).thenReturn(webTarget);
when(webTarget.request(anyString())).thenReturn(builder);
when(builder.put(any(Entity.class)))
.thenReturn(response);
}
@Test
public void initiatePropertyIdentifierSearchTest(){
PropertyIdentifierSearchInput input = new
PropertyIdentifierSearchInput("12345670", BigInteger.valueOf(123));
connectorClient.initiatePropertyIdentifierSearch(input);
ArgumentCaptor<Entity> argument = ArgumentCaptor.forClass(Entity.class);
verify(webTarget.request((String[])
Mockito.any()).put(argument.capture()));
Entity entity = argument.getValue();
//assert the entity
}
확인해 주셔야합니다. – stuf99