Clover icon

Magnolia Crop UI for Imaging Module 3.2.7

  1. Project Clover database Fri Sep 9 2016 14:52:54 CEST
  2. Package info.magnolia.module.cropui

File CropperPageTest.java

 

Code metrics

4
21
4
1
97
53
6
0.29
5.25
4
1.5

Classes

Class Line # Actions
CropperPageTest 58 21 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /**
2    * This file Copyright (c) 2007-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.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    * Tests for {@link CropperPage}.
57    */
 
58    public class CropperPageTest {
59   
 
60  1 toggle @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   
 
68  1 toggle @After
69    public void tearDown() throws Exception {
70  1 Components.setComponentProvider(null);
71    }
72   
 
73  1 toggle @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   
 
85  8 toggle 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    }