Java Code Examples for org.joda.time.LocalDateTime#now()

The following examples show how to use org.joda.time.LocalDateTime#now() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Task_Test.java    From estatio with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    partyRoleType = PartyRoleType.builder().key("PROJECT_MANAGER").build();
    person = Person.builder().username("[email protected]").build();
    task1 = new Task(partyRoleType, person, "Feed the cat", LocalDateTime.now().minusWeeks(2), "cat.Cat", null) {
        @Override
        void appendTitleOfObject(final StringBuilder buf) {
            buf.append("Tiddles");
        }
    };
    task2 = new Task(partyRoleType, person, "Feed the dog", LocalDateTime.now().minusWeeks(1), "dog.Dog", null) {
        @Override
        void appendTitleOfObject(final StringBuilder buf) {
            buf.append("Spot");
        }
    };
    task3 = new Task(partyRoleType, person, "Feed the parrot", LocalDateTime.now(), "parrot.Parrot", null) {
        @Override
        void appendTitleOfObject(final StringBuilder buf) {
            buf.append("Lory");
        }
    };
}
 
Example 2
Source File: TimeAwareRecursiveCopyableDataset.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
public TimeAwareRecursiveCopyableDataset(FileSystem fs, Path rootPath, Properties properties, Path glob) {
  super(fs, rootPath, properties, glob);
  this.lookbackTime = properties.getProperty(LOOKBACK_TIME_KEY);
  PeriodFormatter periodFormatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
  this.lookbackPeriod = periodFormatter.parsePeriod(lookbackTime);
  this.datePattern = properties.getProperty(DATE_PATTERN_KEY);
  this.isPatternMinutely = isDatePatternMinutely(datePattern);
  this.isPatternHourly = !this.isPatternMinutely && isDatePatternHourly(datePattern);
  this.isPatternDaily = !this.isPatternMinutely && !this.isPatternHourly;
  this.currentTime = properties.containsKey(DATE_PATTERN_TIMEZONE_KEY) ? LocalDateTime.now(
      DateTimeZone.forID(DATE_PATTERN_TIMEZONE_KEY))
      : LocalDateTime.now(DateTimeZone.forID(DEFAULT_DATE_PATTERN_TIMEZONE));

  if (this.isPatternDaily) {
    Preconditions.checkArgument(isLookbackTimeStringDaily(this.lookbackTime), "Expected day format for lookback time; found hourly or minutely format");
    pattern = DatePattern.DAILY;
  } else if (this.isPatternHourly) {
    Preconditions.checkArgument(isLookbackTimeStringHourly(this.lookbackTime), "Expected hourly format for lookback time; found minutely format");
    pattern = DatePattern.HOURLY;
  } else {
    pattern = DatePattern.MINUTELY;
  }
}
 
Example 3
Source File: JodaTimeHelperTest.java    From SimpleFlatMapper with MIT License 6 votes vote down vote up
@Test
public void testGetFormattersAndDefaultFormat() {
    LocalDateTime localDateTime = LocalDateTime.now();
    assertEquals(DateTimeFormat.forPattern("yyyy").print(localDateTime),JodaTimeHelper.getDateTimeFormatters(new DefaultDateFormatSupplier() {
        @Override
        public String get() {
            return "yyyy";
        }
    })[0].print(localDateTime));

    DateTimeFormatter[] dateTimeFormatters = JodaTimeHelper.getDateTimeFormatters(new DefaultDateFormatSupplier() {
        @Override
        public String get() {
            return "yyyy";
        }
    }, DateTimeFormat.fullDate());
    assertEquals(1, dateTimeFormatters.length);
    assertEquals(DateTimeFormat.fullDate().print(localDateTime), dateTimeFormatters[0].print(localDateTime));
}
 
Example 4
Source File: JodaTimeHelperTest.java    From SimpleFlatMapper with MIT License 6 votes vote down vote up
@Test
public void testGetFormatterAndDefaultFormat() {
    LocalDateTime localDateTime = LocalDateTime.now();

    assertEquals(DateTimeFormat.forPattern("yyyy").print(localDateTime),JodaTimeHelper.getDateTimeFormatter(new DefaultDateFormatSupplier() {
        @Override
        public String get() {
            return "yyyy";
        }
    }).print(localDateTime));

    assertEquals(DateTimeFormat.fullDate().print(localDateTime) ,JodaTimeHelper.getDateTimeFormatter(new DefaultDateFormatSupplier() {
        @Override
        public String get() {
            return "yyyy";
        }
    }, DateTimeFormat.fullDate()).print(localDateTime));
}
 
