1 | package fr.sii.ogham.template.exception; | |
2 | ||
3 | import static fr.sii.ogham.core.CoreConstants.SERIAL_VERSION_UID; | |
4 | ||
5 | import java.util.List; | |
6 | import java.util.stream.Collectors; | |
7 | ||
8 | import fr.sii.ogham.core.message.capability.HasVariant; | |
9 | import fr.sii.ogham.core.message.content.TemplateContent; | |
10 | import fr.sii.ogham.core.message.content.Variant; | |
11 | import fr.sii.ogham.core.resource.path.ResolvedPath; | |
12 | import fr.sii.ogham.core.resource.path.ResourcePath; | |
13 | import fr.sii.ogham.core.template.context.Context; | |
14 | import fr.sii.ogham.template.common.adapter.VariantResolver; | |
15 | ||
16 | /** | |
17 | * Specialized exception that is thrown when the variant can be handled by Ogham | |
18 | * through a {@link VariantResolver} but the {@link ResolvedPath} provided by | |
19 | * the {@link VariantResolver} points to an non-existing template. | |
20 | * | |
21 | * <p> | |
22 | * This exception provides the list of tested paths (the possible template paths | |
23 | * for the variant) that seem to not exist. For example, using FreeMarker | |
24 | * template engine, an HTML variant template referenced by "templates/register" | |
25 | * may be located at either "templates/register.html.ftl" or | |
26 | * "template/register.html.ftlh". | |
27 | * | |
28 | * @author Aurélien Baudet | |
29 | * | |
30 | */ | |
31 | @SuppressWarnings("squid:MaximumInheritanceDepth") | |
32 | public class TemplateVariantNotFoundException extends VariantResolutionException { | |
33 | private static final long serialVersionUID = SERIAL_VERSION_UID; | |
34 | ||
35 | private final transient List<ResourcePath> testedPaths; | |
36 | ||
37 | public TemplateVariantNotFoundException(String message, TemplateContent template, List<ResourcePath> testedPaths) { | |
38 | this(message, template.getPath(), template.getContext(), getVariant(template), testedPaths); | |
39 | } | |
40 | ||
41 | public TemplateVariantNotFoundException(String message, ResourcePath template, Context context, Variant variant, List<ResourcePath> testedPaths) { | |
42 | super(message, template, context, variant); | |
43 | this.testedPaths = testedPaths; | |
44 | } | |
45 | ||
46 | public List<ResourcePath> getTestedPaths() { | |
47 |
1
1. getTestedPaths : replaced return value with Collections.emptyList for fr/sii/ogham/template/exception/TemplateVariantNotFoundException::getTestedPaths → NO_COVERAGE |
return testedPaths; |
48 | } | |
49 | ||
50 | public List<String> getResolvedPaths() { | |
51 |
6
1. getResolvedPaths : replaced return value with Collections.emptyList for fr/sii/ogham/template/exception/TemplateVariantNotFoundException::getResolvedPaths → NO_COVERAGE 2. lambda$getResolvedPaths$0 : replaced return value with "" for fr/sii/ogham/template/exception/TemplateVariantNotFoundException::lambda$getResolvedPaths$0 → NO_COVERAGE 3. lambda$getResolvedPaths$0 : negated conditional → SURVIVED 4. lambda$getResolvedPaths$0 : negated conditional → NO_COVERAGE 5. getResolvedPaths : replaced return value with Collections.emptyList for fr/sii/ogham/template/exception/TemplateVariantNotFoundException::getResolvedPaths → KILLED 6. lambda$getResolvedPaths$0 : replaced return value with "" for fr/sii/ogham/template/exception/TemplateVariantNotFoundException::lambda$getResolvedPaths$0 → KILLED |
return testedPaths.stream().map(p -> p instanceof ResolvedPath ? ((ResolvedPath) p).getResolvedPath() : p.getOriginalPath()).collect(Collectors.toList()); |
52 | } | |
53 | ||
54 | private static Variant getVariant(TemplateContent template) { | |
55 |
2
1. getVariant : negated conditional → NO_COVERAGE 2. getVariant : negated conditional → SURVIVED |
if (template instanceof HasVariant) { |
56 |
2
1. getVariant : replaced return value with null for fr/sii/ogham/template/exception/TemplateVariantNotFoundException::getVariant → NO_COVERAGE 2. getVariant : replaced return value with null for fr/sii/ogham/template/exception/TemplateVariantNotFoundException::getVariant → SURVIVED |
return ((HasVariant) template).getVariant(); |
57 | } | |
58 | return null; | |
59 | } | |
60 | } | |
Mutations | ||
47 |
1.1 |
|
51 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
55 |
1.1 2.2 |
|
56 |
1.1 2.2 |