@Test
public void testTaskShowsErrorMessageAndFailsIfUninstallFailed() throws Throwable {

  when(myChecker.getInstalledIotLauncherApps(myEmbeddedDevice)).thenReturn(Collections.singleton(OTHER_PACKAGE_NAME));
  // Answer "Yes" to "Do you want to uninstall packages?"
  when(myPrompt.showQuestionPrompt(Mockito.anyString())).thenReturn(true);
  when(myEmbeddedDevice.uninstallPackage(OTHER_PACKAGE_NAME)).thenThrow(new InstallException("Error"));
  UninstallIotLauncherAppsTask task = new UninstallIotLauncherAppsTask(PACKAGE_NAME, myChecker, myPrompt);
  assertFalse(task.run(myExecutor, myEmbeddedDevice, myLaunchStatus, myPrinter).getSuccess());
  verify(myPrompt).showErrorMessage(Mockito.anyString());
}