Example 5
Source File: Times.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
public boolean isKerahat() {
    LocalDateTime now = LocalDateTime.now();

    int untilSun = new Period(getTime(now.toLocalDate(), Vakit.SUN.ordinal()), now, PeriodType.minutes()).getMinutes();
    if (untilSun >= 0 && untilSun < Preferences.KERAHAT_SUNRISE.get()) {
        return true;
    }

    int untilDhuhr = new Period(now, getTime(now.toLocalDate(), Vakit.DHUHR.ordinal()), PeriodType.minutes()).getMinutes();
    if ((untilDhuhr >= 0) && (untilDhuhr < (Preferences.KERAHAT_ISTIWA.get()))) {
        return true;
    }

    int untilMaghrib = new Period(now, getTime(now.toLocalDate(), Vakit.MAGHRIB.ordinal()), PeriodType.minutes()).getMinutes();
    return (untilMaghrib >= 0) && (untilMaghrib < (Preferences.KERAHAT_SUNSET.get()));
}
 
Example 6
Source File: Utils.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static boolean checkIfExpired(String time) {
	if (time == null || time.length() == 0)	return false;
	
	LocalDateTime now = LocalDateTime.now();
	LocalDateTime exp = LocalDateTime.parse(time, DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"));
	return exp.isBefore(now);
}
 
Example 7
Source File: AlarmCore.java    From skywalking with Apache License 2.0 5 votes vote down vote up
public void start(List<AlarmCallback> allCallbacks) {
    LocalDateTime now = LocalDateTime.now();
    lastExecuteTime = now;
    Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(() -> {
        try {
            List<AlarmMessage> alarmMessageList = new ArrayList<>(30);
            LocalDateTime checkTime = LocalDateTime.now();
            int minutes = Minutes.minutesBetween(lastExecuteTime, checkTime).getMinutes();
            boolean[] hasExecute = new boolean[] {false};
            alarmRulesWatcher.getRunningContext().values().forEach(ruleList -> ruleList.forEach(runningRule -> {
                if (minutes > 0) {
                    runningRule.moveTo(checkTime);
                    /*
                     * Don't run in the first quarter per min, avoid to trigger false alarm.
                     */
                    if (checkTime.getSecondOfMinute() > 15) {
                        hasExecute[0] = true;
                        alarmMessageList.addAll(runningRule.check());
                    }
                }
            }));
            // Set the last execute time, and make sure the second is `00`, such as: 18:30:00
            if (hasExecute[0]) {
                lastExecuteTime = checkTime.minusSeconds(checkTime.getSecondOfMinute());
            }

            if (alarmMessageList.size() > 0) {
                allCallbacks.forEach(callback -> callback.doAlarm(alarmMessageList));
            }
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }, 10, 10, TimeUnit.SECONDS);
}
 
Example 8
Source File: Utils.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static boolean checkIfExpired(String time) {
	if (time == null || time.length() == 0)	return false;
	
	LocalDateTime now = LocalDateTime.now();
	LocalDateTime exp = LocalDateTime.parse(time, DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"));
	return exp.isBefore(now);
}
 
Example 9
Source File: CsvMapperFactoryDefaultValueTest.java    From SimpleFlatMapper with MIT License 5 votes vote down vote up
@Test
public void testDefaultValueJodaDateTime() throws IOException {
	LocalDateTime localDateTime = LocalDateTime.now();
	final Tuple2<String, LocalDateTime> value =
			CsvMapperFactory
					.newInstance()
					.addColumnProperty("element1", new DefaultValueProperty<LocalDateTime>(localDateTime))
					.newMapper(new TypeReference<Tuple2<String, LocalDateTime>>() {
					})
					.iterator(CsvParser.reader("element0\nv0"))
					.next();
	assertEquals("v0", value.getElement0());
	assertEquals(localDateTime, value.getElement1());
}
 
Example 10
Source File: ProgressThread.java    From actframework with Apache License 2.0 5 votes vote down vote up
void refresh() {
    consoleStream.print("\r");

    LocalDateTime currTime = LocalDateTime.now();
    Duration elapsed = new Duration(progress.startTime.toDateTime(DateTimeZone.UTC), currTime.toDateTime(DateTimeZone.UTC));

    String prefix = progress.task + " " + percentage() + " " + style.leftBracket;

    int maxSuffixLength = Math.max(0, consoleWidth - consoleRightMargin - prefix.length() - 10);
    String suffix = style.rightBracket + " " + ratio() + " (" + Util.formatDuration(elapsed) + " / " + eta(elapsed) + ") " + progress.extraMessage;
    if (suffix.length() > maxSuffixLength) suffix = suffix.substring(0, maxSuffixLength);

    length = consoleWidth - consoleRightMargin - prefix.length() - suffix.length();

    StringBuilder sb = new StringBuilder();
    sb.append(prefix);

    // case of indefinite progress bars
    if (progress.indefinite) {
        int pos = (int)(progress.current % length);
        sb.append(Util.repeat(style.space, pos));
        sb.append(style.block);
        sb.append(Util.repeat(style.space, length - pos - 1));
    }
    // case of definite progress bars
    else {
        sb.append(Util.repeat(style.block, progressIntegralPart()));
        if (progress.current < progress.max) {
            sb.append(style.fractionSymbols.charAt(progressFractionalPart()));
            sb.append(Util.repeat(style.space, length - progressIntegralPart() - 1));
        }
    }
    sb.append(suffix);
    String line = sb.toString();

    consoleStream.print(line);
}
 
Example 11
Source File: Task_title_Test.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    partyRoleType = PartyRoleType.builder().key("PROJECT_MANAGER").build();
    person = Person.builder().username("[email protected]").build();
    task = new Task(partyRoleType, person, "Feed the cat", LocalDateTime.now(), "cat.Cat", null) {
        @Override
        void appendTitleOfObject(final StringBuilder buf) {
            buf.append("Tiddles");
        }
    };
}
 
Example 12
Source File: UnixTimestampRecursiveCopyableDataset.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
public UnixTimestampRecursiveCopyableDataset(FileSystem fs, Path rootPath, Properties properties, Path glob) {
  super(fs, rootPath, properties, glob);
  this.lookbackTime = properties.getProperty(TimeAwareRecursiveCopyableDataset.LOOKBACK_TIME_KEY);
  this.versionSelectionPolicy =
      VersionSelectionPolicy.valueOf(properties.getProperty(VERSION_SELECTION_POLICY).toUpperCase());
  PeriodFormatter periodFormatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d").toFormatter();
  this.lookbackPeriod = periodFormatter.parsePeriod(lookbackTime);
  String timestampRegex = properties.getProperty(TIMESTAMP_REGEEX, DEFAULT_TIMESTAMP_REGEX);
  this.timestampPattern = Pattern.compile(timestampRegex);
  this.dateTimeZone = DateTimeZone.forID(properties
      .getProperty(TimeAwareRecursiveCopyableDataset.DATE_PATTERN_TIMEZONE_KEY,
          TimeAwareRecursiveCopyableDataset.DEFAULT_DATE_PATTERN_TIMEZONE));
  this.currentTime = LocalDateTime.now(this.dateTimeZone);
}
 
Example 13
Source File: EnforceTaskAssignmentPolicySubscriber_applyPolicy_Test.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    subscriber = new EnforceTaskAssignmentPolicySubscriber();
    subscriber.stateTransitionService = mockStateTransitionService;
    subscriber.personRepository = mockPersonRepository;
    subscriber.metaModelService3 = mockMetaModelService3;
    subscriber.partyRoleTypeRepository = mockPartyRoleTypeRepository;

    domainObject = new BankAccount();
    stateTransitionClass = BankAccountVerificationStateTransition.class;
    pendingTransition = new BankAccountVerificationStateTransition();
    personTaskAssignedTo = new Person();
    personTaskAssignedTo.setReference("JBLOGGS");
    roleTaskAssignedTo = new PartyRoleType();
    roleTaskAssignedTo.setKey("Treasurer");
    previousRoleTaskAssignedTo = new PartyRoleType();
    previousRoleTaskAssignedTo.setKey("INCOMING_INVOICE_MANAGER");

    pendingTask = new Task(
            roleTaskAssignedTo, personTaskAssignedTo,
            "some description", LocalDateTime.now(),
            "bankAccount.BankAccountVerificationStateTransition", // objectType of transition class
            null
    );

    pendingTransition.setTask(pendingTask);

    personForMe = new Person();
    personForMe.getRoles().add(new PartyRole(personForMe, roleTaskAssignedTo));

    assertThat(pendingTransition.getTask()).isNotNull();
    assertThat(personForMe.getRoles()).isNotEmpty();
    assertThat(Lists.newArrayList(personForMe.getRoles()).stream().map(PartyRole::getRoleType))
            .contains(roleTaskAssignedTo);

}
 
Example 14
Source File: WidgetLegacy.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
static void update1x1(Context context, AppWidgetManager appWidgetManager, int widgetId) {
    Resources r = context.getResources();
    float dp = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, r.getDisplayMetrics());

    LocalDateTime now = LocalDateTime.now();
    LocalDate today = now.toLocalDate();

    Theme theme = WidgetUtils.getTheme(widgetId);
    Times times = WidgetUtils.getTimes(widgetId);
    if (times == null) {
        WidgetUtils.showNoCityWidget(context, appWidgetManager, widgetId);
        return;
    }

    WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 1f);
    int s = size.width;
    if (s <= 0)
        return;
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.vakit_widget);

    int next = times.getNextTime();
    String left = LocaleUtils.formatPeriod(now, times.getTime(today, next), false);
    if (Preferences.VAKIT_INDICATOR_TYPE.get().equals("next"))
        next = next + 1;

    remoteViews.setOnClickPendingIntent(R.id.widget, TimesFragment.getPendingIntent(times));

    Bitmap bmp = Bitmap.createBitmap(s, s, Bitmap.Config.ARGB_4444);
    Canvas canvas = new Canvas(bmp);
    canvas.scale(0.99f, 0.99f, s / 2f, s / 2f);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setDither(true);
    paint.setFilterBitmap(true);

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(theme.bgcolor);
    canvas.drawRect(0, 0, s, s, paint);

    paint.setColor(theme.textcolor);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    paint.setAntiAlias(true);
    paint.setSubpixelText(true);

    paint.setColor(theme.hovercolor);

    String city = times.getName();

    paint.setColor(theme.textcolor);

    float cs = s / 5f;
    float ts = (s * 35) / 100f;
    int vs = s / 4;
    paint.setTextSize(cs);
    cs = (cs * s * 0.9f) / paint.measureText(city);
    cs = (cs > vs) ? vs : cs;

    paint.setTextSize(vs);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(Vakit.getByIndex(next).prevTime().getString(), s / 2f, (s * 22) / 80f, paint);

    paint.setTextSize(ts);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(left, s / 2f, (s / 2f) + ((ts * 1) / 3), paint);

    paint.setTextSize(cs);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(city, s / 2f, ((s * 3) / 4f) + ((cs * 2) / 3), paint);

    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(dp);
    paint.setColor(theme.strokecolor);
    canvas.drawRect(0, 0, s, s, paint);

    remoteViews.setImageViewBitmap(R.id.widget, bmp);

    try {
        appWidgetManager.updateAppWidget(widgetId, remoteViews);
    } catch (RuntimeException e) {
        if (!e.getMessage().contains("exceeds maximum bitmap memory usage")) {
            Crashlytics.logException(e);
        }
    }
}
 
