@Test
public void testReplaceSeveralImageReferences() {

	List<MBAttachmentFileEntryReference> fileEntryReferences =
		new ArrayList<>();
	StringBuilder originalContent = new StringBuilder();
	StringBuilder expectedContent = new StringBuilder();
	for (int tempFileId = 0; tempFileId < 3; tempFileId++) {
		FileEntry fileEntry = Mockito.mock(FileEntry.class);
		String finalURL = "http://final-" + tempFileId;
		String curOriginalContent = String.format(
			"<img data-image-id=\"%d\" src=\"%s\"/>", tempFileId,
			"http://temporal-" + tempFileId);
		Mockito.doReturn(
			finalURL
		).when(
			_portletFileRepository
		).getPortletFileEntryURL(
			Mockito.isNull(ThemeDisplay.class), Mockito.eq(fileEntry),
			Mockito.eq(StringPool.BLANK)
		);
		fileEntryReferences.add(
			new MBAttachmentFileEntryReference(tempFileId, fileEntry));
		originalContent.append(curOriginalContent);
		expectedContent.append("<img src=\"" + finalURL + "\" />");
	}
	String finalContent =
		_mbMessageHTMLFormatUploadHandler.replaceImageReferences(
			originalContent.toString(), fileEntryReferences);
	Assert.assertEquals(expectedContent.toString(), finalContent);
}