### Question:
PillDetailsFragment extends DeviceDetailsFragment<SleepPillDevice> { private boolean shouldShowReplaceBatteryAction() { return device.hasRemovableBattery(); }  static PillDetailsFragment newInstance(@NonNull SleepPillDevice device); @Override void onCreate(Bundle savedInstanceState); @Override void onViewCreated(View view, Bundle savedInstanceState); @Override void onActivityResult(int requestCode, int resultCode, Intent data); void updateFirmware(); void replaceDevice(); void replaceBattery(); void showAdvancedOptions();  }### Answer:
@Test public void shouldShowReplaceBatteryAction() throws Exception { final SleepPillDevice testPill = createMockPill(); doReturn(true).when(testPill).hasRemovableBattery(); final PillDetailsFragment fragment = setUpWith(testPill); verify(fragment).addDeviceAction(eq(R.drawable.icon_battery_24), eq(R.string.action_replace_battery), any()); }