I'm trying to mock a restTemplate.exchange method through mockito but it always returns a null value no matter what i return through mock , even if i throw an exception:
this is the actual code :
ResponseEntity<List<LOV>> response = restTemplate.exchange(url, GET, null,new ParameterizedTypeReference<List<LOV>>() {});
mockito code:
ResponseEntity<List<LOV>> mockResponse = new ResponseEntity<List<LOV>>(mockLovList() ,HttpStatus.ACCEPTED);
Mockito.when(restTemplate.exchange(any(), eq(GET), any(), ArgumentMatchers.<ParameterizedTypeReference<List<LOV>>>any())).thenReturn(mockResponse);
Every argument is of type ArgumentMatchers in the exchange mock , mockLovList() returns a list of LOV
it should return whatever i mocked , but it always returns null