/** Test the list feed instances api using an orderBy parameter. Check the order. */
 @Test
 public void testFeedOrderBy()
     throws URISyntaxException, OozieClientException, JAXBException, AuthenticationException,
         IOException, InterruptedException {
   SoftAssert softAssert = new SoftAssert();
   // orderBy start time
   InstancesResult r =
       prism.getFeedHelper().listInstances(feedName, "orderBy=startTime&sortOrder=desc", null);
   InstancesResult.Instance[] instances = r.getInstances();
   Date previousDate = new Date();
   for (InstancesResult.Instance instance : instances) {
     Date current = instance.getStartTime();
     if (current != null) { // e.g if instance is WAITING it doesn't have start time
       softAssert.assertTrue(
           current.before(previousDate) || current.equals(previousDate),
           "Wrong order. Current startTime :" + current + " Previous: " + previousDate);
       previousDate = (Date) current.clone();
     }
   }
   // orderBy status
   r =
       prism
           .getFeedHelper()
           .listInstances(
               feedName,
               "start=" + startTime + "&numResults=12&orderBy=status&sortOrder=desc",
               null);
   InstanceUtil.validateResponse(r, 12, 1, 1, 4, 6);
   instances = r.getInstances();
   InstancesResult.WorkflowStatus previousStatus = InstancesResult.WorkflowStatus.WAITING;
   for (InstancesResult.Instance instance : instances) {
     InstancesResult.WorkflowStatus current = instance.getStatus();
     softAssert.assertTrue(
         current.toString().compareTo(previousStatus.toString()) <= 0,
         "Wrong order. Compared " + current + " and " + previousStatus + " statuses.");
     previousStatus = current;
   }
   // sort by endTime
   r =
       prism
           .getFeedHelper()
           .listInstances(
               feedName,
               "start=" + startTime + "&numResults=12&orderBy=endTime&sortOrder=desc",
               null);
   instances = r.getInstances();
   previousDate = new Date();
   for (InstancesResult.Instance instance : instances) {
     Date current = instance.getEndTime();
     if (current != null) { // e.g if instance is WAITING it doesn't have end time
       softAssert.assertTrue(
           current.before(previousDate) || current.equals(previousDate),
           "Wrong order. Current startTime :" + current + " Previous: " + previousDate);
       previousDate = (Date) current.clone();
     }
   }
   softAssert.assertAll();
 }