class TestMailSender implements MailSender {

	private List<String> subjectsToFail = new ArrayList<>();

	private final List<SimpleMailMessage> received = new ArrayList<>();

	public void clear() {
		received.clear();
	}

	@Override
	public void send(SimpleMailMessage simpleMessage) throws MailException {
		throw new UnsupportedOperationException("Not implemented.  Use send(SimpleMailMessage[]).");
	}

	public void setSubjectsToFail(List<String> subjectsToFail) {
		this.subjectsToFail = subjectsToFail;
	}

	@Override
	public void send(SimpleMailMessage... simpleMessages) throws MailException {<FILL_FUNCTION_BODY>}

	public List<SimpleMailMessage> getReceivedMessages() {
		return received;
	}

}

		Map<Object, Exception> failedMessages = new LinkedHashMap<>();
		for (SimpleMailMessage simpleMessage : simpleMessages) {
			if (subjectsToFail.contains(simpleMessage.getSubject())) {
				failedMessages.put(simpleMessage, new MessagingException());
			}
			else {
				received.add(simpleMessage);
			}
		}
		if (!failedMessages.isEmpty()) {
			throw new MailSendException(failedMessages);
		}
	
<no_super_class>