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.module.cropui; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertEquals; |
37 |
|
|
38 |
|
import info.magnolia.content2bean.Content2BeanException; |
39 |
|
import info.magnolia.content2bean.Content2BeanProcessor; |
40 |
|
import info.magnolia.content2bean.Content2BeanTransformer; |
41 |
|
import info.magnolia.content2bean.TransformationState; |
42 |
|
import info.magnolia.content2bean.TypeMapping; |
43 |
|
import info.magnolia.content2bean.impl.Content2BeanProcessorImpl; |
44 |
|
import info.magnolia.content2bean.impl.Content2BeanTransformerImpl; |
45 |
|
import info.magnolia.content2bean.impl.TransformationStateImpl; |
46 |
|
import info.magnolia.content2bean.impl.TypeMappingImpl; |
47 |
|
import info.magnolia.objectfactory.Components; |
48 |
|
import info.magnolia.test.ComponentsTestUtil; |
49 |
|
import info.magnolia.test.mock.MockContent; |
50 |
|
|
51 |
|
import org.junit.After; |
52 |
|
import org.junit.Before; |
53 |
|
import org.junit.Test; |
54 |
|
|
55 |
|
|
56 |
|
@link |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 6 |
Complexity Density: 0.29 |
|
58 |
|
public class CropperPageTest { |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
60 |
1 |
@Before... |
61 |
|
public void setUp() throws Exception { |
62 |
1 |
ComponentsTestUtil.setImplementation(Content2BeanTransformer.class, Content2BeanTransformerImpl.class); |
63 |
1 |
ComponentsTestUtil.setImplementation(Content2BeanProcessor.class, Content2BeanProcessorImpl.class); |
64 |
1 |
ComponentsTestUtil.setImplementation(TransformationState.class, TransformationStateImpl.class); |
65 |
1 |
ComponentsTestUtil.setImplementation(TypeMapping.class, TypeMappingImpl.class); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
1 |
@After... |
69 |
|
public void tearDown() throws Exception { |
70 |
1 |
Components.setComponentProvider(null); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
73 |
1 |
@Test... |
74 |
|
public void testFromNodeHasNameAndLabelProperlySet() throws Content2BeanException { |
75 |
1 |
doTestFromNode("myName", "myLabel", "myLabel"); |
76 |
1 |
doTestFromNode(null, "myLabel", "myLabel"); |
77 |
1 |
doTestFromNode("myName", null, "myName"); |
78 |
1 |
doTestFromNode(null, null, "theNodeName"); |
79 |
1 |
doTestFromNode("myName", "myLabel", "myLabel"); |
80 |
1 |
doTestFromNode("", "myLabel", "myLabel"); |
81 |
1 |
doTestFromNode("myName", "", "myName"); |
82 |
1 |
doTestFromNode("", "", "theNodeName"); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
85 |
8 |
private void doTestFromNode(String namePropOrNull, String labelPropOrNull, String expectedLabel) throws Content2BeanException {... |
86 |
8 |
final MockContent node = new MockContent("theNodeName"); |
87 |
8 |
if (namePropOrNull != null) { |
88 |
6 |
node.addNodeData("name", namePropOrNull); |
89 |
|
} |
90 |
8 |
if (labelPropOrNull != null) { |
91 |
6 |
node.addNodeData("label", labelPropOrNull); |
92 |
|
} |
93 |
8 |
final CropAndResizeConfig result = CropperPage.fromNode(node); |
94 |
8 |
assertEquals(expectedLabel, result.getLabel()); |
95 |
8 |
assertEquals("theNodeName", result.getName()); |
96 |
|
} |
97 |
|
} |