How to test public method of Service class not belonging to the interface

Tags: #<Tag:0x00007fe2e1ad5478> #<Tag:0x00007fe2e1ad5388>

The method public void triggerStateConversion(Patient patient, Concept trigger, Date dateConverted) in class org.openmrs.api.ProgramWorkflowService is a more complex method. Unfortunately it cannot be tested as a BaseContextSensitiveTest since the method does not belong to the interface of the ProgramWorkflowService.

Is it sufficient and ok to test in the …ServiceUnitTest using mocking?

What is wrong with testing it as a BaseContextSensitiveTest?

It’s just not visible and casting the instance of ProgramWorkflowService returned by Context.getProgramWorkflowService() to ProgramWorkflowServiceImpl does not work. The compiler accepts casting but running the tests results in:

java.lang.ClassCastException: com.sun.proxy.$Proxy121 cannot be cast to org.openmrs.api.impl.ProgramWorkflowServiceImpl
	at org.openmrs.api.ProgramWorkflowServiceTest.runBeforeEachTest(ProgramWorkflowServiceTest.java:73)

Its very possible to test every class make it public or private, protected, Testing openmrs classes and interface , you need to be having idea of expressional testing.