I am migrating my powermock code to mockito, I am currently stuck at mocking constructors with specific argument.
this is older code with powermock –
final ViewRequest viewRequest = new ViewRequest(httpRequest);
PowerMockito.whenNew(ViewRequest.class).withArguments(httpRequest).thenReturn(viewRequest);
I tried using mockedConstruction like this –
MockedConstruction<ViewRequest> viewRequestMockedConstruction =
mockConstruction(ViewRequest.class, (mock, context) -> {
if(context.arguments().get(0).equals(httpRequest)){
mock = viewRequest;
}
});
but this is not working
1