Example 15
Source File: PumpStatus.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setLastCommunicationToNow() {
    this.lastDataTime = LocalDateTime.now();
    this.lastConnection = System.currentTimeMillis();
}
 
Example 16
Source File: WidgetLegacy.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
static void update1x1(Context context, AppWidgetManager appWidgetManager, int widgetId) {
    Resources r = context.getResources();
    float dp = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, r.getDisplayMetrics());

    LocalDateTime now = LocalDateTime.now();
    LocalDate today = now.toLocalDate();

    Theme theme = WidgetUtils.getTheme(widgetId);
    Times times = WidgetUtils.getTimes(widgetId);
    if (times == null) {
        WidgetUtils.showNoCityWidget(context, appWidgetManager, widgetId);
        return;
    }

    WidgetUtils.Size size = WidgetUtils.getSize(context, appWidgetManager, widgetId, 1f);
    int s = size.width;
    if (s <= 0)
        return;
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.vakit_widget);

    int next = times.getNextTime();
    String left = LocaleUtils.formatPeriod(now, times.getTime(today, next), false);
    if (Preferences.VAKIT_INDICATOR_TYPE.get().equals("next"))
        next = next + 1;

    remoteViews.setOnClickPendingIntent(R.id.widget, TimesFragment.getPendingIntent(times));

    Bitmap bmp = Bitmap.createBitmap(s, s, Bitmap.Config.ARGB_4444);
    Canvas canvas = new Canvas(bmp);
    canvas.scale(0.99f, 0.99f, s / 2f, s / 2f);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setDither(true);
    paint.setFilterBitmap(true);

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(theme.bgcolor);
    canvas.drawRect(0, 0, s, s, paint);

    paint.setColor(theme.textcolor);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    paint.setAntiAlias(true);
    paint.setSubpixelText(true);

    paint.setColor(theme.hovercolor);

    String city = times.getName();

    paint.setColor(theme.textcolor);

    float cs = s / 5f;
    float ts = (s * 35) / 100f;
    int vs = s / 4;
    paint.setTextSize(cs);
    cs = (cs * s * 0.9f) / paint.measureText(city);
    cs = (cs > vs) ? vs : cs;

    paint.setTextSize(vs);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(Vakit.getByIndex(next).prevTime().getString(), s / 2f, (s * 22) / 80f, paint);

    paint.setTextSize(ts);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(left, s / 2f, (s / 2f) + ((ts * 1) / 3), paint);

    paint.setTextSize(cs);
    paint.setTextAlign(Paint.Align.CENTER);
    canvas.drawText(city, s / 2f, ((s * 3) / 4f) + ((cs * 2) / 3), paint);

    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(dp);
    paint.setColor(theme.strokecolor);
    canvas.drawRect(0, 0, s, s, paint);

    remoteViews.setImageViewBitmap(R.id.widget, bmp);

    try {
        appWidgetManager.updateAppWidget(widgetId, remoteViews);
    } catch (RuntimeException e) {
        if (!e.getMessage().contains("exceeds maximum bitmap memory usage")) {
            Crashlytics.logException(e);
        }
    }
}
 
