SW360LicenseClientAdapterAsyncImpl implements SW360LicenseClientAdapterAsync { @Override public CompletableFuture<Optional<SW360License>> getLicenseByName(String license) { return optionalFuture(getLicenseClient().getLicenseByName(license)); } SW360LicenseClientAdapterAsyncImpl(SW360LicenseClient client); @Override SW360LicenseClient getLicenseClient(); @Override CompletableFuture<List<SW360SparseLicense>> getLicenses(); @Override CompletableFuture<Optional<SW360License>> getLicenseByName(String license); @Override CompletableFuture<SW360License> enrichSparseLicense(SW360SparseLicense sparseLicense); @Override CompletableFuture<SW360License> createLicense(SW360License license);  }
@Test public void testGetLicenseByName() { SW360License license = prepareLicenseClientGetLicenseByName(); Optional<SW360License> sw360LicenseByAntennaLicense = block(licenseClientAdapter.getLicenseByName(LICENSE_NAME)); assertThat(sw360LicenseByAntennaLicense).isPresent(); assertThat(sw360LicenseByAntennaLicense).hasValue(license); verify(licenseClient, atLeastOnce()).getLicenseByName(LICENSE_NAME); }
@Test public void testGetLicenseByNameUnresolved() { FailedRequestException exception = new FailedRequestException("get_license", HttpConstants.STATUS_ERR_NOT_FOUND); when(licenseClient.getLicenseByName(LICENSE_NAME)) .thenReturn(FutureUtils.failedFuture(exception)); Optional<SW360License> result = block(licenseClientAdapter.getLicenseByName(LICENSE_NAME)); assertThat(result).isEmpty(); }