'Mockito Mongotemplate AggregationResults.getMappedResults getting nullpointer exception
catTemplate.aggregate(cat, cat_collection,Cat.class).getMappedResults()
I want to mock above line so i have written below code
@Mock
MongoTemplate catTemplate;
AggregationResults<Cat> mockResults = (AggregationResults<Cat>) mock(
AggregationResults.class);
when(catTemplate.aggregate(any(Aggregation.class), anyString(),
eq(Cat.class))) .thenReturn(mockResults);
when(mockResults.getMappedResults()).thenReturn(catList);
I am getting null pointer exception, any one help on this
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
