Recipient.java

1
package fr.sii.ogham.email.message;
2
3
import fr.sii.ogham.core.message.recipient.Addressee;
4
import fr.sii.ogham.core.util.EqualsBuilder;
5
import fr.sii.ogham.core.util.HashCodeBuilder;
6
7
/**
8
 * Represents an email recipient. The recipient contains:
9
 * <ul>
10
 * <li>The email address (see {@link EmailAddress})</li>
11
 * <li>The recipient type (the field of the email: to, cc, bcc)</li>
12
 * </ul>
13
 * 
14
 * @author Aurélien Baudet
15
 *
16
 */
17
public class Recipient implements Addressee {
18
	/**
19
	 * The recipient address
20
	 */
21
	private EmailAddress address;
22
23
	/**
24
	 * The recipient type
25
	 */
26
	private RecipientType type;
27
28
	/**
29
	 * Initialize the recipient with the provided address. The address is of the
30
	 * form "user@host.domain" or "Personal Name &lt;user@host.domain&gt;". The
31
	 * recipient type is set to {@link RecipientType#TO}.
32
	 * 
33
	 * @param address
34
	 *            the email address
35
	 */
36
	public Recipient(String address) {
37
		this(new EmailAddress(address));
38
	}
39
40
	/**
41
	 * Initialize the recipient with the provided address. The recipient type is
42
	 * set to {@link RecipientType#TO}.
43
	 * 
44
	 * @param address
45
	 *            the email address
46
	 */
47
	public Recipient(EmailAddress address) {
48
		this(address, RecipientType.TO);
49
	}
50
51
	/**
52
	 * Initialize the recipient with the provided address and for the provided
53
	 * type.
54
	 * 
55
	 * @param address
56
	 *            the email address
57
	 * @param type
58
	 *            the recipient type
59
	 */
60
	public Recipient(EmailAddress address, RecipientType type) {
61
		super();
62
		this.address = address;
63
		this.type = type;
64
	}
65
66
	public EmailAddress getAddress() {
67 5 1. getAddress : replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → NO_COVERAGE
2. getAddress : replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → TIMED_OUT
3. getAddress : replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → KILLED
4. getAddress : replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → KILLED
5. getAddress : replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → KILLED
		return address;
68
	}
69
70
	public RecipientType getType() {
71 5 1. getType : replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → NO_COVERAGE
2. getType : replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → TIMED_OUT
3. getType : replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → KILLED
4. getType : replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → KILLED
5. getType : replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → KILLED
		return type;
72
	}
73
74
	@Override
75
	public String toString() {
76
		StringBuilder builder = new StringBuilder();
77
		builder.append(address).append("(").append(type).append(")");
78 2 1. toString : replaced return value with "" for fr/sii/ogham/email/message/Recipient::toString → NO_COVERAGE
2. toString : replaced return value with "" for fr/sii/ogham/email/message/Recipient::toString → SURVIVED
		return builder.toString();
79
	}
80
81
	@Override
82
	public int hashCode() {
83 2 1. hashCode : replaced int return with 0 for fr/sii/ogham/email/message/Recipient::hashCode → NO_COVERAGE
2. hashCode : replaced int return with 0 for fr/sii/ogham/email/message/Recipient::hashCode → KILLED
		return new HashCodeBuilder().append(address, type).hashCode();
84
	}
85
86
	@Override
87
	public boolean equals(Object obj) {
88 6 1. equals : replaced boolean return with false for fr/sii/ogham/email/message/Recipient::equals → NO_COVERAGE
2. equals : replaced boolean return with true for fr/sii/ogham/email/message/Recipient::equals → SURVIVED
3. equals : replaced boolean return with true for fr/sii/ogham/email/message/Recipient::equals → NO_COVERAGE
4. equals : replaced boolean return with false for fr/sii/ogham/email/message/Recipient::equals → KILLED
5. equals : replaced boolean return with false for fr/sii/ogham/email/message/Recipient::equals → KILLED
6. equals : replaced boolean return with true for fr/sii/ogham/email/message/Recipient::equals → KILLED
		return new EqualsBuilder(this, obj).appendFields("address", "type").isEqual();
89
	}
90
}

Mutations

67

1.1
Location : getAddress
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → KILLED

2.2
Location : getAddress
Killed by : none
replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → TIMED_OUT

3.3
Location : getAddress
Killed by : none
replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → NO_COVERAGE

4.4
Location : getAddress
Killed by : oghamcore.ut.email.EqualsTest.recipient(oghamcore.ut.email.EqualsTest)
replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → KILLED

5.5
Location : getAddress
Killed by : oghamjavamail.it.JavaMailStructureTest.plainTextBody(oghamjavamail.it.JavaMailStructureTest)
replaced return value with null for fr/sii/ogham/email/message/Recipient::getAddress → KILLED

71

1.1
Location : getType
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → KILLED

2.2
Location : getType
Killed by : none
replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → NO_COVERAGE

3.3
Location : getType
Killed by : none
replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → TIMED_OUT

4.4
Location : getType
Killed by : oghamjavamail.it.JavaMailStructureTest.plainTextBody(oghamjavamail.it.JavaMailStructureTest)
replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → KILLED

5.5
Location : getType
Killed by : oghamcore.ut.email.EqualsTest.recipient(oghamcore.ut.email.EqualsTest)
replaced return value with null for fr/sii/ogham/email/message/Recipient::getType → KILLED

78

1.1
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/email/message/Recipient::toString → NO_COVERAGE

2.2
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/email/message/Recipient::toString → SURVIVED

83

1.1
Location : hashCode
Killed by : oghamcore.ut.email.EqualsTest.recipient(oghamcore.ut.email.EqualsTest)
replaced int return with 0 for fr/sii/ogham/email/message/Recipient::hashCode → KILLED

2.2
Location : hashCode
Killed by : none
replaced int return with 0 for fr/sii/ogham/email/message/Recipient::hashCode → NO_COVERAGE

88

1.1
Location : equals
Killed by : oghamall.it.email.EmailCustomImplTest.simple(oghamall.it.email.EmailCustomImplTest)
replaced boolean return with false for fr/sii/ogham/email/message/Recipient::equals → KILLED

2.2
Location : equals
Killed by : none
replaced boolean return with false for fr/sii/ogham/email/message/Recipient::equals → NO_COVERAGE

3.3
Location : equals
Killed by : oghamcore.ut.email.EqualsTest.recipient(oghamcore.ut.email.EqualsTest)
replaced boolean return with false for fr/sii/ogham/email/message/Recipient::equals → KILLED

4.4
Location : equals
Killed by : oghamcore.ut.email.EqualsTest.recipient(oghamcore.ut.email.EqualsTest)
replaced boolean return with true for fr/sii/ogham/email/message/Recipient::equals → KILLED

5.5
Location : equals
Killed by : none
replaced boolean return with true for fr/sii/ogham/email/message/Recipient::equals → SURVIVED

6.6
Location : equals
Killed by : none
replaced boolean return with true for fr/sii/ogham/email/message/Recipient::equals → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM