1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.imaging; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertEquals; |
37 |
|
|
38 |
|
import info.magnolia.imaging.operations.load.DefaultImageIOImageDecoder; |
39 |
|
import info.magnolia.imaging.operations.load.ImageDecoder; |
40 |
|
import info.magnolia.test.ComponentsTestUtil; |
41 |
|
import info.magnolia.test.mock.jcr.MockSession; |
42 |
|
|
43 |
|
import javax.jcr.Node; |
44 |
|
|
45 |
|
import org.junit.Before; |
46 |
|
import org.junit.Test; |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.3 |
|
48 |
|
public class DefaultImageGeneratorTest { |
49 |
|
|
50 |
|
private DefaultImageGenerator generator; |
51 |
|
private ParameterProvider<Node> parameterProvider; |
52 |
|
private Node image; |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
54 |
2 |
@Before... |
55 |
|
public void setUp() throws Exception { |
56 |
2 |
ComponentsTestUtil.setImplementation(ImageDecoder.class, DefaultImageIOImageDecoder.class); |
57 |
|
|
58 |
2 |
MockSession session = new MockSession("dam"); |
59 |
2 |
image = session.getRootNode().addNode("testImage", "mgnl:asset"); |
60 |
2 |
generator = new DefaultImageGenerator(); |
61 |
2 |
parameterProvider = new ParameterProvider<Node>() { |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
62 |
|
@Override... |
63 |
|
public Node getParameter() { |
64 |
|
return image; |
65 |
|
} |
66 |
|
}; |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void extensionIsTakenIntoAccountWhenObtainingOutputFormat() throws Exception { |
71 |
|
|
72 |
1 |
image.setProperty("extension", "png"); |
73 |
|
|
74 |
|
|
75 |
1 |
OutputFormat format = generator.getOutputFormat(parameterProvider); |
76 |
|
|
77 |
|
|
78 |
1 |
assertEquals("png", format.getFormatName()); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
81 |
1 |
@Test... |
82 |
|
public void fallbackToJpgIfNoExtensionExists() { |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
1 |
OutputFormat format = generator.getOutputFormat(parameterProvider); |
87 |
|
|
88 |
|
|
89 |
1 |
assertEquals("jpg", format.getFormatName()); |
90 |
|
} |
91 |
|
} |