I want non-static method of an object returned by a static factory method to return a specific result.
After I have done this setup my test code will be calling the ConnectionFactory.getConn("ABC") indirectly through another piece of code which is being tested.
PowerMockito.when(ConnectionFactory.getConn("ABC").getCurrentStatus()).thenReturn(ConnectionStatus.CONNECTED);
I get a NPE for the above statement.
- I already have @PrepareForTest({FXAllConnectionFactory.class, ConnectionStatus.class}) at the beginning of my junit test class.
What would be the correct way of doing it?
Thanks in advance :)