EmailFiller.java

1
package fr.sii.ogham.email.filler;
2
3
import static fr.sii.ogham.email.message.RecipientType.BCC;
4
import static fr.sii.ogham.email.message.RecipientType.CC;
5
import static fr.sii.ogham.email.message.RecipientType.TO;
6
7
import java.util.Map;
8
9
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper;
10
import fr.sii.ogham.core.filler.AbstractMessageAwareFiller;
11
import fr.sii.ogham.email.message.Email;
12
import fr.sii.ogham.email.message.Recipient;
13
import fr.sii.ogham.email.message.RecipientType;
14
15
public class EmailFiller extends AbstractMessageAwareFiller<Email> {
16
17
	public EmailFiller(Map<String, ConfigurationValueBuilderHelper<?, ?>> defaultValues) {
18
		super(defaultValues, Email.class);
19
	}
20
21
	@Override
22
	protected void fill(Email email) {
23 2 1. fill : negated conditional → RUN_ERROR
2. fill : negated conditional → RUN_ERROR
		if (email.getSubject() == null && containsProperty("subject")) {
24
			email.subject(getProperty("subject", String.class));
25
		}
26 2 1. fill : negated conditional → RUN_ERROR
2. fill : negated conditional → RUN_ERROR
		if (email.getFrom() == null && containsProperty("from")) {
27
			email.from(getProperty("from", String.class));
28
		}
29 2 1. fill : negated conditional → RUN_ERROR
2. fill : negated conditional → RUN_ERROR
		if (!hasRecipient(email, TO) && containsProperty("to")) {
30
			email.to(getProperty("to", String[].class));
31
		}
32 2 1. fill : negated conditional → RUN_ERROR
2. fill : negated conditional → RUN_ERROR
		if (!hasRecipient(email, CC) && containsProperty("cc")) {
33
			email.cc(getProperty("cc", String[].class));
34
		}
35 2 1. fill : negated conditional → RUN_ERROR
2. fill : negated conditional → RUN_ERROR
		if (!hasRecipient(email, BCC) && containsProperty("bcc")) {
36
			email.bcc(getProperty("bcc", String[].class));
37
		}
38
	}
39
40
	private static boolean hasRecipient(Email email, RecipientType type) {
41 1 1. hasRecipient : negated conditional → RUN_ERROR
		if (email.getRecipients() == null) {
42 1 1. hasRecipient : replaced boolean return with true for fr/sii/ogham/email/filler/EmailFiller::hasRecipient → RUN_ERROR
			return false;
43
		}
44
		for (Recipient recipient : email.getRecipients()) {
45 1 1. hasRecipient : negated conditional → RUN_ERROR
			if (type == recipient.getType()) {
46 1 1. hasRecipient : replaced boolean return with false for fr/sii/ogham/email/filler/EmailFiller::hasRecipient → RUN_ERROR
				return true;
47
			}
48
		}
49 1 1. hasRecipient : replaced boolean return with true for fr/sii/ogham/email/filler/EmailFiller::hasRecipient → RUN_ERROR
		return false;
50
	}
51
}

Mutations

23

1.1
Location : fill
Killed by :
negated conditional → RUN_ERROR

2.2
Location : fill
Killed by :
negated conditional → RUN_ERROR

26

1.1
Location : fill
Killed by :
negated conditional → RUN_ERROR

2.2
Location : fill
Killed by :
negated conditional → RUN_ERROR

29

1.1
Location : fill
Killed by :
negated conditional → RUN_ERROR

2.2
Location : fill
Killed by :
negated conditional → RUN_ERROR

32

1.1
Location : fill
Killed by :
negated conditional → RUN_ERROR

2.2
Location : fill
Killed by :
negated conditional → RUN_ERROR

35

1.1
Location : fill
Killed by :
negated conditional → RUN_ERROR

2.2
Location : fill
Killed by :
negated conditional → RUN_ERROR

41

1.1
Location : hasRecipient
Killed by :
negated conditional → RUN_ERROR

42

1.1
Location : hasRecipient
Killed by :
replaced boolean return with true for fr/sii/ogham/email/filler/EmailFiller::hasRecipient → RUN_ERROR

45

1.1
Location : hasRecipient
Killed by :
negated conditional → RUN_ERROR

46

1.1
Location : hasRecipient
Killed by :
replaced boolean return with false for fr/sii/ogham/email/filler/EmailFiller::hasRecipient → RUN_ERROR

49

1.1
Location : hasRecipient
Killed by :
replaced boolean return with true for fr/sii/ogham/email/filler/EmailFiller::hasRecipient → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1