To test a protected method using junit and mockito, in the test class (the class used to test the method), create a “child class” that extends the protagonist class and merely overrides the protagonist method to make it public so as to give access to the method to the test class, and then write tests against this child class.
To break that down, the problem statement is that the test class does not have access to the protected method and hence the developer is unable to write tests to validate the protected method.
The less than optimal solution is to modify the access modifier to public so as to give test class access to this method. This is a HUGE compromise to the encapsulation ideal and the tenet that a method should have the LEAST visibility that it needs.
The solution here is to provide a surrogate class that extends the protagonist class and whose only purpose is to override the method in question and make it public. Once that is done, the test class treats this class as the protagonist class and writes assertions on it.