MainActivityPresenter implements DialogInterface.OnClickListener { long getMillis(String timing) { String[] timeAndUnit = timing.split(" "); String time = timeAndUnit[0]; String unit = timeAndUnit[1]; long millis = 0; if (unit.toLowerCase().equals("min") || unit.toLowerCase().equals("mins")) { millis = TimeUnit.MINUTES.toMillis(Long.valueOf(time)); } else if (unit.toLowerCase().equals("hr") || unit.toLowerCase().equals("hrs")) { millis = TimeUnit.HOURS.toMillis(Long.valueOf(time)); } return millis; } @Inject  MainActivityPresenter(Set<String> activatedPackages, SharedPreferences sharedPreferences,
      Context context, AccessibilityChecker accessibilityChecker); void setView(MainActivityView mainActivityView); void checkAccessibilityEnabled(); void onAppLockActivateClick(); void onTimingClick(String timing); void onWarningTextClick(); void onCreditTextClick(); void onGithubClick(); @Override void onClick(DialogInterface dialog, int which);  }
@Test public void testGetMillis() throws Exception { long millis; millis = mainActivityPresenter.getMillis("1 min"); assertEquals(TimeUnit.MINUTES.toMillis(1), millis); millis = mainActivityPresenter.getMillis("5 mins"); assertEquals(TimeUnit.MINUTES.toMillis(5), millis); millis = mainActivityPresenter.getMillis("1 hr"); assertEquals(TimeUnit.HOURS.toMillis(1), millis); millis = mainActivityPresenter.getMillis("24 hrs"); assertEquals(TimeUnit.HOURS.toMillis(24), millis); }