### Question:
Alarms { public static void setAlarm( @NonNull Context context, @NonNull WorkManagerImpl workManager, @NonNull String workSpecId, long triggerAtMillis) { WorkDatabase workDatabase = workManager.getWorkDatabase(); SystemIdInfoDao systemIdInfoDao = workDatabase.systemIdInfoDao(); SystemIdInfo systemIdInfo = systemIdInfoDao.getSystemIdInfo(workSpecId); if (systemIdInfo != null) { cancelExactAlarm(context, workSpecId, systemIdInfo.systemId); setExactAlarm(context, workSpecId, systemIdInfo.systemId, triggerAtMillis); } else { IdGenerator idGenerator = new IdGenerator(context); int alarmId = idGenerator.nextAlarmManagerId(); SystemIdInfo newSystemIdInfo = new SystemIdInfo(workSpecId, alarmId); systemIdInfoDao.insertSystemIdInfo(newSystemIdInfo); setExactAlarm(context, workSpecId, alarmId, triggerAtMillis); } } private  Alarms(); static void setAlarm(
            @NonNull Context context,
            @NonNull WorkManagerImpl workManager,
            @NonNull String workSpecId,
            long triggerAtMillis); static void cancelAlarm(
            @NonNull Context context,
            @NonNull WorkManagerImpl workManager,
            @NonNull String workSpecId);  }### Answer:
@Test public void testSetAlarm_withPreExistingAlarms() { OneTimeWorkRequest work = new OneTimeWorkRequest.Builder(TestWorker.class).build(); insertWork(work); String workSpecId = work.getStringId(); SystemIdInfo systemIdInfo = new SystemIdInfo(workSpecId, 1); mDatabase.systemIdInfoDao().insertSystemIdInfo(systemIdInfo); Alarms.setAlarm(mContext, mWorkManager, workSpecId, mTriggerAt); SystemIdInfo updatedSystemIdInfo = mDatabase.systemIdInfoDao().getSystemIdInfo(workSpecId); assertThat(updatedSystemIdInfo, is(notNullValue())); assertThat(updatedSystemIdInfo.systemId, is(systemIdInfo.systemId)); }
@Test public void testSetAlarm_noPreExistingAlarms() { OneTimeWorkRequest work = new OneTimeWorkRequest.Builder(TestWorker.class).build(); insertWork(work); String workSpecId = work.getStringId(); Alarms.setAlarm(mContext, mWorkManager, workSpecId, mTriggerAt); SystemIdInfo systemIdInfo = mDatabase.systemIdInfoDao().getSystemIdInfo(workSpecId); assertThat(systemIdInfo, is(notNullValue())); }