I am trying to pass my responseEntityMock for this following snippet using, But it is not working.
ResponseEntity<byte[]> response =
new RestTemplate().exchange(url, HttpMethod.POST, requestEntity, byte[].class);
Can anyone tell me how to pass my own ResponseEntityMock for this code. Thanks.
I am using the following code:
ResponseEntity<byte[]> responseEntity = PowerMockito.mock(ResponseEntity.class);
RestTemplate restTemplateMock = PowerMockito.mock(RestTemplate.class);
PowerMockito.whenNew(RestTemplate.class).withAnyArguments().thenReturn(restTemplateMock);
when(restTemplateMock.exchange(eq(path), eq(POST), any(),
eq(byte[].class))).thenReturn(responseEntity);