blob: c2f53e3457d82dee266b2a1673a5a089ac6e1052 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// 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 com.yahoo.vespa.hosted.controller.tenant.PendingMailVerification;
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<>();
public final boolean blackhole;
public MockMailer() {
this(false);
}
MockMailer(boolean blackhole) {
this.blackhole = blackhole;
}
public static MockMailer blackhole() {
return new MockMailer(true);
}
@Override
public void send(Mail mail) {
if (blackhole) {
return;
}
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.getOrDefault(recipient, List.of());
}
public void reset() {
mails.clear();
}
}
|