So here is the scenario
public class Report {
public void Generate {
if (!isValidDate) {
return;
}
//calling other method
}
protected boolean isValidDate() {
boolean isValid = true;
//some logic here to change to false
return isValid;
}
}
And in my test, I have this as I want to set the boolean value to be true.
@InjectMocks
Report report;
@Before
public void setUp() throws Exception {
Whitebox.setInternalState(report, "isValidParameters", true);
}
@Test
public void testReport() throws Exception {
//test logic to be added here
}
Then I got the RuntimeException: Unable to set internal state on a private field. Can someone please help on how I can set the boolean value of that protected method for my test here? TIA