-
Notifications
You must be signed in to change notification settings - Fork 3.8k
TRUNK-5067: Added tests to MessageServiceImpl #4922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -1,116 +1,173 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you intentionally remove the license header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean this one ->
/**
- This Source Code Form is subject to the terms of the Mozilla Public License,
- v. 2.0. If a copy of the MPL was not distributed with this file, You can
- obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
- the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
- Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
- graphic logo is a trademark of OpenMRS Inc.
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, i didn't intend it. May be the file never had that header, but it's ok. Let me fix it. Thanks!
var templates = messageService.getTemplatesByName(templateName); | ||
|
||
// Assert | ||
assertNotNull(templates); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sure this fails, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm putting everything right ensuring that every test passes. WORK IN PROGRESS......
package org.openmrs.notification; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.openmrs.api.context.Context; | ||
import org.openmrs.test.jupiter.BaseContextSensitiveTest; | ||
import org.openmrs.notification.MessageServiceImpl; | ||
import org.openmrs.notification.MessageException; | ||
import org.openmrs.notification.Message; | ||
import org.openmrs.notification.Template; | ||
import org.openmrs.notification.MessagePreparator; | ||
import org.openmrs.notification.MessageSender; | ||
|
||
/** | ||
* Unit tests for the MessageService. | ||
*/ | ||
public class MessageServiceTest extends BaseContextSensitiveTest { | ||
|
||
private static final String NO_SMTP_SERVER_ERROR = "Could not connect to SMTP host:"; | ||
|
||
MessageService ms = null; | ||
private MessageServiceImpl messageService; | ||
|
||
/** | ||
* Run this before each unit test in this class. The "@Before" method in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvements: Added unit tests, proper test setup, and integration with OpenMRS test data.
Needs minor fixes: Add missing assertions, avoid redundant initialization, and refactor hardcoded strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank u 4 ur time and advice. I'm busy polishing these codes but i have one challenge >> The openmrs initialisation wizard never completed successfully. I have tried it many times but still fail. THEN, about these tests. Yes i made some fixes here and there but the problem is that these tests keep passing and failing on different trials i don't know why?? could it be due to that initialisation wizard issue i mentioned earlier or something else. Now, can i push these changes as they are? or i wait until they all pass at all times, because i'm still investigating. Thanx.
Description of what I changed
Issue I worked on
see https://issues.openmrs.org/browse/TRUNK-
Checklist: I completed these to help reviewers :)
[ x] My IDE is configured to follow the code style of this project.
No? Unsure? -> configure your IDE, format the code and add the changes with
git add . && git commit --amend
[x ] I have added tests to cover my changes. (If you refactored
existing code that was well tested you do not have to add tests)
No? -> write tests and add them to this commit
git add . && git commit --amend
[x ] I ran
mvn clean package
right before creating this pull request andadded all formatting changes to my commit.
No? -> execute above command
[ x] All new and existing tests passed.
No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.
[ x] My pull request is based on the latest changes of the master branch.
No? Unsure? -> execute command
git pull --rebase upstream master