Need Help…
I tried to run mockito unit test but it giving error`Strict stubbing argument mismatch.
does anyone know why this error happened is there something wrong with my code ?
Any response would be highly appreciated.
Please check:
this invocation of 'getCoopPipelineItems' method: aggregateService.getCoopPipelineItems( [0], "submitted", "filter", Mock for Pageable, hashCode: 2037183157 ); -> at io.portfolioaggregate.service.rest.PortfolioAggregateRestController.getCoopPipelineOutlinesWithFilter(PortfolioAggregateRestController.java:92)
has following stubbing(s) with different arguments:
aggregateService.getCoopPipelineItems( [0], "", "", null );
Here’s my code:
@Test
public void getCoopPipelineOutlinesWithFilter_returnsExpectedResult() {
PagedResult<PipelineItem> expected = mock(PagedResult.class);
when(aggregateService.getCoopPipelineItems(List.of(anyInt()), anyString(), anyString(), any(Pageable.class)))
.thenReturn(expected);
List<Integer> orgIds = List.of(0);
PagedResult<PipelineItem> result = controller.getCoopPipelineOutlinesWithFilter(orgIds, "submitted", "filter", mock(Pageable.class));
Assertions.assertEquals(expected, result);
verify(aggregateService).getCoopPipelineItems(orgIds, "submitted", "filter",
mock(Pageable.class));
}
fix the error of my code and unit test pass
New contributor
Nelvan Balthazar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.