-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Trunk 2303 #266
Trunk 2303 #266
Changes from all commits
9912509
a9984b5
9de77d9
b949fc5
de564b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ | |
import org.openmrs.test.Verifies; | ||
|
||
/** | ||
* This class tests all methods that are not getter or setters in the Obs java object TODO: finish | ||
* this test class for Obs | ||
* This class tests all methods that are not getter or setters in the Obs java | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you have the right code template, and this line was reformatted to be too short. Make sure you have the code formatter and template defined at https://wiki.openmrs.org/display/docs/Coding+Conventions |
||
* object TODO: finish this test class for Obs | ||
* | ||
* @see Obs | ||
*/ | ||
|
@@ -53,7 +53,8 @@ public void shouldAddandRemoveObsToGroup() throws Exception { | |
// These methods should not fail even with null attributes on the obs | ||
assertFalse(obsGroup.isObsGrouping()); | ||
assertFalse(obsGroup.hasGroupMembers(false)); | ||
assertFalse(obsGroup.hasGroupMembers(true)); //Check both flags for false | ||
assertFalse(obsGroup.hasGroupMembers(true)); // Check both flags for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment here about your line length being too short |
||
// false | ||
|
||
// adding an obs when the obs group has no other obs | ||
// should not throw an error | ||
|
@@ -102,23 +103,23 @@ public void shouldGetRelatedObservations() throws Exception { | |
o.setPerson(new Patient(2)); | ||
o.setValueText("childObs"); | ||
|
||
//create its sibling | ||
// create its sibling | ||
Obs oSibling = new Obs(); | ||
oSibling.setDateCreated(new Date()); | ||
oSibling.setLocation(new Location(1)); | ||
oSibling.setObsDatetime(new Date()); | ||
oSibling.setValueText("childObs2"); | ||
oSibling.setPerson(new Patient(2)); | ||
|
||
//create a parent Obs | ||
// create a parent Obs | ||
Obs oParent = new Obs(); | ||
oParent.setDateCreated(new Date()); | ||
oParent.setLocation(new Location(1)); | ||
oParent.setObsDatetime(new Date()); | ||
oSibling.setValueText("parentObs"); | ||
oParent.setPerson(new Patient(2)); | ||
|
||
//create a grandparent obs | ||
// create a grandparent obs | ||
Obs oGrandparent = new Obs(); | ||
oGrandparent.setDateCreated(new Date()); | ||
oGrandparent.setLocation(new Location(1)); | ||
|
@@ -130,7 +131,7 @@ public void shouldGetRelatedObservations() throws Exception { | |
oParent.addGroupMember(oSibling); | ||
oGrandparent.addGroupMember(oParent); | ||
|
||
//create a leaf observation at the grandparent level | ||
// create a leaf observation at the grandparent level | ||
Obs o2 = new Obs(); | ||
o2.setDateCreated(new Date()); | ||
o2.setLocation(new Location(1)); | ||
|
@@ -141,17 +142,18 @@ public void shouldGetRelatedObservations() throws Exception { | |
oGrandparent.addGroupMember(o2); | ||
|
||
/** | ||
* test to make sure that if the original child obs calls getRelatedObservations, it returns | ||
* itself and its siblings: original obs is one of two groupMembers, so relatedObservations | ||
* should return a size of set 2 then, make sure that if oParent calls | ||
* getRelatedObservations, it returns its own children as well as the leaf obs attached to | ||
* the grandparentObs oParent has two members, and one leaf ancestor -- so a set of size 3 | ||
* should be returned. | ||
* test to make sure that if the original child obs calls | ||
* getRelatedObservations, it returns itself and its siblings: original | ||
* obs is one of two groupMembers, so relatedObservations should return | ||
* a size of set 2 then, make sure that if oParent calls | ||
* getRelatedObservations, it returns its own children as well as the | ||
* leaf obs attached to the grandparentObs oParent has two members, and | ||
* one leaf ancestor -- so a set of size 3 should be returned. | ||
*/ | ||
assertEquals(o.getRelatedObservations().size(), 2); | ||
assertEquals(oParent.getRelatedObservations().size(), 3); | ||
|
||
// create a great-grandparent obs | ||
// create a great-grandparent obs | ||
Obs oGGP = new Obs(); | ||
oGGP.setDateCreated(new Date()); | ||
oGGP.setLocation(new Location(1)); | ||
|
@@ -160,7 +162,7 @@ public void shouldGetRelatedObservations() throws Exception { | |
oGGP.setValueText("grandParentObs"); | ||
oGGP.addGroupMember(oGrandparent); | ||
|
||
//create a leaf great-grandparent obs | ||
// create a leaf great-grandparent obs | ||
Obs oGGPleaf = new Obs(); | ||
oGGPleaf.setDateCreated(new Date()); | ||
oGGPleaf.setLocation(new Location(1)); | ||
|
@@ -170,24 +172,25 @@ public void shouldGetRelatedObservations() throws Exception { | |
oGGP.addGroupMember(oGGPleaf); | ||
|
||
/** | ||
* now run the previous assertions again. this time there are two ancestor leaf obs, so the | ||
* first assertion should still return a set of size 2, but the second assertion sould | ||
* return a set of size 4. | ||
* now run the previous assertions again. this time there are two | ||
* ancestor leaf obs, so the first assertion should still return a set | ||
* of size 2, but the second assertion sould return a set of size 4. | ||
*/ | ||
assertEquals(o.getRelatedObservations().size(), 2); | ||
assertEquals(oParent.getRelatedObservations().size(), 4); | ||
|
||
//remove the grandparent leaf observation: | ||
// remove the grandparent leaf observation: | ||
|
||
oGrandparent.removeGroupMember(o2); | ||
|
||
//now the there is only one ancestor leaf obs: | ||
// now the there is only one ancestor leaf obs: | ||
assertEquals(o.getRelatedObservations().size(), 2); | ||
assertEquals(oParent.getRelatedObservations().size(), 3); | ||
|
||
/** | ||
* finally, test a non-obsGroup and non-member Obs to the function Obs o2 is now not | ||
* connected to our heirarchy: an empty set should be returned: | ||
* finally, test a non-obsGroup and non-member Obs to the function Obs | ||
* o2 is now not connected to our heirarchy: an empty set should be | ||
* returned: | ||
*/ | ||
|
||
assertNotNull(o2.getRelatedObservations()); | ||
|
@@ -271,6 +274,15 @@ public void getValueAsString_shouldReturnNonPreciseValuesForNumericConcepts() th | |
Assert.assertEquals(str, obs.getValueAsString(Locale.US)); | ||
} | ||
|
||
@Test | ||
@Verifies(value = "should not return long decimal numbers as scientific notation", method = "getValueAsString(Locale)") | ||
public void getValueAsString_shouldNotReturnLongDecimalNumbersAsScientificNotation() throws Exception { | ||
Obs obs = new Obs(); | ||
obs.setValueNumeric(123456789.0); | ||
String str = "123456789.0"; | ||
Assert.assertEquals(str, obs.getValueAsString(Locale.US)); | ||
} | ||
|
||
@Test | ||
@Verifies(value = "should return proper DateFormat", method = "getValueAsString()") | ||
public void getValueAsString_shouldReturnProperDateFormat() throws Exception { | ||
|
@@ -301,7 +313,8 @@ public void getValueAsBoolean_shouldReturnTrueForValue_numericConceptsIfValueIs1 | |
|
||
/** | ||
* @see Obs#getGroupMembers(boolean) | ||
* @verifies Get all group members if passed true, and non-voided if passed false | ||
* @verifies Get all group members if passed true, and non-voided if passed | ||
* false | ||
*/ | ||
@Test | ||
public void getGroupMembers_shouldGetAllGroupMembersIfPassedTrueAndNonvoidedIfPassedFalse() throws Exception { | ||
|
@@ -317,7 +330,7 @@ public void getGroupMembers_shouldGetAllGroupMembersIfPassedTrueAndNonvoidedIfPa | |
assertEquals("set of all members should have length of 3", 3, members.size()); | ||
members = parent.getGroupMembers(false); | ||
assertEquals("set of non-voided should have length of 2", 2, members.size()); | ||
members = parent.getGroupMembers(); //should be same as false | ||
members = parent.getGroupMembers(); // should be same as false | ||
assertEquals("default should return non-voided with length of 2", 2, members.size()); | ||
} | ||
|
||
|
@@ -330,7 +343,7 @@ public void hasGroupMembers_shouldReturnTrueIfThisObsHasGroupMembersBasedOnParam | |
Obs parent = new Obs(5); | ||
Obs child = new Obs(33); | ||
child.setVoided(true); | ||
parent.addGroupMember(child); //Only contains 1 voided child | ||
parent.addGroupMember(child); // Only contains 1 voided child | ||
assertTrue("When checking for all members, should return true", parent.hasGroupMembers(true)); | ||
assertFalse("When checking for non-voided, should return false", parent.hasGroupMembers(false)); | ||
assertFalse("Default should check for non-voided", parent.hasGroupMembers()); | ||
|
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 need to comment import. Please remove it.