### Question:
CLILicensePresenter implements LicensePresenter { public void presentLicenses(boolean preAccept) { LicenseSet licenses = licenseModule.getRequiredLicenses(); if (preAccept) { licenses.acceptAll(); } else { for (License license : licenses) { if (license.isAccepted()) { continue; } user.show(""); user.show(license.getLicenseText()); String input = user.ask("prompt"); if (input != null && YES.startsWith(input.toLowerCase())) { license.accept(); } else { license.reject(); } } } } @Inject  CLILicensePresenter(LicenseLocator licenseModule, User user); void presentLicenses(boolean preAccept); String getNotice();  }### Answer:
@Test public void acceptLicensesWhenPreAccepted() { LicensePresenter manager = new CLILicensePresenter(locator, user); boolean error = false; try { manager.presentLicenses(true); } catch (LicenseRejectedException lre) { error = true; } assertFalse(error); }
@Test public void acceptLicensesWhenUserInput() { given(user.ask(anyString())).willReturn("y"); LicensePresenter manager = new CLILicensePresenter(locator, user); boolean error = false; try { manager.presentLicenses(false); } catch (LicenseRejectedException lre) { error = true; } assertFalse(error); }
@Test public void presentLicensesErrorsWhenNotAcceptLicense() { given(user.ask(anyString())).willReturn("no"); LicensePresenter manager = new CLILicensePresenter(locator, user); boolean error = false; try { manager.presentLicenses(false); } catch (LicenseRejectedException lre) { error = true; } assertTrue(error); }