1. Project Clover database Fri Apr 29 2016 13:24:33 CEST
  2. Package info.magnolia.module.blossom.dialog

File DefaultDialogCreatorTest.java

 

Code metrics

8
143
46
16
542
354
50
0.35
3.11
2.88
1.09

Classes

Class Line # Actions
DefaultDialogCreatorTest 73 113 0% 19 4
0.970149397%
DefaultDialogCreatorTest.AnnotatedInterface 76 0 - 0 0
-1.0 -
DefaultDialogCreatorTest.SimpleFactory 83 0 0% 3 1
0.666666766.7%
DefaultDialogCreatorTest.InheritingFactory 100 0 0% 2 0
1.0100%
DefaultDialogCreatorTest.BogusTemplate 139 1 0% 1 0
1.0100%
DefaultDialogCreatorTest.TemplateWithDialogFactoryThatNeedsItem 163 2 0% 2 1
0.880%
DefaultDialogCreatorTest.DialogFactoryWithTabFactoryThatNeedsItem 191 2 0% 2 1
0.880%
DefaultDialogCreatorTest.DialogFactoryWithPostCreateMethod 217 1 0% 2 0
1.0100%
DefaultDialogCreatorTest.DialogFactoryWithPostCreateMethodExtendingSuperclass 229 1 0% 1 0
1.0100%
DefaultDialogCreatorTest.DialogFactoryWithPostCreateMethodOverridingMethodInSuperclass 254 2 0% 3 0
1.0100%
DefaultDialogCreatorTest.DialogFactoryWithPostCreateMethodOverridingMethodInSuperclassWithoutRepeatingAnnotation 289 1 0% 1 2
0.00%
DefaultDialogCreatorTest.DialogFactoryWithPostCreateMethodTakingArguments 313 6 0% 1 0
1.0100%
DefaultDialogCreatorTest.DialogFactoryWithPostCreateMethodAfterSubclasses 343 3 0% 3 0
1.0100%
DefaultDialogCreatorTest.DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass 361 5 0% 4 0
1.0100%
DefaultDialogCreatorTest.DialogWithTabsOrderedByName 413 3 0% 3 0
1.0100%
DefaultDialogCreatorTest.DialogWithTabsOrderedByLabel 450 3 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 14 tests. .

Source view

1    /**
2    * This file Copyright (c) 2010-2016 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.module.blossom.dialog;
35   
36    import static org.junit.Assert.assertEquals;
37    import static org.junit.Assert.assertFalse;
38    import static org.junit.Assert.assertNotNull;
39    import static org.junit.Assert.assertNull;
40    import static org.junit.Assert.assertTrue;
41    import static org.junit.Assert.fail;
42    import static org.mockito.Mockito.mock;
43    import static org.mockito.Mockito.when;
44   
45    import info.magnolia.init.MagnoliaConfigurationProperties;
46    import info.magnolia.module.blossom.annotation.DialogFactory;
47    import info.magnolia.module.blossom.annotation.PostCreate;
48    import info.magnolia.module.blossom.annotation.TabFactory;
49    import info.magnolia.module.blossom.annotation.TabOrder;
50    import info.magnolia.test.ComponentsTestUtil;
51    import info.magnolia.ui.dialog.config.DialogBuilder;
52    import info.magnolia.ui.dialog.definition.ConfiguredFormDialogDefinition;
53    import info.magnolia.ui.dialog.definition.DialogDefinition;
54    import info.magnolia.ui.form.config.TabBuilder;
55    import info.magnolia.ui.form.config.TextFieldBuilder;
56    import info.magnolia.ui.form.definition.TabDefinition;
57    import info.magnolia.ui.framework.config.UiConfig;
58   
59    import java.util.ArrayList;
60    import java.util.List;
61   
62    import javax.jcr.Node;
63   
64    import org.junit.Test;
65   
66    import com.vaadin.data.Item;
67   
68    /**
69    * Test case for {@link DefaultDialogCreator}.
70    *
71    * @since 1.0
72    */
 
