### Question:
LicenseInfoHandler implements LicenseInfoService.Iface { @Override public List<LicenseInfoParsingResult> getLicenseInfoForAttachment(Release release, String attachmentContentId, User user) throws TException { if (release == null) { return Collections.singletonList(noSourceParsingResult(MSG_NO_RELEASE_GIVEN)); } List<LicenseInfoParsingResult> cachedResults = licenseInfoCache.getIfPresent(attachmentContentId); if (cachedResults != null) { return cachedResults; } Attachment attachment = nullToEmptySet(release.getAttachments()).stream() .filter(a -> a.getAttachmentContentId().equals(attachmentContentId)).findFirst().orElseThrow(() -> { String message = String.format( "Attachment selected for license info generation is not found in release's attachments. Release id: %s. Attachment content id: %s", release.getId(), attachmentContentId); return new IllegalStateException(message); }); try { List<LicenseInfoParser> applicableParsers = parsers.stream() .filter(parser -> wrapTException(() -> parser.isApplicableTo(attachment, user, release))).collect(Collectors.toList()); if (applicableParsers.size() == 0) { LOGGER.warn("No applicable parser has been found for the attachment selected for license information"); return assignReleaseToLicenseInfoParsingResult( assignFileNameToLicenseInfoParsingResult( noSourceParsingResult("No applicable parser has been found for the attachment"), attachment.getFilename()), release); } else if (applicableParsers.size() > 1) { LOGGER.info("More than one parser claims to be able to parse attachment with contend id " + attachmentContentId); } List<LicenseInfoParsingResult> results = applicableParsers.stream() .map(parser -> wrapTException(() -> parser.getLicenseInfos(attachment, user, release))).flatMap(Collection::stream) .collect(Collectors.toList()); filterEmptyLicenses(results); results = assignReleaseToLicenseInfoParsingResults(results, release); results = assignComponentToLicenseInfoParsingResults(results, release, user); licenseInfoCache.put(attachmentContentId, results); return results; } catch (WrappedTException exception) { throw exception.getCause(); } } LicenseInfoHandler(); @VisibleForTesting protected  LicenseInfoHandler(AttachmentDatabaseHandler attachmentDatabaseHandler,
                              ComponentDatabaseHandler componentDatabaseHandler, ProjectDatabaseHandler projectDatabaseHandler); @Override LicenseInfoFile getLicenseInfoFile(Project project, User user, String outputGenerator,
                                              Map<String, Set<String>> releaseIdsToSelectedAttachmentIds, Map<String, Set<LicenseNameWithText>> excludedLicensesPerAttachment, String externalIds); @Override List<OutputFormatInfo> getPossibleOutputFormats(); @Override OutputFormatInfo getOutputFormatInfoForGeneratorClass(String generatorClassName); @Override List<LicenseInfoParsingResult> getLicenseInfoForAttachment(Release release, String attachmentContentId, User user); @Override LicenseObligationsStatusInfo getProjectObligationStatus(Map<String, ObligationStatusInfo> obligationStatusMap, List<LicenseInfoParsingResult> licenseResults, 
            Map<String, String> excludedReleaseIdToAcceptedCLI); @Override LicenseInfoParsingResult createLicenseToObligationMapping(LicenseInfoParsingResult licenseResult, ObligationParsingResult obligationResult); @Override List<ObligationParsingResult> getObligationsForAttachment(Release release, String attachmentContentId, User user); @Override String getDefaultLicenseInfoHeaderText(); @Override String getDefaultObligationsText();  }### Answer:
@Test(expected = IllegalStateException.class) public void testThatAttachmentMustBePartOfTheRelease() throws TException { Release release = Mockito.mock(Release.class); handler.getLicenseInfoForAttachment(release, "123", user); }