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.googlesitemap.app.field; |
35 |
|
|
36 |
|
import static org.hamcrest.CoreMatchers.*; |
37 |
|
import static org.junit.Assert.assertThat; |
38 |
|
import static org.mockito.Mockito.mock; |
39 |
|
|
40 |
|
import info.magnolia.cms.i18n.DefaultI18nContentSupport; |
41 |
|
import info.magnolia.cms.i18n.I18nContentSupport; |
42 |
|
import info.magnolia.context.Context; |
43 |
|
import info.magnolia.context.MgnlContext; |
44 |
|
import info.magnolia.jcr.util.NodeTypes; |
45 |
|
import info.magnolia.test.ComponentsTestUtil; |
46 |
|
import info.magnolia.test.mock.MockWebContext; |
47 |
|
import info.magnolia.ui.api.i18n.I18NAuthoringSupport; |
48 |
|
import info.magnolia.ui.framework.i18n.DefaultI18NAuthoringSupport; |
49 |
|
|
50 |
|
import java.util.Locale; |
51 |
|
|
52 |
|
import org.junit.After; |
53 |
|
import org.junit.Before; |
54 |
|
import org.junit.Test; |
55 |
|
|
56 |
|
import com.vaadin.data.Item; |
57 |
|
|
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 3 |
Complexity Density: 0.19 |
|
59 |
|
public class TemplateStaticFieldFactoryTest { |
60 |
|
|
61 |
|
private TemplateStaticFieldDefinition templateStaticFieldDefinition; |
62 |
|
private TemplateStaticFieldFactory templateStaticFieldFactory; |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
64 |
1 |
@Before... |
65 |
|
public void setUp() throws Exception { |
66 |
1 |
final Context context = new MockWebContext(); |
67 |
1 |
MgnlContext.setInstance(context); |
68 |
|
|
69 |
1 |
ComponentsTestUtil.setImplementation(I18nContentSupport.class, DefaultI18nContentSupport.class); |
70 |
1 |
ComponentsTestUtil.setImplementation(I18NAuthoringSupport.class, DefaultI18NAuthoringSupport.class); |
71 |
|
|
72 |
1 |
templateStaticFieldDefinition = new TemplateStaticFieldDefinition(); |
73 |
1 |
templateStaticFieldFactory = new TemplateStaticFieldFactory(templateStaticFieldDefinition, mock(Item.class)); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
76 |
1 |
@After... |
77 |
|
public void tearDown() { |
78 |
1 |
MgnlContext.setInstance(null); |
79 |
1 |
ComponentsTestUtil.clear(); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
82 |
1 |
@Test... |
83 |
|
public void basicFieldTestThatShowsDefect() { |
84 |
|
|
85 |
1 |
final String templateId = "google-sitemap:pages/siteMapsConfiguration"; |
86 |
1 |
final String templateName = "GoogleSiteMap"; |
87 |
1 |
templateStaticFieldDefinition.setName(NodeTypes.Renderable.NAME); |
88 |
1 |
templateStaticFieldDefinition.setValue(templateId); |
89 |
|
|
90 |
|
|
91 |
1 |
TemplateStaticField field = (TemplateStaticField) templateStaticFieldFactory.createFieldComponent(); |
92 |
|
|
93 |
1 |
assertThat(field.getInternalValue(), is(templateId)); |
94 |
|
|
95 |
|
|
96 |
1 |
field.setLocale(Locale.FRANCE); |
97 |
|
|
98 |
|
|
99 |
1 |
assertThat(field.getInternalValue(), allOf(is(templateId), not(is(templateName)))); |
100 |
|
} |
101 |
|
|
102 |
|
} |