### Question:
CLIParser extends AbstractCLIParser { @Override public <T> List<LicenseInfoParsingResult> getLicenseInfos(Attachment attachment, User user, T context) throws TException { AttachmentContent attachmentContent = attachmentContentProvider.getAttachmentContent(attachment); LicenseInfo licenseInfo = new LicenseInfo().setFilenames(Arrays.asList(attachmentContent.getFilename())); LicenseInfoParsingResult result = new LicenseInfoParsingResult().setLicenseInfo(licenseInfo); InputStream attachmentStream = null; try { attachmentStream = attachmentConnector.getAttachmentStream(attachmentContent, user, context); Document doc = getDocument(attachmentStream); Set<String> copyrights = getCopyrights(doc); licenseInfo.setCopyrights(copyrights); licenseInfo.setLicenseNamesWithTexts(getLicenseNameWithTexts(doc)); licenseInfo.setSha1Hash(getSha1Hash(doc)); licenseInfo.setComponentName(getComponent(doc)); result.setAttachmentContentId(attachment.getAttachmentContentId()); result.setStatus(LicenseInfoRequestStatus.SUCCESS); } catch (ParserConfigurationException | IOException | XPathExpressionException | SAXException | SW360Exception e) { log.error(e); result.setStatus(LicenseInfoRequestStatus.FAILURE).setMessage("Error while parsing CLI file: " + e.toString()); } finally { closeQuietly(attachmentStream, log); } return Collections.singletonList(result); } CLIParser(AttachmentConnector attachmentConnector, AttachmentContentProvider attachmentContentProvider); @Override boolean isApplicableTo(Attachment attachment, User user, T context); @Override List<LicenseInfoParsingResult> getLicenseInfos(Attachment attachment, User user, T context); @Override ObligationParsingResult getObligations(Attachment attachment, User user, T context);  }### Answer:
@Test public void testGetCLIFailsOnMalformedXML() throws Exception { Attachment cliAttachment = new Attachment("A1", "a.xml"); when(connector.getAttachmentStream(anyObject(), anyObject(), anyObject())).thenReturn(new ReaderInputStream(new StringReader(CLI_TESTFILE.replaceAll("</Content>", "</Broken>")))); LicenseInfoParsingResult res = parser.getLicenseInfos(cliAttachment, new User(), new Project()).stream().findFirst().orElseThrow(()->new RuntimeException("Parser returned empty LisenceInfoParsingResult list")); assertLicenseInfoParsingResult(res, LicenseInfoRequestStatus.FAILURE); assertThat(res.getStatus(), is(LicenseInfoRequestStatus.FAILURE)); assertThat(res.getLicenseInfo(), notNullValue()); assertThat(res.getLicenseInfo().getFilenames(), contains("a.xml")); }