code looks something like this
public GetPortfoliosResponse retrievePortfolios(
RequestIdentityInfo requestIdentityInfo,
GetPortfoliosRequest getPortfoliosRequest) {
PortfolioReferenceParameter portfolioReferenceParameter = new PortfolioReferenceParameter();
//some code
List<Portfolio> portfolios = portfolioReferenceParameter.getPortfolios();
}
And in my test class I'm doing something like this:
@Mock
private PortfolioReferenceParameter portfolioReferenceParameter;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
List<Portfolio> portfolios = new ArrayList<Portfolio>();
//code to build the list
when(portfolioReferenceParameter.getPortfolios()).thenReturn(portfolios);
}
But this doesn't seem to be working. When I make a call to the serviceimpl method it is still taking the actual object of PortfolioReferenceParameter which is locally created in that method. Any ideas how can I mock that object with my object?
Aucun commentaire:
Enregistrer un commentaire