Clover icon

Magnolia Imaging Module 3.2.3

  1. Project Clover database Fri Nov 6 2015 14:54:03 CET
  2. Package info.magnolia.imaging.operations.cropresize

File SelectedCropAndResizeTest.java

 

Code metrics

0
9
1
1
96
17
1
0.11
9
1
1

Classes

Class Line # Actions
SelectedCropAndResizeTest 43 9 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /**
2    * This file Copyright (c) 2007-2015 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.imaging.operations.cropresize;
35   
36    import static org.junit.Assert.*;
37   
38    import org.junit.Test;
39   
40    /**
41    * Tests for {@link info.magnolia.imaging.operations.cropresize.SelectedCropAndResize}.
42    */
 
43    public class SelectedCropAndResizeTest {
44   
45    /**
46    * This is how cropper info was stored with the now defunct imagefiltering module.
47    * The syntax/structure might change in the future, but we should still be able to decode such
48    * strings at least until the next major version.
49    */
 
50  1 toggle @Test
51    public void testCanDecodeLegacyCropInfoStrings() {
52  1 final String legacyJsonString = "{\"CropperInfo\":{\"configName\":\"screenshot\",\"coords\":{\"x1\":424,\"y1\":174,\"x2\":1138,\"y2\":650}}}";
53  1 final CroppingInfo croppingInfo = new SelectedCropAndResize().decode(legacyJsonString);
54  1 assertEquals("screenshot", croppingInfo.getConfigName());
55  1 final Coords coords = croppingInfo.getCoords();
56  1 assertNotNull(coords);
57  1 assertEquals(424, coords.getX1());
58  1 assertEquals(174, coords.getY1());
59  1 assertEquals(1138, coords.getX2());
60  1 assertEquals(650, coords.getY2());
61    }
62   
63    /**
64    * This test is now irrelevant since this is configured at operation level using content2bean
65    * Keeping the test around because we'll need something similar for ui - when we figure out
66    * how to connect the two together.
67    *
68    *
69    public void testGetsTargetWidthAndHeightFromSpecifiedConfigSubNode() throws IOException {
70    final Content configNode = createStrictMock(Content.class);
71    final Content configSubNode = createStrictMock(Content.class);
72    final NodeData targetWidth = createStrictMock(NodeData.class);
73    final NodeData targetHeight = createStrictMock(NodeData.class);
74    expect(configNode.getChildByName("foo")).andReturn(configSubNode);
75    expect(configSubNode.getNodeData("targetWidth")).andReturn(targetWidth);
76    expect(configSubNode.getNodeData("targetHeight")).andReturn(targetHeight);
77    expect(targetWidth.getLong()).andReturn(234l);
78    expect(targetHeight.getLong()).andReturn(567l);
79   
80    replay(configNode, configSubNode, targetWidth, targetHeight);
81   
82    final BufferedImage dummyImg = ImageIO.read(getClass().getResourceAsStream("/funnel.gif"));
83    final Coords cropCoords = new Coords(0, 0, 16, 8);
84    final CropperInfo cropInfo = new CropperInfo("foo", cropCoords);
85    final CropAndResize op = new CropAndResize();
86    op.setTargetWidth(234);
87    op.setTargetHeight(567);
88    final BufferedImage result = op.apply(dummyImg, cropInfo, configNode);
89    assertEquals(234, result.getWidth());
90    assertEquals(567, result.getHeight());
91   
92    verify(configNode, configSubNode, targetWidth, targetHeight);
93    }
94    */
95   
96    }