Changeset 10347 in josm


Ignore:
Timestamp:
2016-06-09T10:58:26+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - add unit test to see if squid:S1244 can be safely disabled

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java

    r10308 r10347  
    5656
    5757    /**
    58      * InvalidSelection exception has to be raised when action can't be perform
    59      */
    60     private static class InvalidSelection extends Exception {
     58     * InvalidSelection exception has to be raised when action can't be performed
     59     */
     60    static class InvalidSelection extends Exception {
    6161
    6262        /**
     
    6969        /**
    7070         * Create an InvalidSelection exception with specific message
    71          * @param msg Message that will be display to the user
     71         * @param msg Message that will be displayed to the user
    7272         */
    7373        InvalidSelection(String msg) {
     
    343343     * Class that represent a line
    344344     */
    345     private static class Line {
     345    static class Line {
    346346
    347347        /**
  • trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java

    r9661 r10347  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertNotNull;
    56
    67import org.junit.BeforeClass;
     
    89import org.openstreetmap.josm.JOSMFixture;
    910import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.actions.AlignInLineAction.InvalidSelection;
     12import org.openstreetmap.josm.actions.AlignInLineAction.Line;
    1013import org.openstreetmap.josm.data.coor.EastNorth;
    1114import org.openstreetmap.josm.data.coor.LatLon;
     
    189192        assertEquals("Wrong y coordinate.", y, coordinate.getY(), LatLon.MAX_SERVER_PRECISION);
    190193    }
     194
     195    /**
     196     * Test that a {@link Line} can be constructed with nodes of different coordinates.
     197     * @throws InvalidSelection never
     198     */
     199    @Test
     200    public void testLineDifferentCoordinates() throws InvalidSelection {
     201        assertNotNull(new Line(new Node(new EastNorth(0, 1)),
     202                               new Node(new EastNorth(0, 2))));
     203        assertNotNull(new Line(new Node(new EastNorth(0, 1)),
     204                               new Node(new EastNorth(1, 1))));
     205        assertNotNull(new Line(new Node(new EastNorth(0, 1)),
     206                               new Node(new EastNorth(0+1e-150, 1+1e-150))));
     207    }
     208
     209    /**
     210     * Test that a {@link Line} cannot be constructed with nodes of same coordinates.
     211     * @throws InvalidSelection always
     212     */
     213    @Test(expected = InvalidSelection.class)
     214    public void testLineSameCoordinates1() throws InvalidSelection {
     215        new Line(new Node(new EastNorth(0, 1)),
     216                 new Node(new EastNorth(0, 1)));
     217    }
     218
     219    /**
     220     * Test that a {@link Line} cannot be constructed with nodes of same coordinates.
     221     * @throws InvalidSelection always
     222     */
     223    @Test(expected = InvalidSelection.class)
     224    public void testLineSameCoordinates2() throws InvalidSelection {
     225        new Line(new Node(new EastNorth(0, 1)),
     226                 new Node(new EastNorth(0+1e-175, 1+1e-175)));
     227    }
    191228}
Note: See TracChangeset for help on using the changeset viewer.