### Question:
WorkConstraintsTracker implements ConstraintController.OnConstraintUpdatedCallback { @Override public void onConstraintMet(@NonNull List<String> workSpecIds) { List<String> unconstrainedWorkSpecIds = new ArrayList<>(); for (String workSpecId : workSpecIds) { if (areAllConstraintsMet(workSpecId)) { Log.d(TAG, String.format("Constraints met for %s", workSpecId)); unconstrainedWorkSpecIds.add(workSpecId); } } if (mCallback != null) { mCallback.onAllConstraintsMet(unconstrainedWorkSpecIds); } } WorkConstraintsTracker(Context context, @Nullable WorkConstraintsCallback callback); @VisibleForTesting  WorkConstraintsTracker(
            @Nullable WorkConstraintsCallback callback,
            ConstraintController[] controllers); void replace(@NonNull List<WorkSpec> workSpecs); void reset(); boolean areAllConstraintsMet(@NonNull String workSpecId); @Override void onConstraintMet(@NonNull List<String> workSpecIds); @Override void onConstraintNotMet(@NonNull List<String> workSpecIds);  }### Answer:
@Test public void testOnConstraintMet_controllerInvoked() { mWorkConstraintsTracker.onConstraintMet(TEST_WORKSPEC_IDS); for (String id : TEST_WORKSPEC_IDS) { verify(mMockController).isWorkSpecConstrained(id); } }
@Test public void testOnConstraintMet_allConstraintsMet() { when(mMockController.isWorkSpecConstrained(any(String.class))).thenReturn(false); mWorkConstraintsTracker.onConstraintMet(TEST_WORKSPEC_IDS); assertThat(mUnconstrainedWorkSpecIds, is(TEST_WORKSPEC_IDS)); }
@Test public void testOnConstraintMet_allConstraintsMet_subList() { when(mMockController.isWorkSpecConstrained(TEST_WORKSPEC_IDS.get(0))).thenReturn(true); when(mMockController.isWorkSpecConstrained(TEST_WORKSPEC_IDS.get(1))).thenReturn(false); when(mMockController.isWorkSpecConstrained(TEST_WORKSPEC_IDS.get(2))).thenReturn(false); mWorkConstraintsTracker.onConstraintMet(TEST_WORKSPEC_IDS); assertThat(mUnconstrainedWorkSpecIds, containsInAnyOrder(TEST_WORKSPEC_IDS.get(1), TEST_WORKSPEC_IDS.get(2))); }
@Test public void testOnConstraintMet_allConstraintsNotMet() { when(mMockController.isWorkSpecConstrained(any(String.class))).thenReturn(true); mWorkConstraintsTracker.onConstraintMet(TEST_WORKSPEC_IDS); assertThat(mUnconstrainedWorkSpecIds, is(empty())); }