@Test @SmallTest public void testStopWork_invalidWorkId() { String id = "INVALID_WORK_ID"; assertThat(mProcessor.stopWork(id), is(false)); }
public synchronized boolean stopWork(String id) { Log.d(TAG, String.format("Processor stopping %s", id)); WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id); if (wrapper != null) { wrapper.interrupt(false); Log.d(TAG, String.format("WorkerWrapper stopped for %s", id)); return true; } Log.d(TAG, String.format("WorkerWrapper could not be found for %s", id)); return false; }
Processor implements ExecutionListener { public synchronized boolean stopWork(String id) { Log.d(TAG, String.format("Processor stopping %s", id)); WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id); if (wrapper != null) { wrapper.interrupt(false); Log.d(TAG, String.format("WorkerWrapper stopped for %s", id)); return true; } Log.d(TAG, String.format("WorkerWrapper could not be found for %s", id)); return false; } }
Processor implements ExecutionListener { public synchronized boolean stopWork(String id) { Log.d(TAG, String.format("Processor stopping %s", id)); WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id); if (wrapper != null) { wrapper.interrupt(false); Log.d(TAG, String.format("WorkerWrapper stopped for %s", id)); return true; } Log.d(TAG, String.format("WorkerWrapper could not be found for %s", id)); return false; } Processor(
            Context appContext,
            Configuration configuration,
            WorkDatabase workDatabase,
            List<Scheduler> schedulers,
            Executor executor); }
Processor implements ExecutionListener { public synchronized boolean stopWork(String id) { Log.d(TAG, String.format("Processor stopping %s", id)); WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id); if (wrapper != null) { wrapper.interrupt(false); Log.d(TAG, String.format("WorkerWrapper stopped for %s", id)); return true; } Log.d(TAG, String.format("WorkerWrapper could not be found for %s", id)); return false; } Processor(
            Context appContext,
            Configuration configuration,
            WorkDatabase workDatabase,
            List<Scheduler> schedulers,
            Executor executor); synchronized boolean startWork(String id); synchronized boolean startWork(String id, Extras.RuntimeExtras runtimeExtras); synchronized boolean stopWork(String id); synchronized boolean stopAndCancelWork(String id); synchronized boolean isCancelled(String id); synchronized boolean hasWork(); synchronized boolean isEnqueued(@NonNull String workSpecId); synchronized void addExecutionListener(ExecutionListener executionListener); synchronized void removeExecutionListener(ExecutionListener executionListener); @Override synchronized void onExecuted(
            @NonNull String workSpecId,
            boolean isSuccessful,
            boolean needsReschedule); }
Processor implements ExecutionListener { public synchronized boolean stopWork(String id) { Log.d(TAG, String.format("Processor stopping %s", id)); WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id); if (wrapper != null) { wrapper.interrupt(false); Log.d(TAG, String.format("WorkerWrapper stopped for %s", id)); return true; } Log.d(TAG, String.format("WorkerWrapper could not be found for %s", id)); return false; } Processor(
            Context appContext,
            Configuration configuration,
            WorkDatabase workDatabase,
            List<Scheduler> schedulers,
            Executor executor); synchronized boolean startWork(String id); synchronized boolean startWork(String id, Extras.RuntimeExtras runtimeExtras); synchronized boolean stopWork(String id); synchronized boolean stopAndCancelWork(String id); synchronized boolean isCancelled(String id); synchronized boolean hasWork(); synchronized boolean isEnqueued(@NonNull String workSpecId); synchronized void addExecutionListener(ExecutionListener executionListener); synchronized void removeExecutionListener(ExecutionListener executionListener); @Override synchronized void onExecuted(
            @NonNull String workSpecId,
            boolean isSuccessful,
            boolean needsReschedule);  }