SW360MetaDataReceiver { public Optional<SW360License> getLicenseDetails(SW360SparseLicense sparseLicense) { try { return Optional.of(licenseClientAdapter.enrichSparseLicense(sparseLicense)); } catch (SW360ClientException e) { LOGGER.debug("Failed to lookup sparse license {}.", sparseLicense.getShortName(), e); return Optional.empty(); } } SW360MetaDataReceiver(SW360Connection sw360ConnectionConfiguration); Optional<SW360Release> findReleaseForArtifact(Artifact artifact); Optional<SW360License> getLicenseDetails(SW360SparseLicense sparseLicense); Optional<Path> downloadAttachment(SW360Release release, SW360SparseAttachment attachment, Path downloadPath);  }
@Test public void testGetLicenseDetails() { SW360SparseLicense sparseLicense = new SW360SparseLicense(); SW360License sw360License = new SW360License(); when(licenseClientAdapter.enrichSparseLicense(sparseLicense)) .thenReturn(sw360License); setUp(); Optional<SW360License> licenseDetails = metaDataReceiver.getLicenseDetails(sparseLicense); assertThat(licenseDetails).hasValue(sw360License); verify(licenseClientAdapter, times(1)).enrichSparseLicense(sparseLicense); }
@Test public void testGetLicenseDetailsException() { SW360SparseLicense license = new SW360SparseLicense().setShortName("foo"); when(licenseClientAdapter.enrichSparseLicense(license)) .thenThrow(new SW360ClientException("License lookup failed")); setUp(); Optional<SW360License> licenseDetails = metaDataReceiver.getLicenseDetails(license); assertThat(licenseDetails).isEmpty(); }