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.parameters; |
35 |
|
|
36 |
|
import static org.junit.Assert.*; |
37 |
|
import static org.mockito.Mockito.*; |
38 |
|
|
39 |
|
import info.magnolia.cms.core.Content; |
40 |
|
import info.magnolia.cms.core.HierarchyManager; |
41 |
|
import info.magnolia.cms.util.ContentUtil; |
42 |
|
import info.magnolia.context.MgnlContext; |
43 |
|
import info.magnolia.imaging.AbstractRepositoryTestCase; |
44 |
|
import info.magnolia.imaging.ParameterProvider; |
45 |
|
|
46 |
|
import javax.jcr.RepositoryException; |
47 |
|
import javax.servlet.http.HttpServletRequest; |
48 |
|
|
49 |
|
import org.junit.Test; |
50 |
|
|
51 |
|
|
52 |
|
@link |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
54 |
|
public class ContentParameterProviderFactoryRepositoryTest extends AbstractRepositoryTestCase { |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
56 |
1 |
@Test... |
57 |
|
public void testWrapsContentSuchThatEqualsAndHashCodeAreImplementedBasedOnPathAndHierarchyManagerName() throws RepositoryException { |
58 |
1 |
final HierarchyManager hm = MgnlContext.getHierarchyManager("website"); |
59 |
1 |
ContentUtil.createPath(hm, "/some/node"); |
60 |
1 |
assertNotNull(hm.getContent("/some/node")); |
61 |
1 |
assertNotSame(hm.getContent("/some/node"), hm.getContent("/some/node")); |
62 |
1 |
assertFalse(hm.getContent("/some/node").equals(hm.getContent("/some/node"))); |
63 |
|
|
64 |
1 |
final HttpServletRequest req = mock(HttpServletRequest.class); |
65 |
1 |
when(req.getPathInfo()).thenReturn("/generator/website/some/node"); |
66 |
1 |
final ContentParameterProviderFactory factory = new ContentParameterProviderFactory(); |
67 |
1 |
final ParameterProvider<Content> param1 = factory.newParameterProviderFor(req); |
68 |
1 |
final ParameterProvider<Content> param2 = factory.newParameterProviderFor(req); |
69 |
1 |
assertNotSame("2 calls to ParameterProviderFactory should return 2 *different instances*.", |
70 |
|
param1.getParameter(), param2.getParameter()); |
71 |
1 |
assertEquals("2 calls to ParameterProviderFactory should return 2 *equivalent instances*.", |
72 |
|
param1.getParameter(), param2.getParameter()); |
73 |
|
} |
74 |
|
} |