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.operations.load; |
35 |
|
|
36 |
|
|
37 |
|
import static org.junit.Assert.*; |
38 |
|
|
39 |
|
import info.magnolia.cms.core.Content; |
40 |
|
import info.magnolia.cms.core.HierarchyManager; |
41 |
|
import info.magnolia.cms.core.NodeData; |
42 |
|
import info.magnolia.cms.util.ContentUtil; |
43 |
|
import info.magnolia.context.MgnlContext; |
44 |
|
import info.magnolia.imaging.AbstractRepositoryTestCase; |
45 |
|
import info.magnolia.imaging.ImagingException; |
46 |
|
import info.magnolia.imaging.ParameterProvider; |
47 |
|
import info.magnolia.imaging.ParameterProviderFactory; |
48 |
|
import info.magnolia.imaging.caching.CachingStrategy; |
49 |
|
import info.magnolia.imaging.caching.ContentBasedCachingStrategy; |
50 |
|
import info.magnolia.imaging.parameters.NodeDataParameterProvider; |
51 |
|
|
52 |
|
import org.junit.Test; |
53 |
|
|
54 |
|
|
55 |
|
@link |
56 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
57 |
|
public class FromNodeDataTest extends AbstractRepositoryTestCase { |
58 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
1PASS
|
|
59 |
1 |
@Test... |
60 |
|
public void testNonBinaryPropertyYieldsAProperException() throws Exception { |
61 |
1 |
final HierarchyManager srcHM = MgnlContext.getHierarchyManager("website"); |
62 |
1 |
final Content src = ContentUtil.createPath(srcHM, "/some/node"); |
63 |
1 |
final NodeData srcProp = src.createNodeData("chalala", "tralala"); |
64 |
1 |
srcHM.save(); |
65 |
|
|
66 |
1 |
final ParameterProviderFactory<Object, NodeData> ppf = new ParameterProviderFactory<Object, NodeData>() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
1 |
@Override... |
68 |
|
public ParameterProvider<NodeData> newParameterProviderFor(Object environment) { |
69 |
1 |
return new NodeDataParameterProvider(srcProp); |
70 |
|
} |
71 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
72 |
|
@Override... |
73 |
|
public CachingStrategy getCachingStrategy() { |
74 |
|
return new ContentBasedCachingStrategy(); |
75 |
|
} |
76 |
|
}; |
77 |
|
|
78 |
1 |
final FromNodeData op = new FromNodeData(); |
79 |
1 |
try { |
80 |
1 |
op.apply(null, ppf.newParameterProviderFor(null)); |
81 |
0 |
fail(); |
82 |
|
} catch (ImagingException e) { |
83 |
1 |
assertEquals("Nodedata /some/node/chalala doesn't exist or is not of type binary.", e.getMessage()); |
84 |
|
} |
85 |
|
} |
86 |
|
} |