1
|
|
package pro.verron.officestamper.core; |
2
|
|
|
3
|
|
import jakarta.xml.bind.JAXBElement; |
4
|
|
import org.docx4j.wml.ObjectFactory; |
5
|
|
import org.docx4j.wml.P; |
6
|
|
import org.docx4j.wml.Tbl; |
7
|
|
import org.docx4j.wml.Tc; |
8
|
|
import pro.verron.officestamper.api.OfficeStamperException; |
9
|
|
|
10
|
|
import java.util.function.Predicate; |
11
|
|
|
12
|
|
/** |
13
|
|
* Utility class for table cells |
14
|
|
* |
15
|
|
* @author Joseph Verron |
16
|
|
* @author Tom Hombergs |
17
|
|
* @version ${version} |
18
|
|
* @since 1.0.0 |
19
|
|
*/ |
20
|
|
public class TableCellUtil { |
21
|
|
|
22
|
|
private static final ObjectFactory objectFactory = new ObjectFactory(); |
23
|
|
|
24
|
|
private TableCellUtil() { |
25
|
|
throw new OfficeStamperException("Utility class shouldn't be instantiated"); |
26
|
|
} |
27
|
|
|
28
|
|
/** |
29
|
|
* Checks if a table cell contains a paragraph or a table |
30
|
|
* |
31
|
|
* @param cell the table cell |
32
|
|
* |
33
|
|
* @return true if the table cell contains a paragraph or a table, false otherwise |
34
|
|
*/ |
35
|
|
public static boolean hasNoParagraphOrTable(Tc cell) { |
36
|
|
Predicate<Object> isP = P.class::isInstance; |
37
|
3
1. lambda$hasNoParagraphOrTable$0 : replaced boolean return with true for pro/verron/officestamper/core/TableCellUtil::lambda$hasNoParagraphOrTable$0 → NO_COVERAGE
2. lambda$hasNoParagraphOrTable$0 : negated conditional → NO_COVERAGE
3. lambda$hasNoParagraphOrTable$0 : negated conditional → NO_COVERAGE
|
Predicate<Object> isTbl = e -> e instanceof JAXBElement<?> jaxbElement && jaxbElement.getValue() instanceof Tbl; |
38
|
2
1. hasNoParagraphOrTable : replaced boolean return with true for pro/verron/officestamper/core/TableCellUtil::hasNoParagraphOrTable → SURVIVED
2. hasNoParagraphOrTable : replaced boolean return with false for pro/verron/officestamper/core/TableCellUtil::hasNoParagraphOrTable → SURVIVED
|
return cell.getContent() |
39
|
|
.stream() |
40
|
|
.noneMatch(isP.or(isTbl)); |
41
|
|
} |
42
|
|
|
43
|
|
/** |
44
|
|
* Checks if a table cell contains a paragraph |
45
|
|
* |
46
|
|
* @param cell the table cell |
47
|
|
*/ |
48
|
|
public static void addEmptyParagraph(Tc cell) { |
49
|
|
P paragraph = objectFactory.createP(); |
50
|
|
paragraph.getContent() |
51
|
|
.add(objectFactory.createR()); |
52
|
|
cell.getContent() |
53
|
|
.add(paragraph); |
54
|
|
} |
55
|
|
} |
| | Mutations |
37 |
|
1.1 Location : lambda$hasNoParagraphOrTable$0 Killed by : none replaced boolean return with true for pro/verron/officestamper/core/TableCellUtil::lambda$hasNoParagraphOrTable$0 → NO_COVERAGE
2.2 Location : lambda$hasNoParagraphOrTable$0 Killed by : none negated conditional → NO_COVERAGE
3.3 Location : lambda$hasNoParagraphOrTable$0 Killed by : none negated conditional → NO_COVERAGE
|
38 |
|
1.1 Location : hasNoParagraphOrTable Killed by : none replaced boolean return with true for pro/verron/officestamper/core/TableCellUtil::hasNoParagraphOrTable → SURVIVED
Covering tests
Covered by tests:
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#20]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#23]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#19]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#24]
2.2 Location : hasNoParagraphOrTable Killed by : none replaced boolean return with false for pro/verron/officestamper/core/TableCellUtil::hasNoParagraphOrTable → SURVIVED
Covering tests
Covered by tests:
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#20]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#23]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#19]
- pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#24]
|