### Question:
PersistentLicenseLocator implements LicenseLocator { public LicenseSet getRequiredLicenses() { List<License> licenses = new ArrayList<License>(); for (License license : delegate.getRequiredLicenses()) { License persistentLicense = new PersistentLicense(log, license, username); licenses.add(persistentLicense); } return new LicenseSet(licenses); } PersistentLicenseLocator(LicenseLocator delegate, LicenseLog log, String username); LicenseSet getRequiredLicenses();  }### Answer:
@Test public void shouldReturnEqualLicenseSet() { LicenseSet originalLicenses = new LicenseSet(asList(new License("aaa", "aaa"), new License("bbb", "bbb"))); given(mockLocator.getRequiredLicenses()).willReturn(originalLicenses); LicenseSet result = testLocator.getRequiredLicenses(); assertEquals(result, originalLicenses); }
@Test public void shouldLogLicenseAcceptance() { License one = new License("aaa", "aaa"); License two = new License("bbb", "bbb"); LicenseSet originalLicenses = new LicenseSet(asList(one, two)); given(mockLocator.getRequiredLicenses()).willReturn(originalLicenses); LicenseSet result = testLocator.getRequiredLicenses(); result.acceptAll(); one.accept(); two.accept(); verify(mockLog).logLicenseAccepted(eq(one), eq(USER), any(Date.class)); verify(mockLog).logLicenseAccepted(eq(two), eq(USER), any(Date.class)); }
@Test public void shouldCheckLogForAcceptance() { License l = new License("aaa", "aaa"); LicenseSet originalLicense = new LicenseSet(asList(l)); given(mockLocator.getRequiredLicenses()).willReturn(originalLicense); given(mockLog.isLicenseAccepted(l, USER)).willReturn(true); LicenseSet result = testLocator.getRequiredLicenses(); boolean accepted = result.isAccepted(); verify(mockLog).isLicenseAccepted(l, USER); assertTrue(accepted); }