Keelhaul: I've attached a patch that has the fixes for the test cases you mentioned. It entailed making a change to the HibernateLocationDAO.saveLocation to work like HibernateObsDAO.saveObs worked. Luckily, I had encountered the same problem when I was doing obs grouping, so I knew where to look.
The other fix was in trunk. The "parent_location_id" column was not being picked up in your dbunit xml file because the first location element in there didn't have that column defined. For some reason, dbunit treats the first element as the standard for all elements in that file. Because the first element didn't have the column, the column wasn't used in any of the subsequent elements...hence your other columns not really being children of the parent. I added the column to the first with a value of [NULL] so that it would work. Update to the latest trunk as well.
Two requests:
- Have LocationTag mimic ConceptNameTag. The properties on it should be the same, saved the same way, etc. (You don't need those default values though)
- Clean up and shorten your test cases. I really like where you're going with the test cases. Kudos to you for it!
However, some of your test cases are doing too much, assert more than once, etc. You can pull a lot of tests out into really small LocationTest.java and only test, say, the addChildLocation(Location) method. Then in your LocationServiceTest you can assume that that will be working and you won't have to do so many asserts.
Something like:
LocationTest.java:
public void addChildLocation_shouldAssignParentLocation() \{
Location parentLocation = new Location();
Location childLocation = new Location();
parentLocation.addChildLocation(childLocation);
assertTrue(parentLocation.equals(childLocation.getParentLocation()));
\}
Strong work here, Keelhaul. Once you throw in these changes, we'll push it through an official code review and hopefully get it into trunk soon!
I'll add a liquibase element for the sql changes for you when I can...
I fear that we're going to need to support several classes of locations – e.g., clinic locations, cities, states, etc. We don't want the list of all known villages to show up when data assistants are selecting a clinic site, right?