// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.stubs;

import com.yahoo.vespa.hosted.controller.api.integration.organization.Mail;
import com.yahoo.vespa.hosted.controller.api.integration.organization.Mailer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MockMailer implements Mailer {

    public final Map<String, List<Mail>> mails = new HashMap<>();

    @Override
    public void send(Mail mail) {
        for (String recipient : mail.recipients()) {
            mails.putIfAbsent(recipient, new ArrayList<>());
            mails.get(recipient).add(mail);
        }
    }

    @Override
    public String user() {
        return "user";
    }

    @Override
    public String domain() {
        return "domain";
    }

    /** Returns the list of mails sent to the given recipient. Modifications affect the set of mails stored in this. */
    public List<Mail> inbox(String recipient) {
        return mails.get(recipient);
    }

}

@@ -534,56 +534,367 @@
 ();%0A
-%0A    @Override%0A    public void send(Mail mail) %7B
+    public final boolean blackhole;%0A%0A    public MockMailer() %7B%0A        this(false);%0A    %7D%0A%0A    MockMailer(boolean blackhole) %7B%0A        this.blackhole = blackhole;%0A    %7D%0A%0A    public static MockMailer blackhole() %7B%0A        return new MockMailer(true);%0A    %7D%0A%0A    @Override%0A    public void send(Mail mail) %7B%0A        if (blackhole) %7B%0A            return;%0A        %7D
 %0A   

Add blackhole support to MockMailer