OrderServiceTest starts to fail!

This test “OrderServiceTest saveOrder_shouldThrowAmbiguousOrderExceptionIfDisconnectingMultipleActiveOrdersForTheGivenConcepts” is failing on all branches where it exists. That is 1.10.x, 1.11.x, 1.12.x, 2.0.x, 2.1.x, and master. It has always run successfully until all of the sudden, it started failing. I first detected it on our Sonar CI https://ci.openmrs.org/browse/SON-OPENMRSCOREMASTER/latest All other platform CI builds were green. So i decided to manually run them and they all failed. I even tried them out locally and they still failed. Am trying to investigate, but just wanted to mention it here just in case some one has an answer that will save my time, for it seems obvious. :smile:

@dkayiwa, thanks for posting this. I had spent a little time the other night trying to test a patch to the CohortMembership issue I raised recently, and also ran into this failure. I didn’t know why and it was blocking me slightly. So I’m glad to hear it wasn’t just me! Please update back here if this gets figured out.

Thanks, Mike

It fails for me too locally, we need to find out the revision when it started failing

It’s a data problem, not a bug. One of the orders in the XML test file has date_stopped=“2017-08-15 00:00:00.0”. As getActiveOrders uses the system date if the parameter asOfDate is NULL, the test worked fine until four days ago.

A couple of things I saw:

  • DrugOrder.toString should display the date stopped info in the from … to part.
  • HibernateOrderDAO.getActiveOrders is barely readable with Criteria, HQL would be clearer

Date condition in HQL:

dateActivated <= :asOfDate AND (dateStopped IS NULL AND autoExpireDate IS NULL OR dateStopped IS NULL AND autoExpireDate >= :asOfDate OR dateStopped >= :asOfDate)

Great find @lluismf! I have created a ticket and marked it as Ready for Work here:


Very good catch @lluismf :smile: And it happened here: https://issues.openmrs.org/browse/TRUNK-4701