All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.taimos.dvalin.notification.mail.TestMailSender Maven / Gradle / Ivy

There is a newer version: 1.35
Show newest version
package de.taimos.dvalin.notification.mail;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.mail.MailException;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;

import de.taimos.daemon.spring.annotations.TestComponent;

@TestComponent
public class TestMailSender implements MailSender {

    private final List messages = new ArrayList<>();

    @PostConstruct
    public void init(){
        System.out.println("INIT TEST MAIL SENDER");
    }

    @Override
    public void send(SimpleMailMessage simpleMailMessage) throws MailException {
        this.messages.add(simpleMailMessage);
    }

    @Override
    public void send(SimpleMailMessage... simpleMailMessages) throws MailException {
        for (SimpleMailMessage message : simpleMailMessages) {
            this.send(message);
        }
    }

    public List getMessages() {
        return this.messages;
    }

    public void clear() {
        this.messages.clear();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy