| 1 | package fr.sii.ogham.email.builder; | |
| 2 | ||
| 3 | import java.util.List; | |
| 4 | ||
| 5 | import org.slf4j.Logger; | |
| 6 | import org.slf4j.LoggerFactory; | |
| 7 | ||
| 8 | import fr.sii.ogham.core.builder.Builder; | |
| 9 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 10 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
| 11 | import fr.sii.ogham.core.builder.resolution.ClassPathResolutionBuilder; | |
| 12 | import fr.sii.ogham.core.builder.resolution.FileResolutionBuilder; | |
| 13 | import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilder; | |
| 14 | import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilderHelper; | |
| 15 | import fr.sii.ogham.core.builder.resolution.StringResolutionBuilder; | |
| 16 | import fr.sii.ogham.core.fluent.AbstractParent; | |
| 17 | import fr.sii.ogham.core.resource.resolver.FirstSupportingResourceResolver; | |
| 18 | import fr.sii.ogham.core.resource.resolver.ResourceResolver; | |
| 19 | import fr.sii.ogham.core.translator.resource.AttachmentResourceTranslator; | |
| 20 | import fr.sii.ogham.core.translator.resource.EveryResourceTranslator; | |
| 21 | import fr.sii.ogham.core.translator.resource.LookupResourceTranslator; | |
| 22 | import fr.sii.ogham.core.translator.resource.OverrideNameWrapperResourceTranslator; | |
| 23 | import fr.sii.ogham.email.attachment.Attachment; | |
| 24 | ||
| 25 | /** | |
| 26 | * Configures how {@link Attachment}s are handled. | |
| 27 | * | |
| 28 | * Attachment resolution consists of finding a file: | |
| 29 | * <ul> | |
| 30 | * <li>either on filesystem</li> | |
| 31 | * <li>or in the classpath</li> | |
| 32 | * <li>or anywhere else</li> | |
| 33 | * </ul> | |
| 34 | * | |
| 35 | * | |
| 36 | * @author Aurélien Baudet | |
| 37 | * | |
| 38 | */ | |
| 39 | public class AttachmentHandlingBuilder extends AbstractParent<EmailBuilder> implements ResourceResolutionBuilder<AttachmentHandlingBuilder>, Builder<AttachmentResourceTranslator> { | |
| 40 | private static final Logger LOG = LoggerFactory.getLogger(AttachmentHandlingBuilder.class); | |
| 41 | ||
| 42 | private final BuildContext buildContext; | |
| 43 | private ResourceResolutionBuilderHelper<AttachmentHandlingBuilder> resourceResolutionBuilderHelper; | |
| 44 | ||
| 45 | /** | |
| 46 | * Initializes the builder with a parent builder. The parent builder is used | |
| 47 | * when calling {@link #and()} method. The {@link EnvironmentBuilder} is | |
| 48 | * used to evaluate properties when {@link #build()} method is called. | |
| 49 | * | |
| 50 | * @param parent | |
| 51 | * the parent builder | |
| 52 | * @param buildContext | |
| 53 | * for registering instances and property evaluation | |
| 54 | */ | |
| 55 | public AttachmentHandlingBuilder(EmailBuilder parent, BuildContext buildContext) { | |
| 56 | super(parent); | |
| 57 | this.buildContext = buildContext; | |
| 58 | resourceResolutionBuilderHelper = new ResourceResolutionBuilderHelper<>(this, buildContext); | |
| 59 | } | |
| 60 | ||
| 61 | @Override | |
| 62 | public ClassPathResolutionBuilder<AttachmentHandlingBuilder> classpath() { | |
| 63 |
8
1. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → NO_COVERAGE 2. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → KILLED 3. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → KILLED 4. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → KILLED 5. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → KILLED 6. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → KILLED 7. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → KILLED 8. classpath : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::classpath → KILLED |
return resourceResolutionBuilderHelper.classpath(); |
| 64 | } | |
| 65 | ||
| 66 | @Override | |
| 67 | public FileResolutionBuilder<AttachmentHandlingBuilder> file() { | |
| 68 |
8
1. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → NO_COVERAGE 2. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → KILLED 3. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → KILLED 4. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → KILLED 5. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → KILLED 6. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → KILLED 7. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → KILLED 8. file : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::file → KILLED |
return resourceResolutionBuilderHelper.file(); |
| 69 | } | |
| 70 | ||
| 71 | @Override | |
| 72 | public StringResolutionBuilder<AttachmentHandlingBuilder> string() { | |
| 73 |
8
1. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → NO_COVERAGE 2. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → KILLED 3. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → KILLED 4. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → KILLED 5. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → KILLED 6. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → KILLED 7. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → KILLED 8. string : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::string → KILLED |
return resourceResolutionBuilderHelper.string(); |
| 74 | } | |
| 75 | ||
| 76 | @Override | |
| 77 | public AttachmentHandlingBuilder resolver(ResourceResolver resolver) { | |
| 78 |
1
1. resolver : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::resolver → NO_COVERAGE |
return resourceResolutionBuilderHelper.resolver(resolver); |
| 79 | } | |
| 80 | ||
| 81 | @Override | |
| 82 | public AttachmentResourceTranslator build() { | |
| 83 | EveryResourceTranslator translator = buildContext.register(new EveryResourceTranslator()); | |
| 84 | LOG.info("Using translator that calls all registered translators"); | |
| 85 |
3
1. build : removed call to fr/sii/ogham/core/translator/resource/EveryResourceTranslator::addTranslator → NO_COVERAGE 2. build : removed call to fr/sii/ogham/core/translator/resource/EveryResourceTranslator::addTranslator → SURVIVED 3. build : removed call to fr/sii/ogham/core/translator/resource/EveryResourceTranslator::addTranslator → KILLED |
translator.addTranslator(buildContext.register(new OverrideNameWrapperResourceTranslator(translator))); |
| 86 |
4
1. build : removed call to fr/sii/ogham/core/translator/resource/EveryResourceTranslator::addTranslator → SURVIVED 2. build : removed call to fr/sii/ogham/core/translator/resource/EveryResourceTranslator::addTranslator → NO_COVERAGE 3. build : removed call to fr/sii/ogham/core/translator/resource/EveryResourceTranslator::addTranslator → TIMED_OUT 4. build : removed call to fr/sii/ogham/core/translator/resource/EveryResourceTranslator::addTranslator → KILLED |
translator.addTranslator(buildContext.register(new LookupResourceTranslator(buildResolver()))); |
| 87 | LOG.debug("Registered translators: {}", translator.getTranslators()); | |
| 88 |
4
1. build : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::build → NO_COVERAGE 2. build : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::build → SURVIVED 3. build : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::build → KILLED 4. build : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::build → KILLED |
return translator; |
| 89 | } | |
| 90 | ||
| 91 | private ResourceResolver buildResolver() { | |
| 92 | List<ResourceResolver> resolvers = resourceResolutionBuilderHelper.buildResolvers(); | |
| 93 |
3
1. buildResolver : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::buildResolver → SURVIVED 2. buildResolver : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::buildResolver → NO_COVERAGE 3. buildResolver : replaced return value with null for fr/sii/ogham/email/builder/AttachmentHandlingBuilder::buildResolver → KILLED |
return buildContext.register(new FirstSupportingResourceResolver(resolvers)); |
| 94 | } | |
| 95 | } | |
Mutations | ||
| 63 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 68 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 73 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 78 |
1.1 |
|
| 85 |
1.1 2.2 3.3 |
|
| 86 |
1.1 2.2 3.3 4.4 |
|
| 88 |
1.1 2.2 3.3 4.4 |
|
| 93 |
1.1 2.2 3.3 |