SyncDateBottomSheet extends BaseDialogFragment { public String formatRnrLastSyncTime(long lastRnrSyncedTimestamp) { if (lastRnrSyncedTimestamp == 0) { return presenter.hasRnrSyncError() ? LMISApp.getContext().getString(R.string.initial_rnr_sync_failed) : StringUtils.EMPTY; } return formatLastSyncTime(lastRnrSyncedTimestamp, R.string.label_rnr_form_last_synced_time_ago); }  @Override Dialog onCreateDialog(Bundle savedInstanceState); @Nullable @Override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState); @Override void onViewCreated(View view, Bundle savedInstanceState); @Override void onStart(); void show(FragmentManager fragmentManager); static Bundle getArgumentsToMe(long rnrLastSyncTime, long stockLastSyncTime); String formatRnrLastSyncTime(long lastRnrSyncedTimestamp); String formatStockCardLastSyncTime(long lastStockCardSyncedTimestamp); static final String RNR_SYNC_TIME; static final String STOCK_SYNC_TIME; }
@Test public void shouldShowRnrFormLastSyncedTimeCorrectly() { String formatRnrLastSyncTimeWithMinute = fragment.formatRnrLastSyncTime(timeMills - 20 * DateUtil.MILLISECONDS_MINUTE); assertThat(formatRnrLastSyncTimeWithMinute, equalTo("Requisition last synced 20 minutes ago")); String formatRnrLastSyncTimeWithHour = fragment.formatRnrLastSyncTime(timeMills - 20 * DateUtil.MILLISECONDS_HOUR); assertThat(formatRnrLastSyncTimeWithHour, equalTo("Requisition last synced 20 hours ago")); String formatRnrLastSyncTimeWithDay = fragment.formatRnrLastSyncTime(timeMills - 1 * DateUtil.MILLISECONDS_DAY); assertThat(formatRnrLastSyncTimeWithDay, equalTo("Requisition last synced 1 day ago")); String formatRnrLastSyncTimeWithDays = fragment.formatRnrLastSyncTime(timeMills - 20 * DateUtil.MILLISECONDS_DAY); assertThat(formatRnrLastSyncTimeWithDays, equalTo("Requisition last synced 20 days ago")); }