MetadataUtilsTest.getLocation_shouldFetchByUuid Throwing Error

Hallo friends… i have been working on TICKET DPLY-40 and Finished replacing SessionFactory/Session instances with DbSessionFactory / DbSession instances for purposes of backwards compatibility with openmrs versions less than 2.x. When i run mvn clean install -DskipTests, builds are successful ,however when i include tests,builds fail,causes by en error in metadatadeploy.MetadataUtilsTest Tests in error: getLocation_shouldFetchByUuid(org.openmrs.module.metadatadeploy.MetadataUtilsTest): No such Location with identifier 'dc5c1fcc-0459-4201-bf70-0b90535ba362

any hints or way out ?

I suggest that you check out the status of the location table during the tests. E.g. if that location is actually not in the table then you need to figure out why it’s not there after making your changes.

I would do this by putting a breakpoint somewhere in the test and inspecting things with your IDEs debugger. (But you could also do it by adding a lot of log.debug statements.)

2 Likes

Thanks very much @darius,will get back to you as soon as i have tried out those options.

Herer, you can simply use with REST API to confirm that location object exists in the system. Try this following URL in your browser simply and check the output!

http://localhost:8081/openmrs/ws/rest/v1/location/dc5c1fcc-0459-4201-bf70-0b90535ba362

1 Like

Thanks @suthagar23

Let me also ask this, making that rest call, would it not be directing me to the system database? I found .csv sample data file shipped with the module…i came across /metadatadeploy-api/src/test/resources/test-location-source.csv with the following contents…

1.Name,Desc 2.Location #1,Testing,51DA0E0A-CD4B-4D48-9422-7555623662BB 3. Location #2,C271874A-DACE-480A-8D55-840A96ADA70F 4.Location #3 , ,8FA56890-2CCA-40CD-9D43-67E0C9732AA5

I tried out all the values in the method signature param,with failures.But i will try out all options and see…

Not sure this will work. He’s still building the project and does not use a deployed server. During test execution database tables are built from dataset files.

@ivange94 Thanks ,it looks like that UUID is particularly missing on the .csv list…

Can you confirm that this test passes without your changes? For that you can just checkout master and do mvn clean install. If you are developing on master then you have to checkout a new branch and revert the branch to the first commit below your own and do mvn clean install. If the test passes while doing the above then the location is actually present but something in your code might be making it unavailable at the time of running the test.

To verify that I’ll advice you place breakpoints in your code as @darius suggested. With Intelij Idea you even place breakpoints in code that is not available. That is if your code uses api binaries you can still place breakpoints in them.

BE CAREFUL not to wipe out your work :grinning:

ha ha true:joy:

@ivange94 Tests pass with master…so i think i may have to do git reset and re do something…