Contact.java

1
package fr.sii.ogham.sms.message;
2
3
import fr.sii.ogham.core.util.EqualsBuilder;
4
import fr.sii.ogham.core.util.HashCodeBuilder;
5
6
/**
7
 * A SMS contact taht contains the following information:
8
 * <ul>
9
 * <li>The name of the contact (optional)</li>
10
 * <li>The phone number of the contact</li>
11
 * </ul>
12
 * 
13
 * @author Aurélien Baudet
14
 *
15
 */
16
public class Contact {
17
	/**
18
	 * The name of the contact
19
	 */
20
	private final String name;
21
22
	/**
23
	 * The phone number for the contact
24
	 */
25
	private PhoneNumber phoneNumber;
26
27
	/**
28
	 * Initialize the contact with its phone number as string.
29
	 * <p>
30
	 * No name is specified.
31
	 * </p>
32
	 * 
33
	 * @param phoneNumber
34
	 *            the phone number for the contact
35
	 */
36
	public Contact(String phoneNumber) {
37
		this(new PhoneNumber(phoneNumber));
38
	}
39
40
	/**
41
	 * Initialize the contact with its name and its phone number as string.
42
	 * 
43
	 * @param name
44
	 *            the name of the contact
45
	 * @param phoneNumber
46
	 *            the phone number for the contact as string
47
	 */
48
	public Contact(String name, String phoneNumber) {
49
		this(name, new PhoneNumber(phoneNumber));
50
	}
51
52
	/**
53
	 * Initialize the contact with its name and its phone number.
54
	 * <p>
55
	 * No name is specified.
56
	 * </p>
57
	 * 
58
	 * @param phoneNumber
59
	 *            the phone number for the contact
60
	 */
61
	public Contact(PhoneNumber phoneNumber) {
62
		this(null, phoneNumber);
63
	}
64
65
	/**
66
	 * Initialize the contact with its name and its phone number.
67
	 * 
68
	 * @param name
69
	 *            the name of the contact
70
	 * @param phoneNumber
71
	 *            the phone number for the contact
72
	 */
73
	public Contact(String name, PhoneNumber phoneNumber) {
74
		super();
75
		this.name = name;
76
		this.phoneNumber = phoneNumber;
77
	}
78
79
	public String getName() {
80 3 1. getName : replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → SURVIVED
2. getName : replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → NO_COVERAGE
3. getName : replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → KILLED
		return name;
81
	}
82
83
	public PhoneNumber getPhoneNumber() {
84 6 1. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → NO_COVERAGE
2. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → TIMED_OUT
3. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED
4. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED
5. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED
6. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED
		return phoneNumber;
85
	}
86
87
	public void setPhoneNumber(PhoneNumber phoneNumber) {
88
		this.phoneNumber = phoneNumber;
89
	}
90
91
92
	@Override
93
	public String toString() {
94
		StringBuilder builder = new StringBuilder();
95 4 1. toString : negated conditional → NO_COVERAGE
2. toString : negated conditional → SURVIVED
3. toString : negated conditional → NO_COVERAGE
4. toString : negated conditional → TIMED_OUT
		if (name != null && !name.isEmpty()) {
96
			builder.append(name).append(" ");
97
		}
98
		builder.append("<").append(phoneNumber).append(">");
99 3 1. toString : replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → NO_COVERAGE
2. toString : replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → SURVIVED
3. toString : replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → TIMED_OUT
		return builder.toString();
100
	}
101
102
	@Override
103
	public int hashCode() {
104 2 1. hashCode : replaced int return with 0 for fr/sii/ogham/sms/message/Contact::hashCode → NO_COVERAGE
2. hashCode : replaced int return with 0 for fr/sii/ogham/sms/message/Contact::hashCode → KILLED
		return new HashCodeBuilder().append(name, phoneNumber).hashCode();
105
	}
106
107
	@Override
108
	public boolean equals(Object obj) {
109 6 1. equals : replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → NO_COVERAGE
2. equals : replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → NO_COVERAGE
3. equals : replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → SURVIVED
4. equals : replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → KILLED
5. equals : replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → KILLED
6. equals : replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → KILLED
		return new EqualsBuilder(this, obj).appendFields("name", "phoneNumber").isEqual();
110
	}
111
}

Mutations

80

1.1
Location : getName
Killed by : none
replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → SURVIVED

2.2
Location : getName
Killed by : none
replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → NO_COVERAGE

3.3
Location : getName
Killed by : oghamcore.ut.sms.EqualsTest.sender(oghamcore.ut.sms.EqualsTest)
replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → KILLED

84

1.1
Location : getPhoneNumber
Killed by : oghamcore.ut.sms.EqualsTest.sender(oghamcore.ut.sms.EqualsTest)
replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED

2.2
Location : getPhoneNumber
Killed by : oghamovh.it.OvhSmsTest.nationalNumber(oghamovh.it.OvhSmsTest)
replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED

3.3
Location : getPhoneNumber
Killed by : oghamall.it.sms.SmsSMPPGsm7bitTest.longMessage(oghamall.it.sms.SmsSMPPGsm7bitTest)
replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED

4.4
Location : getPhoneNumber
Killed by : oghamcloudhopper.it.PartialConfigurationTest.nothingConfiguredAndLongMessageShouldSendOneLongMessageUsingDefaultEncoding(oghamcloudhopper.it.PartialConfigurationTest)
replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED

5.5
Location : getPhoneNumber
Killed by : none
replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → NO_COVERAGE

6.6
Location : getPhoneNumber
Killed by : none
replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → TIMED_OUT

95

1.1
Location : toString
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : toString
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : toString
Killed by : none
negated conditional → SURVIVED

4.4
Location : toString
Killed by : none
negated conditional → NO_COVERAGE

99

1.1
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → TIMED_OUT

2.2
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → NO_COVERAGE

3.3
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → SURVIVED

104

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

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

109

1.1
Location : equals
Killed by : none
replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → NO_COVERAGE

2.2
Location : equals
Killed by : oghamcore.ut.core.convert.SmsSenderConverterSpec
replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → KILLED

3.3
Location : equals
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → KILLED

4.4
Location : equals
Killed by : none
replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → NO_COVERAGE

5.5
Location : equals
Killed by : oghamcore.ut.sms.EqualsTest.sender(oghamcore.ut.sms.EqualsTest)
replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → KILLED

6.6
Location : equals
Killed by : none
replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → SURVIVED

Active mutators

Tests examined


Report generated by PIT OGHAM