private Pair<List<String>, List<String>> createTestData(String locationType) throws Exception {
    Configuration conf = cluster.getConf();
    FileSystem fs = FileSystem.get(conf);

    List<String> outOfRange = new ArrayList<String>();
    List<String> inRange = new ArrayList<String>();

    touch(fs, locationType + "/YYYY/feed3/dd/MM/02/more/hello", true);
    touch(fs, locationType + "/YYYY/feed4/dd/MM/02/more/hello", true);
    touch(fs, locationType + "/YYYY/feed1/mmHH/dd/MM/bad-va-lue/more/hello", true);
    touch(fs, locationType + "/somedir/feed1/mmHH/dd/MM/bad-va-lue/more/hello", true);
    outOfRange.add(locationType + "/YYYY/feed3/dd/MM/02/more/hello");
    outOfRange.add(locationType + "/YYYY/feed4/dd/MM/02/more/hello");
    outOfRange.add(locationType + "/YYYY/feed1/mmHH/dd/MM/bad-va-lue/more/hello");
    outOfRange.add(locationType + "/somedir/feed1/mmHH/dd/MM/bad-va-lue/more/hello");

    return Pair.of(inRange, outOfRange);
  }
  private Pair<List<String>, List<String>> createTestData(
      String feed, String mask, int period, TimeUnit timeUnit, String locationType)
      throws Exception {
    Configuration conf = cluster.getConf();
    FileSystem fs = FileSystem.get(conf);

    List<String> outOfRange = new ArrayList<String>();
    List<String> inRange = new ArrayList<String>();

    Pair<List<String>, List<String>> pair = createTestData(locationType);
    outOfRange.addAll(pair.second);
    inRange.addAll(pair.first);

    pair = generateInstances(fs, feed, mask, period, timeUnit, locationType, true);
    outOfRange.addAll(pair.second);
    inRange.addAll(pair.first);
    return Pair.of(inRange, outOfRange);
  }
  private Pair<List<String>, List<String>> generateInstances(
      FileSystem fs,
      String feed,
      String formatString,
      int range,
      TimeUnit timeUnit,
      String locationType,
      boolean generateFiles)
      throws Exception {

    List<String> outOfRange = new ArrayList<String>();
    List<String> inRange = new ArrayList<String>();

    DateFormat format = new SimpleDateFormat(formatString);
    format.setTimeZone(TimeZone.getTimeZone("UTC"));
    long now = System.currentTimeMillis();

    DateFormat displayFormat =
        new SimpleDateFormat(timeUnit == TimeUnit.HOURS ? "yyyyMMddHH" : "yyyyMMdd");
    displayFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    StringBuilder buffer = new StringBuilder();
    for (long date = now; date > now - timeUnit.toMillis(range + 6); date -= timeUnit.toMillis(1)) {
      String path = locationType + "/YYYY/" + feed + "/mmHH/dd/MM/" + format.format(date);
      touch(fs, path, generateFiles);
      if (date <= now && date > now - timeUnit.toMillis(range)) {
        outOfRange.add(path);
      } else {
        inRange.add(path);
        buffer.append((displayFormat.format(date) + "0000").substring(0, 12)).append(',');
      }
    }

    map.put(feed, "instances=" + buffer.substring(0, buffer.length() - 1));
    return Pair.of(inRange, outOfRange);
  }
 private Pair<Date, Date> getDateRange(String period) throws ELException {
   Long duration = (Long) EVALUATOR.evaluate("${" + period + "}", Long.class, RESOLVER, RESOLVER);
   Date end = new Date();
   Date start = new Date(end.getTime() - duration);
   return Pair.of(start, end);
 }