Example 17
Source File: JodaLocalDateTimeCodec.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
protected LocalDateTime now() {
    return LocalDateTime.now();
}
 
Example 18
Source File: JodaLocalDateTimeTsGenerator.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public LocalDateTime now() {
    return LocalDateTime.now();
}
 
Example 19
Source File: ProgressBar.java    From actframework with Apache License 2.0 4 votes vote down vote up
/**
 * Starts this progress bar.
 */
public ProgressBar start() {
    progress.startTime = LocalDateTime.now();
    thread.start();
    return this;
}
 
Example 20
Source File: UnixTimestampRecursiveCopyableDatasetTest.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@Test(enabled = false)
public void testGetFilesAtPath()
    throws IOException {
  //1570544993735-PT-499913495

  LocalDateTime endDate =
      LocalDateTime.now(DateTimeZone.forID(TimeAwareRecursiveCopyableDataset.DEFAULT_DATE_PATTERN_TIMEZONE));

  for (int i = 0; i < MAX_NUM_DAILY_DIRS; i++) {
    for (int j = 0; j < NUM_DIRS_PER_DAY; j++) {
      Path subDirPath =
          new Path(baseSrcDir, new Path(endDate.toDateTime().plusSeconds(60).getMillis() + "-PT-100000"));
      fs.mkdirs(subDirPath);
      for (int k = 0; k < NUM_FILES_PER_DIR; k++) {
        Path filePath = new Path(subDirPath, k + ".avro");
        fs.create(filePath);
      }
      endDate = endDate.minusMinutes(10);
    }
    endDate = endDate.minusDays(1);
  }

  PathFilter ACCEPT_ALL_PATH_FILTER = new PathFilter() {

    @Override
    public boolean accept(Path path) {
      return true;
    }
  };

  //
  // Test db level copy, Qualifying Regex: ".*([0-9]{13})-PT-.*/.*", dataset root = /tmp/src/databaseName
  //
  Properties properties = new Properties();
  properties.setProperty("gobblin.dataset.pattern", sourceDir);
  properties.setProperty(TimeAwareRecursiveCopyableDataset.DATE_PATTERN_TIMEZONE_KEY,
      TimeAwareRecursiveCopyableDataset.DEFAULT_DATE_PATTERN_TIMEZONE);
  properties.setProperty(TimeAwareRecursiveCopyableDataset.LOOKBACK_TIME_KEY, NUM_LOOKBACK_DAYS_STR);
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.VERSION_SELECTION_POLICY, "ALL");
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.TIMESTAMP_REGEEX, ".*/([0-9]{13})-PT-.*/.*");

  UnixTimestampCopyableDatasetFinder finder = new UnixTimestampCopyableDatasetFinder(fs, properties);

  // Snap shot selection policy = ALL
  String datasetRoot = rootPath + "/" + databaseName;
  UnixTimestampRecursiveCopyableDataset dataset = (UnixTimestampRecursiveCopyableDataset) finder.datasetAtPath(new Path(datasetRoot));
  List<FileStatus> fileStatusList = dataset.getFilesAtPath(fs, baseSrcDir, ACCEPT_ALL_PATH_FILTER);
  Assert.assertTrue(fileStatusList.size() == 30);

  // version selection policy = EARLIEST
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.VERSION_SELECTION_POLICY, "EARLIEST");
  finder = new UnixTimestampCopyableDatasetFinder(fs, properties);
  dataset = (UnixTimestampRecursiveCopyableDataset) finder.datasetAtPath(new Path(datasetRoot));
  fileStatusList = dataset.getFilesAtPath(fs, baseSrcDir, ACCEPT_ALL_PATH_FILTER);
  Assert.assertTrue(fileStatusList.size() == 6);

  // version selection policy = LATEST
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.VERSION_SELECTION_POLICY, "latest");
  finder = new UnixTimestampCopyableDatasetFinder(fs, properties);
  dataset = (UnixTimestampRecursiveCopyableDataset) finder.datasetAtPath(new Path(datasetRoot));
  fileStatusList = dataset.getFilesAtPath(fs, baseSrcDir, ACCEPT_ALL_PATH_FILTER);
  Assert.assertTrue(fileStatusList.size() == 6);

  //
  // Test table level copy, Qualifying Regex: ".*/([0-9]{13})-PT-.*/.*")\, dataset root = /tmp/src/databaseName/tableName
  //
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.TIMESTAMP_REGEEX, "([0-9]{13})-PT-.*/.*");
  finder = new UnixTimestampCopyableDatasetFinder(fs, properties);
  datasetRoot = rootPath + "/" + databaseName + "/" + tableName;

  // Snap shot selection policy = ALL
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.VERSION_SELECTION_POLICY, "ALL");
  dataset = (UnixTimestampRecursiveCopyableDataset) finder.datasetAtPath(new Path(datasetRoot));
  fileStatusList = dataset.getFilesAtPath(fs, baseSrcDir, ACCEPT_ALL_PATH_FILTER);
  Assert.assertTrue(fileStatusList.size() == 30);

  // Snap shot selection policy = EARLIEST
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.VERSION_SELECTION_POLICY, "EARLIEST");
  finder = new UnixTimestampCopyableDatasetFinder(fs, properties);
  dataset = (UnixTimestampRecursiveCopyableDataset) finder.datasetAtPath(new Path(datasetRoot));
  fileStatusList = dataset.getFilesAtPath(fs, baseSrcDir, ACCEPT_ALL_PATH_FILTER);
  Assert.assertTrue(fileStatusList.size() == 6);

  // Snap shot selection policy = LATEST
  properties.setProperty(UnixTimestampRecursiveCopyableDataset.VERSION_SELECTION_POLICY, "latest");
  finder = new UnixTimestampCopyableDatasetFinder(fs, properties);
  dataset = (UnixTimestampRecursiveCopyableDataset) finder.datasetAtPath(new Path(datasetRoot));
  fileStatusList = dataset.getFilesAtPath(fs, baseSrcDir, ACCEPT_ALL_PATH_FILTER);
  Assert.assertTrue(fileStatusList.size() == 6);

}