Image.java

1
package pro.verron.officestamper.preset;
2
3
import org.apache.commons.io.IOUtils;
4
5
import java.io.ByteArrayOutputStream;
6
import java.io.IOException;
7
import java.io.InputStream;
8
9
/**
10
 * This class describes an image which will be inserted into a document.
11
 *
12
 * @author Joseph Verron
13
 * @author Romster
14
 * @version ${version}
15
 * @since 1.0.0
16
 */
17
public final class Image {
18
19
    /**
20
     * TODO_LATER: make private asap
21
     */
22
    private final byte[] imageBytes;
23
24
    /**
25
     * TODO_LATER: make private asap
26
     */
27
    private Integer maxWidth;
28
29
    /**
30
     * <p>Constructor for Image.</p>
31
     *
32
     * @param in - content of the image as InputStream
33
     * @throws IOException if any.
34
     */
35
    public Image(InputStream in) throws IOException {
36
        ByteArrayOutputStream out = new ByteArrayOutputStream();
37
        IOUtils.copy(in, out);
38
        this.imageBytes = out.toByteArray();
39
    }
40
41
    /**
42
     * <p>Constructor for Image.</p>
43
     *
44
     * @param in       - content of the image as InputStream
45
     * @param maxWidth - max width of the image in twip
46
     * @throws IOException if any.
47
     */
48
    public Image(InputStream in, Integer maxWidth) throws IOException {
49
        ByteArrayOutputStream out = new ByteArrayOutputStream();
50
        IOUtils.copy(in, out);
51
        this.imageBytes = out.toByteArray();
52
        this.maxWidth = maxWidth;
53
    }
54
55
    /**
56
     * <p>Constructor for Image.</p>
57
     *
58
     * @param imageBytes - content of the image as an array of the bytes
59
     */
60
    public Image(byte[] imageBytes) {
61
        this.imageBytes = imageBytes;
62
    }
63
    /**
64
     * <p>Constructor for Image.</p>
65
     *
66
     * @param imageBytes - content of the image as an array of the bytes
67
     * @param maxWidth   - max width of the image in twip
68
     */
69
    public Image(byte[] imageBytes, Integer maxWidth) {
70
        this.imageBytes = imageBytes;
71
        this.maxWidth = maxWidth;
72
    }
73
74
    /**
75
     * <p>Getter for the field <code>maxWidth</code>.</p>
76
     *
77
     * @return a {@link Integer} object
78
     */
79
    public Integer getMaxWidth() {
80 1 1. getMaxWidth : replaced Integer return value with 0 for pro/verron/officestamper/preset/Image::getMaxWidth → KILLED
        return maxWidth;
81
    }
82
83
    /**
84
     * <p>Getter for the field <code>imageBytes</code>.</p>
85
     *
86
     * @return an array of {@link byte} objects
87
     */
88
    public byte[] getImageBytes() {
89 1 1. getImageBytes : replaced return value with null for pro/verron/officestamper/preset/Image::getImageBytes → KILLED
        return imageBytes;
90
    }
91
}

Mutations

80

1.1
Location : getMaxWidth
Killed by : 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:#32]
replaced Integer return value with 0 for pro/verron/officestamper/preset/Image::getMaxWidth → KILLED

89

1.1
Location : getImageBytes
Killed by : 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:#32]
replaced return value with null for pro/verron/officestamper/preset/Image::getImageBytes → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0