73    public class DefaultDialogCreatorTest extends DialogTestSupport {
74   
75    // Factories from interfaces are not supported
 
76    public interface AnnotatedInterface {
77   
78    @TabFactory("FromInterface")
79    void foo();
80    }
81   
82    @DialogFactory(value = "some-dialog", label = "TestDialog")
 
83    public static class SimpleFactory implements AnnotatedInterface {
84   
 
85  4 toggle @TabFactory("Properties")
86    public void properties() {
87    }
88   
 
89  3 toggle @TabFactory("Settings")
90    public void settings() {
91    }
92   
 
93  0 toggle @Override
94    public void foo() {
95    }
96    }
97   
98    @DialogFactory("some-dialog")
99    @TabOrder({"Margins", "Sizes", "Properties"})
 
100    public static class InheritingFactory extends SimpleFactory {
101   
 
102  1 toggle @TabFactory("Margins")
103    public void margins(TabBuilder builder, DialogCreationContext context, DialogDefinition dialog, UiConfig cfg) {
104    }
105   
 
106  1 toggle @TabFactory("Sizes")
107    @Override
108    public void settings() {
109    }
110    }
111   
 
112  1 toggle @Test
113    public void testSimpleFactory() throws Exception {
114   
115  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription(new SimpleFactory(), null);
116   
117  1 assertEquals("some-dialog", description.getId());
118  1 assertEquals("TestDialog", description.getFactoryMetaData().getLabel());
119   
120  1 final DialogCreationContext context = new DialogCreationContext();
121  1 DefaultDialogCreator creator = creator();
122  1 creator.createDialog(description.getFactoryMetaData(), context);
123   
124  1 assertHasTabsWithLabels(context.getDialog(), new String[]{"Settings", "Properties"});
125    }
126   
 
127  1 toggle @Test
128    public void testInheritingFactory() throws Exception {
129   
130  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription(new InheritingFactory(), null);
131   
132  1 DialogCreationContext context = new DialogCreationContext();
133  1 DefaultDialogCreator creator = creator();
134  1 creator.createDialog(description.getFactoryMetaData(), context);
135   
136  1 assertHasTabsInLabelOrder(context.getDialog(), new String[]{"Margins", "Sizes", "Properties"});
137    }
138   
 
139    public static class BogusTemplate {
140   
 
141  1 toggle @DialogFactory("some-dialog")
142    public void someDialog(DialogBuilder builder, DialogDefinition dialog, DialogCreationContext context) {
143  1 builder.form().tab("settings").label("Settings");
144    }
145    }
146   
 
147  1 toggle @Test
148    public void testDialogFactoryOnMethod() throws Exception {
149   
150  1 List<BlossomDialogDescription> descriptions = new DialogDescriptionBuilder().buildDescriptions(new BogusTemplate());
151   
152  1 assertEquals(1, descriptions.size());
153   
154  1 BlossomDialogDescription description = descriptions.get(0);
155   
156  1 DialogCreationContext context = new DialogCreationContext();
157  1 DefaultDialogCreator creator = creator();
158  1 creator.createDialog(description.getFactoryMetaData(), context);
159   
160  1 assertHasTabsWithLabels(context.getDialog(), new String[]{"Settings"});
161    }
162   
 
163    public static class TemplateWithDialogFactoryThatNeedsItem {
164   
 
165  1 toggle @DialogFactory("some-dialog")
166    public void someDialog(DialogBuilder builder, Item item) {
167  1 if (item != null) {
168  1 builder.form().tab("gotItem").label("gotItem");
169    }
170    }
171    }
172   
 
173  1 toggle @Test
174    public void testDialogFactoryThatNeedsItem() throws Exception {
175   
176  1 List<BlossomDialogDescription> descriptions = new DialogDescriptionBuilder().buildDescriptions(new TemplateWithDialogFactoryThatNeedsItem());
177   
178  1 assertEquals(1, descriptions.size());
179   
180  1 BlossomDialogDescription description = descriptions.get(0);
181   
182  1 Item mockItem = mock(Item.class);
183  1 DialogCreationContext context = new DialogCreationContext();
184  1 context.setItem(mockItem);
185  1 DefaultDialogCreator creator = creator();
186  1 creator.createDialog(description.getFactoryMetaData(), context);
187   
188  1 assertHasTabsWithLabels(context.getDialog(), new String[]{"gotItem"});
189    }
190   
 
191    public static class DialogFactoryWithTabFactoryThatNeedsItem {
192   
 
193  1 toggle @TabFactory("Content")
194    public void someDialog(TabBuilder builder, Item item) {
195  1 if (item != null) {
196  1 builder.fields(new TextFieldBuilder("gotItem"));
197    }
198    }
199    }
200   
 
201  1 toggle @Test
202    public void testDialogFactoryWithTabFactoryThatNeedsItem() throws Exception {
203   
204  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription("id", "label", new DialogFactoryWithTabFactoryThatNeedsItem());
205   
206  1 Item mockItem = mock(Item.class);
207  1 DialogCreationContext context = new DialogCreationContext();
208  1 context.setItem(mockItem);
209  1 DefaultDialogCreator creator = creator();
210  1 creator.createDialog(description.getFactoryMetaData(), context);
211   
212  1 assertEquals("gotItem", context.getDialog().getForm().getTabs().get(0).getFields().get(0).getName());
213    }
214   
215    private static List<String> events = new ArrayList<String>();
216   
 
217    public static class DialogFactoryWithPostCreateMethod {
218   
 
219  1 toggle @PostCreate
220    public void postCreate() {
221  1 events.add("DialogFactoryWithPostCreateMethod");
222    }
223   
 
224  3 toggle @TabFactory("a")
225    public void a() {
226    }
227    }
228   
 
229    public static class DialogFactoryWithPostCreateMethodExtendingSuperclass extends DialogFactoryWithPostCreateMethod {
230   
 
231  1 toggle @PostCreate
232    public void postCreate2() {
233  1 events.add("DialogFactoryWithPostCreateMethodExtendingSuperclass");
234    }
235    }
236   
 
237  1 toggle @Test
238    public void testPostCreateIsInvokedOnSuperclassesFirst() throws Exception {
239   
240    // GIVEN
241  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription("id", "label", new DialogFactoryWithPostCreateMethodExtendingSuperclass());
242  1 DialogCreationContext context = new DialogCreationContext();
243  1 DefaultDialogCreator creator = creator();
244   
245    // WHEN
246  1 creator.createDialog(description.getFactoryMetaData(), context);
247   
248    // THEN
249  1 assertEquals("DialogFactoryWithPostCreateMethod", events.remove(0));
250  1 assertEquals("DialogFactoryWithPostCreateMethodExtendingSuperclass", events.remove(0));
251  1 assertTrue(events.isEmpty());
252    }
253   
 
254    public static class DialogFactoryWithPostCreateMethodOverridingMethodInSuperclass extends DialogFactoryWithPostCreateMethod {
255   
 
256  1 toggle @PostCreate
257    public void postCreate2() {
258  1 events.add("DialogFactoryWithPostCreateMethodOverridingMethodInSuperclass#postCreate2");
259    }
260   
 
261  1 toggle @Override
262    @PostCreate
263    public void postCreate() {
264  1 events.add("DialogFactoryWithPostCreateMethodOverridingMethodInSuperclass#postCreate");
265    }
266   
 
267  1 toggle @TabFactory("b")
268    public void b() {
269    }
270    }
271   
 
272  1 toggle @Test
273    public void testPostCreateOnMethodInSuperclassThatIsOverriddenIsInvokedFirst() throws Exception {
274   
275    // GIVEN
276  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription("id", "label", new DialogFactoryWithPostCreateMethodOverridingMethodInSuperclass());
277  1 DialogCreationContext context = new DialogCreationContext();
278  1 DefaultDialogCreator creator = creator();
279   
280    // WHEN
281  1 creator.createDialog(description.getFactoryMetaData(), context);
282   
283    // THEN
284  1 assertEquals("DialogFactoryWithPostCreateMethodOverridingMethodInSuperclass#postCreate", events.remove(0));
285  1 assertEquals("DialogFactoryWithPostCreateMethodOverridingMethodInSuperclass#postCreate2", events.remove(0));
286  1 assertTrue(events.isEmpty());
287    }
288   
 
289    public static class DialogFactoryWithPostCreateMethodOverridingMethodInSuperclassWithoutRepeatingAnnotation extends DialogFactoryWithPostCreateMethod {
290   
 
291  0 toggle @Override
292    public void postCreate() {
293  0 events.add("DialogFactoryWithPostCreateMethodOverridingMethodInSuperclassWithoutRepeatingAnnotation#postCreate");
294    }
295    }
296   
 
297  1 toggle @Test
298    public void testPostCreateIsNotInvokedIfMethodIsOverriddenWithoutRepeatingAnnotation() throws Exception {
299   
300    // GIVEN
301  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription("id", "label", new DialogFactoryWithPostCreateMethodOverridingMethodInSuperclassWithoutRepeatingAnnotation());
302  1 DialogCreationContext context = new DialogCreationContext();
303  1 DefaultDialogCreator creator = creator();
304   
305    // WHEN
306  1 creator.createDialog(description.getFactoryMetaData(), context);
307   
308    // THEN
309  1 assertFalse(events.contains("DialogFactoryWithPostCreateMethodOverridingMethodInSuperclassWithoutRepeatingAnnotation#postCreate"));
310  1 assertTrue(events.isEmpty());
311    }
312   
 
313    public static class DialogFactoryWithPostCreateMethodTakingArguments {
314   
 
315  1 toggle @PostCreate
316    public void postCreate(DialogBuilder dialogBuilder, DialogCreationContext context, ConfiguredFormDialogDefinition definition, Node node, Item item, UiConfig cfg) {
317  1 assertNotNull(dialogBuilder);
318  1 assertNotNull(context);
319  1 assertNotNull(definition);
320  1 assertNotNull(node);
321  1 assertNotNull(item);
322  1 assertNotNull(cfg);
323    }
324    }
325   
 
326  1 toggle @Test
327    public void testPostCreateIsInvokedWithArguments() throws Exception {
328   
329    // GIVEN
330  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription("id", "label", new DialogFactoryWithPostCreateMethodTakingArguments());
331  1 DialogCreationContext context = new DialogCreationContext();
332  1 context.setItem(mock(Item.class));
333  1 context.setContentNode(mock(Node.class));
334  1 DefaultDialogCreator creator = creator();
335   
336    // WHEN
337  1 creator.createDialog(description.getFactoryMetaData(), context);
338   
339    // THEN
340    // no exception thrown
341    }
342   
 
343    public static class DialogFactoryWithPostCreateMethodAfterSubclasses {
344   
 
345  1 toggle @TabFactory("tab")
346    public void tabFactory() {
347  1 events.add("DialogFactoryWithPostCreateMethodAfterSubclasses#tabFactory"); // 1
348    }
349   
 
350  1 toggle @PostCreate
351    public void postCreate() {
352  1 events.add("DialogFactoryWithPostCreateMethodAfterSubclasses#postCreate"); // 2
353    }
354   
 
355  1 toggle @PostCreate(PostCreate.Phase.AFTER_SUB_CLASSES)
356    public void postCreateAfterSubclasses() {
357  1 events.add("DialogFactoryWithPostCreateMethodAfterSubclasses#postCreateAfterSubclasses"); // 6
358    }
359    }
360   
 
361    public static class DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass extends DialogFactoryWithPostCreateMethodAfterSubclasses {
362   
 
363  1 toggle @TabFactory("tabInSubClass")
364    public void tabFactory2() {
365  1 events.add("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#tabInSubClass"); // 3
366    }
367   
 
368  1 toggle @PostCreate
369    public void postCreate2() {
370  1 events.add("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#postCreate2"); // 4
371    }
372   
 
373  1 toggle @PostCreate(PostCreate.Phase.AFTER_SUB_CLASSES)
374    public void postCreateAfterSubclasses() {
375  1 events.add("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#postCreateAfterSubclasses"); // 5
376  1 super.postCreateAfterSubclasses();
377    }
378   
 
379  1 toggle @PostCreate(PostCreate.Phase.AFTER_SUB_CLASSES)
380    public void postCreateAfterSubclasses2() {
381  1 events.add("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#postCreateAfterSubclasses2"); // 7
382    }
383    }
384   
 
385  1 toggle @Test
386    public void testPostCreateForAfterSubclassesPhaseIsInvokedLast() throws Exception {
387   
388    // GIVEN
389  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription("id", "label", new DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass());
390  1 DialogCreationContext context = new DialogCreationContext();
391  1 DefaultDialogCreator creator = creator();
392   
393    // WHEN
394  1 creator.createDialog(description.getFactoryMetaData(), context);
395   
396    // THEN
397  1 assertEquals("DialogFactoryWithPostCreateMethodAfterSubclasses#tabFactory", events.remove(0));
398  1 assertEquals("DialogFactoryWithPostCreateMethodAfterSubclasses#postCreate", events.remove(0));
399   
400  1 assertEquals("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#tabInSubClass", events.remove(0));
401  1 assertEquals("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#postCreate2", events.remove(0));
402   
403  1 assertEquals("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#postCreateAfterSubclasses", events.remove(0));
404  1 assertEquals("DialogFactoryWithPostCreateMethodAfterSubclasses#postCreateAfterSubclasses", events.remove(0));
405   
406  1 assertEquals("DialogFactoryWithPostCreateMethodAfterSubclassesExtendingSuperclass#postCreateAfterSubclasses2", events.remove(0));
407   
408  1 assertTrue(events.isEmpty());
409    }
410   
411    @DialogFactory("dialog")
412    @TabOrder({"tab3", "tab2", "tab1"})
 
413    public static class DialogWithTabsOrderedByName {
414   
 
415  1 toggle @TabFactory("tab1")
416    public void tab1(TabBuilder tab) {
417  1 tab.label("this is tab 1");
418    }
419   
 
420  1 toggle @TabFactory("tab2")
421    public void tab2(TabBuilder tab) {
422  1 tab.label("this is tab 2");
423    }
424   
 
425  1 toggle @TabFactory("tab3")
426    public void tab3(TabBuilder tab) {
427  1 tab.label("this is tab 3");
428    }
429    }
430   
 
431  1 toggle @Test
432    public void testSortTabsByName() throws Exception {
433   
434    // GIVEN
435  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription(new DialogWithTabsOrderedByName(), null);
436  1 DialogCreationContext context = new DialogCreationContext();
437  1 mockProperty(DefaultDialogCreator.SORT_TABS_BY_LABEL_PROPERTY_NAME, "false");
438  1 DefaultDialogCreator creator = creator();
439  1 assertFalse(creator.getSortTabsByLabel());
440   
441    // WHEN
442  1 creator.createDialog(description.getFactoryMetaData(), context);
443   
444    // THEN
445  1 assertHasTabsInNameOrder(context.getDialog(), new String[]{"tab3", "tab2", "tab1"});
446    }
447   
448    @DialogFactory("dialog")
449    @TabOrder({"this is tab 3", "this is tab 2", "this is tab 1"})
 
450    public static class DialogWithTabsOrderedByLabel {
451   
 
452  1 toggle @TabFactory("tab1")
453    public void tab1(TabBuilder tab) {
454  1 tab.label("this is tab 1");
455    }
456   
 
457  1 toggle @TabFactory("tab2")
458    public void tab2(TabBuilder tab) {
459  1 tab.label("this is tab 2");
460    }
461   
 
462  1 toggle @TabFactory("tab3")
463    public void tab3(TabBuilder tab) {
464  1 tab.label("this is tab 3");
465    }
466    }
467   
 
468  1 toggle @Test
469    public void testSortTabsByLabel() throws Exception {
470   
471    // GIVEN
472  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription(new DialogWithTabsOrderedByLabel(), null);
473  1 DialogCreationContext context = new DialogCreationContext();
474  1 mockProperty(DefaultDialogCreator.SORT_TABS_BY_LABEL_PROPERTY_NAME, "true");
475  1 DefaultDialogCreator creator = creator();
476  1 assertTrue(creator.getSortTabsByLabel());
477   
478    // WHEN
479  1 creator.createDialog(description.getFactoryMetaData(), context);
480   
481    // THEN
482  1 assertHasTabsInLabelOrder(context.getDialog(), new String[]{"this is tab 3", "this is tab 2", "this is tab 1"});
483    }
484   
 
485  1 toggle @Test
486    public void testSetsBothLabelAndNameByDefault() throws Exception {
487   
488    // GIVEN
489  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription(new SimpleFactory(), null);
490  1 DialogCreationContext context = new DialogCreationContext();
491  1 DefaultDialogCreator creator = creator();
492  1 assertTrue(creator.getSetTabLabels());
493   
494    // WHEN
495  1 creator.createDialog(description.getFactoryMetaData(), context);
496   
497    // THEN
498  1 for (TabDefinition tab : context.getDialog().getForm().getTabs()) {
499  2 assertNotNullOrEmpty(tab.getLabel());
500  2 assertNotNullOrEmpty(tab.getName());
501    }
502    }
503   
 
504  1 toggle @Test
505    public void testSetsNoLabelIfAskedNotTo() throws Exception {
506   
507    // GIVEN
508  1 BlossomDialogDescription description = new DialogDescriptionBuilder().buildDescription(new SimpleFactory(), null);
509  1 DialogCreationContext context = new DialogCreationContext();
510  1 mockProperty(DefaultDialogCreator.SET_TAB_LABELS_PROPERTY_NAME, "false");
511  1 DefaultDialogCreator creator = creator();
512  1 assertFalse(creator.getSetTabLabels());
513   
514    // WHEN
515  1 creator.createDialog(description.getFactoryMetaData(), context);
516   
517    // THEN
518  1 for (TabDefinition tab : context.getDialog().getForm().getTabs()) {
519  2 assertNull(tab.getLabel());
520    }
521    }
522   
 
523  14 toggle private DefaultDialogCreator creator() throws Exception {
524  14 DefaultDialogCreator creator = new DefaultDialogCreator();
525  14 creator.afterPropertiesSet();
526  14 return creator;
527    }
528   
 
529  3 toggle private void mockProperty(String key, String value) {
530  3 MagnoliaConfigurationProperties configurationProperties = mock(MagnoliaConfigurationProperties.class);
531  3 when(configurationProperties.getProperty(key)).thenReturn(value);
532  3 ComponentsTestUtil.setInstance(MagnoliaConfigurationProperties.class, configurationProperties);
533    }
534   
 
535  4 toggle private void assertNotNullOrEmpty(String s) {
536  4 if (s == null) {
537  0 fail("Expected string to not be null, was: " + s);
538  4 } else if (s.length() == 0) {
539  0 fail("Expected string to not be empty, was: " + s);
540    }
541    }
542    }