1 | package fr.sii.ogham.core.translator.resource; | |
2 | ||
3 | import org.slf4j.Logger; | |
4 | import org.slf4j.LoggerFactory; | |
5 | ||
6 | import fr.sii.ogham.core.exception.resource.ResourceResolutionException; | |
7 | import fr.sii.ogham.core.resource.LookupResource; | |
8 | import fr.sii.ogham.core.resource.Resource; | |
9 | import fr.sii.ogham.core.resource.resolver.ResourceResolver; | |
10 | import fr.sii.ogham.email.exception.attachment.translator.ResourceTranslatorException; | |
11 | ||
12 | /** | |
13 | * <p> | |
14 | * Translator that handles {@link LookupResource}. It associates a lookup with a | |
15 | * real resource implementation. | |
16 | * </p> | |
17 | * <p> | |
18 | * This translator uses a {@link ResourceResolver} to get the real | |
19 | * resource implementation. | |
20 | * </p> | |
21 | * | |
22 | * @author Aurélien Baudet | |
23 | * | |
24 | */ | |
25 | public class LookupResourceTranslator implements AttachmentResourceTranslator { | |
26 | private static final Logger LOG = LoggerFactory.getLogger(LookupResourceTranslator.class); | |
27 | ||
28 | private final ResourceResolver resolver; | |
29 | ||
30 | public LookupResourceTranslator(ResourceResolver resolver) { | |
31 | super(); | |
32 | this.resolver = resolver; | |
33 | } | |
34 | ||
35 | @Override | |
36 | public Resource translate(Resource resource) throws ResourceTranslatorException { | |
37 |
3
1. translate : negated conditional → NO_COVERAGE 2. translate : negated conditional → KILLED 3. translate : negated conditional → KILLED |
if (resource instanceof LookupResource) { |
38 | try { | |
39 | LookupResource lookupResource = (LookupResource) resource; | |
40 | LOG.debug("Resolving {} using {}", lookupResource.getPath(), resolver); | |
41 |
2
1. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::translate → NO_COVERAGE 2. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::translate → KILLED |
return resolver.getResource(lookupResource.getPath()); |
42 | } catch (ResourceResolutionException e) { | |
43 | throw new ResourceTranslatorException("failed to translate lookup resource", e); | |
44 | } | |
45 | } else { | |
46 | LOG.trace("Not a LookupResource => skip it"); | |
47 |
3
1. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::translate → NO_COVERAGE 2. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::translate → KILLED 3. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::translate → KILLED |
return resource; |
48 | } | |
49 | } | |
50 | ||
51 | @Override | |
52 | public String toString() { | |
53 |
3
1. toString : replaced return value with "" for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::toString → SURVIVED 2. toString : replaced return value with "" for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::toString → NO_COVERAGE 3. toString : replaced return value with "" for fr/sii/ogham/core/translator/resource/LookupResourceTranslator::toString → TIMED_OUT |
return "LookupResourceTranslator"; |
54 | } | |
55 | ||
56 | } | |
Mutations | ||
37 |
1.1 2.2 3.3 |
|
41 |
1.1 2.2 |
|
47 |
1.1 2.2 3.3 |
|
53 |
1.1 2.2 3.3 |