@Test public void whenInstancesChangeLockLocked_doesNotMigrate_andSetsResultInRepository() { instancesChangeLock.lock(); StorageMigrationService service = Robolectric.setupIntentService(StorageMigrationService.class); service.onHandleIntent(null); verifyNoInteractions(storageMigrator); verify(storageMigrationRepository).setResult(StorageMigrationResult.CHANGES_IN_PROGRESS); verify(storageMigrationRepository).markMigrationEnd(); }
@Override protected void onHandleIntent(@Nullable Intent intent) { instancesLock.withLock(acquiredInstancesLock -> { formsLock.withLock(acquiredFormsLock -> { if (acquiredInstancesLock && acquiredFormsLock) { storageMigrator.performStorageMigration(); } else { storageMigrationRepository.setResult(StorageMigrationResult.CHANGES_IN_PROGRESS); storageMigrationRepository.markMigrationEnd(); } return null; }); return null; }); }
StorageMigrationService extends IntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { instancesLock.withLock(acquiredInstancesLock -> { formsLock.withLock(acquiredFormsLock -> { if (acquiredInstancesLock && acquiredFormsLock) { storageMigrator.performStorageMigration(); } else { storageMigrationRepository.setResult(StorageMigrationResult.CHANGES_IN_PROGRESS); storageMigrationRepository.markMigrationEnd(); } return null; }); return null; }); } }
StorageMigrationService extends IntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { instancesLock.withLock(acquiredInstancesLock -> { formsLock.withLock(acquiredFormsLock -> { if (acquiredInstancesLock && acquiredFormsLock) { storageMigrator.performStorageMigration(); } else { storageMigrationRepository.setResult(StorageMigrationResult.CHANGES_IN_PROGRESS); storageMigrationRepository.markMigrationEnd(); } return null; }); return null; }); } StorageMigrationService(); }
StorageMigrationService extends IntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { instancesLock.withLock(acquiredInstancesLock -> { formsLock.withLock(acquiredFormsLock -> { if (acquiredInstancesLock && acquiredFormsLock) { storageMigrator.performStorageMigration(); } else { storageMigrationRepository.setResult(StorageMigrationResult.CHANGES_IN_PROGRESS); storageMigrationRepository.markMigrationEnd(); } return null; }); return null; }); } StorageMigrationService();  }
StorageMigrationService extends IntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { instancesLock.withLock(acquiredInstancesLock -> { formsLock.withLock(acquiredFormsLock -> { if (acquiredInstancesLock && acquiredFormsLock) { storageMigrator.performStorageMigration(); } else { storageMigrationRepository.setResult(StorageMigrationResult.CHANGES_IN_PROGRESS); storageMigrationRepository.markMigrationEnd(); } return null; }); return null; }); } StorageMigrationService();  static final String SERVICE_NAME; }