/**
   * Generate data. Schedule process. Try to perform -kill operation using -start and -end which are
   * both in future with respect to process start.
   *
   * @throws Exception TODO amend test with validations
   */
  @Test(groups = {"singleCluster"})
  public void testProcessInstanceKillBothStartAndEndInFuture01() throws Exception {
    /*
    both start and end r in future with respect to process start end
     */
    String startTime = TimeUtil.getTimeWrtSystemTime(-20);
    String endTime = TimeUtil.getTimeWrtSystemTime(400);
    String startTimeData = TimeUtil.getTimeWrtSystemTime(-50);
    String endTimeData = TimeUtil.getTimeWrtSystemTime(50);

    List<String> dataDates = TimeUtil.getMinuteDatesOnEitherSide(startTimeData, endTimeData, 1);
    HadoopUtil.flattenAndPutDataInFolder(
        clusterFS, OSUtil.SINGLE_FILE, baseTestHDFSDir + "/input01", dataDates);
    bundles[0].setInputFeedDataPath(feedInputPath.replace("input/", "input01/"));
    bundles[0].setProcessValidity(startTime, endTime);
    bundles[0].setProcessPeriodicity(5, TimeUnit.minutes);
    bundles[0].setOutputFeedPeriodicity(5, TimeUnit.minutes);
    bundles[0].setOutputFeedLocationData(feedOutputPath);
    bundles[0].setProcessConcurrency(6);
    bundles[0].submitFeedsScheduleProcess(prism);
    String startTimeRequest = TimeUtil.getTimeWrtSystemTime(-17);
    String endTimeRequest = TimeUtil.getTimeWrtSystemTime(23);
    InstancesResult r =
        prism
            .getProcessHelper()
            .getProcessInstanceKill(
                Util.readEntityName(bundles[0].getProcessData()),
                "?start=" + startTimeRequest + "&end=" + endTimeRequest);
    LOGGER.info(r.toString());
  }
 /**
  * Schedule process. Try to perform -getStatus using valid -start parameter but invalid process
  * name. Attempt should fail with an appropriate status code.
  *
  * @throws Exception
  */
 @Test(groups = {"singleCluster"})
 public void testProcessInstanceStatusInvalidName() throws Exception {
   bundles[0].setProcessValidity("2010-01-02T01:00Z", "2010-01-02T02:30Z");
   bundles[0].setProcessPeriodicity(5, TimeUnit.minutes);
   bundles[0].submitFeedsScheduleProcess(prism);
   InstancesResult r =
       prism
           .getProcessHelper()
           .getProcessInstanceStatus("invalidProcess", "?start=2010-01-01T01:00Z");
   if (!(r.getStatusCode() == ResponseKeys.PROCESS_NOT_FOUND)) {
     Assert.assertTrue(false);
   }
 }
 /**
  * Perform -getStatus using only -start parameter within time-range of non-materialized instances.
  * There should be no instances returned in response.
  *
  * @throws Exception
  */
 @Test(groups = {"singleCluster"})
 public void testProcessInstanceStatusOnlyStartAfterMat() throws Exception {
   bundles[0].setProcessValidity("2010-01-02T01:00Z", "2010-01-03T10:22Z");
   bundles[0].setProcessTimeOut(3, TimeUnit.minutes);
   bundles[0].setProcessPeriodicity(1, TimeUnit.minutes);
   bundles[0].setProcessConcurrency(1);
   bundles[0].submitFeedsScheduleProcess(prism);
   InstancesResult r =
       prism
           .getProcessHelper()
           .getProcessInstanceStatus(
               Util.readEntityName(bundles[0].getProcessData()), "?start=2010-01-02T05:00Z");
   AssertUtil.assertSucceeded(r);
   Assert.assertEquals(r.getInstances(), null);
 }
 /**
  * Schedule and then delete process. Try to get the status of its instances. Attempt should fail
  * with an appropriate code.
  *
  * @throws Exception
  */
 @Test(groups = {"singleCluster"})
 public void testProcessInstanceStatusKilled() throws Exception {
   bundles[0].setProcessValidity("2010-01-02T01:00Z", "2010-01-02T01:22Z");
   bundles[0].setProcessPeriodicity(5, TimeUnit.minutes);
   bundles[0].submitFeedsScheduleProcess(prism);
   AssertUtil.assertSucceeded(
       prism.getProcessHelper().delete(URLS.DELETE_URL, bundles[0].getProcessData()));
   InstancesResult r =
       prism
           .getProcessHelper()
           .getProcessInstanceStatus(
               Util.readEntityName(bundles[0].getProcessData()),
               "?start=2010-01-02T01:00Z&end=2010-01-02T01:20Z");
   if ((r.getStatusCode() != ResponseKeys.PROCESS_NOT_FOUND)) {
     Assert.assertTrue(false);
   }
 }
 /**
  * Schedule process. Perform -kill action on instances between -start and -end dates which expose
  * range of last 3 instances which have been materialized already and those which should be. Check
  * that only existent instances are killed.
  *
  * @throws Exception
  */
 @Test(groups = {"singleCluster"})
 public void testProcessInstanceKillKillNonMatrelized() throws Exception {
   bundles[0].setProcessValidity("2010-01-02T00:00Z", "2010-01-02T04:00Z");
   bundles[0].setProcessTimeOut(3, TimeUnit.minutes);
   bundles[0].setProcessPeriodicity(1, TimeUnit.minutes);
   bundles[0].setOutputFeedPeriodicity(5, TimeUnit.minutes);
   bundles[0].setOutputFeedLocationData(feedOutputPath);
   bundles[0].setProcessConcurrency(6);
   bundles[0].submitFeedsScheduleProcess(prism);
   TimeUtil.sleepSeconds(TIMEOUT);
   InstancesResult r =
       prism
           .getProcessHelper()
           .getProcessInstanceKill(
               Util.readEntityName(bundles[0].getProcessData()),
               "?start=2010-01-02T00:03Z&end=2010-01-02T00:30Z");
   InstanceUtil.validateResponse(r, 3, 0, 0, 0, 3);
   LOGGER.info(r.toString());
 }
 /**
  * Schedule process. Check that -kill action is not performed when time range between -start and
  * -end parameters is in future and don't include existing instances.
  *
  * @throws Exception
  */
 @Test(groups = {"singleCluster"})
 public void testProcessInstanceKillBothStartAndEndInFuture() throws Exception {
   /*
   both start and end r in future with respect to current time
    */
   bundles[0].setProcessValidity("2010-01-02T01:00Z", "2099-01-02T01:21Z");
   bundles[0].setProcessPeriodicity(5, TimeUnit.minutes);
   bundles[0].setOutputFeedPeriodicity(5, TimeUnit.minutes);
   bundles[0].setOutputFeedLocationData(feedOutputPath);
   bundles[0].setProcessConcurrency(6);
   bundles[0].submitFeedsScheduleProcess(prism);
   String startTime = TimeUtil.getTimeWrtSystemTime(1);
   String endTime = TimeUtil.getTimeWrtSystemTime(40);
   InstancesResult r =
       prism
           .getProcessHelper()
           .getProcessInstanceKill(
               Util.readEntityName(bundles[0].getProcessData()),
               "?start=" + startTime + "&end=" + endTime);
   LOGGER.info(r.getMessage());
   Assert.assertEquals(r.getInstances(), null);
 }