Add tests to MessageServiceImpl

Hello all i have been working on this ticket https://issues.openmrs.org/browse/TRUNK-5067 In order to use the massage objects to write Unit tests on the overloaded sendMessage (…) methods, I think we should change the highlighted methods from returning void to returning a Message.java object because I neither see a table that store sent messages. Thanks…@dkayiwa, @k.joseph, @teleivo

Hi @jwnasambu,

you should be able to write tests without changing the API of MessageService. You could use mocks as in ProgramWorkflowServiceUnitTest which allow you to check if a service has been called and assert the arguments it got passed to.

2 Likes

@teleivo thanks

You can throw an APIException and store the message code in it. It’s the standard way in OpenMRS IIRC.

1 Like