### Question:
RegisteringTimeoutController { static void setTimeout(@NonNull final Context context, @NonNull final String providerName) { OPFLog.logMethod(context, providerName); final long when = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(TIMEOUT_MINUTES); OPFLog.d( "Set registering timeout : %s", SimpleDateFormat.getDateTimeInstance( DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US ).format(new Date(when)) ); final AlarmManager alarmManager = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); final Intent intent = new Intent(context, RetryBroadcastReceiver.class); intent.setAction(ACTION_CHECK_REGISTERING_TIMEOUT); intent.putExtra(EXTRA_PROVIDER_NAME, providerName); alarmManager.set( AlarmManager.RTC, when, PendingIntent.getBroadcast(context, providerName.hashCode(), intent, 0) ); } private  RegisteringTimeoutController();   }### Answer:
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) @Test public void testSetTimeout() { final Context ctx = RuntimeEnvironment.application.getApplicationContext(); final AlarmManager alarmManager = (AlarmManager) RuntimeEnvironment.application.getSystemService(Context.ALARM_SERVICE); final ShadowAlarmManager shadowAlarmManager = shadowOf(alarmManager); final long whenExpected = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(TIMEOUT_MINUTES); RegisteringTimeoutController.setTimeout(ctx, TEST_PROVIDER); final List<ShadowAlarmManager.ScheduledAlarm> alarms = shadowAlarmManager.getScheduledAlarms(); for (ShadowAlarmManager.ScheduledAlarm alarm : alarms) { final PendingIntent operation = alarm.operation; final int creatorUid = operation.getCreatorUid(); if (creatorUid == ctx.getApplicationInfo().uid) { Assert.assertTrue(Math.abs(whenExpected - alarm.triggerAtTime) < TIME_DELTA_MILLISECONDS); return; } } Assert.fail(); }