SyncDateBottomSheet extends BaseDialogFragment { public String formatStockCardLastSyncTime(long lastStockCardSyncedTimestamp) { if (lastStockCardSyncedTimestamp == 0) { return presenter.hasStockCardSyncError() ? LMISApp.getContext().getString(R.string.initial_stock_movement_sync_failed) : StringUtils.EMPTY; } return formatLastSyncTime(lastStockCardSyncedTimestamp, R.string.label_stock_card_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 shouldShowStockCardLastSyncedTimeCorrectly() { String formatStockCardLastSyncTimeWithMinute = fragment.formatStockCardLastSyncTime(timeMills - 1 * DateUtil.MILLISECONDS_MINUTE); assertThat(formatStockCardLastSyncTimeWithMinute, equalTo("Stock cards last synced 1 minute ago")); String formatStockCardLastSyncTimeWithMinutes = fragment.formatStockCardLastSyncTime(timeMills - 20 * DateUtil.MILLISECONDS_MINUTE); assertThat(formatStockCardLastSyncTimeWithMinutes, equalTo("Stock cards last synced 20 minutes ago")); String formatStockCardLastSyncTimeWithHour = fragment.formatStockCardLastSyncTime(timeMills - 20 * DateUtil.MILLISECONDS_HOUR); assertThat(formatStockCardLastSyncTimeWithHour, equalTo("Stock cards last synced 20 hours ago")); String formatStockCardLastSyncTimeWithDay = fragment.formatStockCardLastSyncTime(timeMills - 20 * DateUtil.MILLISECONDS_DAY); assertThat(formatStockCardLastSyncTimeWithDay, equalTo("Stock cards last synced 20 days ago")); }