Changeset 11914 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-04-15T02:00:43+02:00 (3 years ago)
Author:
Don-vip
Message:

sonar - squid:S2972 - Inner classes should not have too many lines of code

Location:
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java

    r10335 r11914  
    44import static org.junit.Assert.assertEquals;
    55
    6 import java.text.ParseException;
    76import java.util.Arrays;
    87import java.util.Collections;
     
    109
    1110import org.junit.BeforeClass;
     11import org.junit.Rule;
    1212import org.junit.Test;
    13 import org.openstreetmap.josm.JOSMFixture;
    1413import org.openstreetmap.josm.data.coor.CachedLatLon;
    1514import org.openstreetmap.josm.data.gpx.GpxData;
    1615import org.openstreetmap.josm.io.GpxReaderTest;
     16import org.openstreetmap.josm.testutils.JOSMTestRules;
    1717import org.openstreetmap.josm.tools.Pair;
    1818import org.openstreetmap.josm.tools.date.DateUtils;
    1919import org.openstreetmap.josm.tools.date.DateUtilsTest;
    2020
     21import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     22
    2123/**
    22  * Unit tests of {@link CorrelateGpxWithImagesTest} class.
     24 * Unit tests of {@link CorrelateGpxWithImages} class.
    2325 */
    2426public class CorrelateGpxWithImagesTest {
     
    2729     * Setup test.
    2830     */
     31    @Rule
     32    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     33    public JOSMTestRules test = new JOSMTestRules();
     34
     35    /**
     36     * Setup test.
     37     */
    2938    @BeforeClass
    3039    public static void setUp() {
    31         JOSMFixture.createUnitTestFixture().init();
    3240        DateUtilsTest.setTimeZone(TimeZone.getTimeZone("UTC"));
    3341    }
     
    7583        i0.setExifTime(DateUtils.fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX
    7684        i0.createTmp();
    77         assertEquals(Pair.create(CorrelateGpxWithImages.Timezone.ZERO, CorrelateGpxWithImages.Offset.seconds(-4)),
     85        assertEquals(Pair.create(Timezone.ZERO, Offset.seconds(-4)),
    7886                CorrelateGpxWithImages.autoGuess(Collections.singletonList(i0), gpx));
    7987    }
    80 
    81     /**
    82      * Unit test of {@link CorrelateGpxWithImages.Timezone#formatTimezone}.
    83      */
    84     @Test
    85     public void testFormatTimezone() {
    86         assertEquals("+1:00", new CorrelateGpxWithImages.Timezone(1).formatTimezone());
    87         assertEquals("+6:30", new CorrelateGpxWithImages.Timezone(6.5).formatTimezone());
    88         assertEquals("-6:30", new CorrelateGpxWithImages.Timezone(-6.5).formatTimezone());
    89         assertEquals("+3:08", new CorrelateGpxWithImages.Timezone(Math.PI).formatTimezone());
    90         assertEquals("+2:43", new CorrelateGpxWithImages.Timezone(Math.E).formatTimezone());
    91     }
    92 
    93     /**
    94      * Unit test of {@link CorrelateGpxWithImages.Timezone#parseTimezone}.
    95      * @throws ParseException in case of parsing error
    96      */
    97     @Test
    98     public void testParseTimezone() throws ParseException {
    99         assertEquals(1, CorrelateGpxWithImages.Timezone.parseTimezone("+01:00").getHours(), 1e-3);
    100         assertEquals(1, CorrelateGpxWithImages.Timezone.parseTimezone("+1:00").getHours(), 1e-3);
    101         assertEquals(1.5, CorrelateGpxWithImages.Timezone.parseTimezone("+01:30").getHours(), 1e-3);
    102         assertEquals(11.5, CorrelateGpxWithImages.Timezone.parseTimezone("+11:30").getHours(), 1e-3);
    103     }
    104 
    105     /**
    106      * Unit test of {@link CorrelateGpxWithImages.Offset#formatOffset}.
    107      */
    108     @Test
    109     public void testFormatOffset() {
    110         assertEquals("0", CorrelateGpxWithImages.Offset.seconds(0).formatOffset());
    111         assertEquals("123", CorrelateGpxWithImages.Offset.seconds(123).formatOffset());
    112         assertEquals("-4242", CorrelateGpxWithImages.Offset.seconds(-4242).formatOffset());
    113         assertEquals("0.1", CorrelateGpxWithImages.Offset.milliseconds(100).formatOffset());
    114         assertEquals("0.120", CorrelateGpxWithImages.Offset.milliseconds(120).formatOffset());
    115         assertEquals("0.123", CorrelateGpxWithImages.Offset.milliseconds(123).formatOffset());
    116         assertEquals("1.2", CorrelateGpxWithImages.Offset.milliseconds(1200).formatOffset());
    117         assertEquals("1.234", CorrelateGpxWithImages.Offset.milliseconds(1234).formatOffset());
    118     }
    119 
    120     /**
    121      * Unit test of {@link CorrelateGpxWithImages.Offset#parseOffset}.
    122      * @throws ParseException in case of parsing error
    123      */
    124     @Test
    125     public void testParseOffest() throws ParseException {
    126         assertEquals(0, CorrelateGpxWithImages.Offset.parseOffset("0").getSeconds());
    127         assertEquals(4242L, CorrelateGpxWithImages.Offset.parseOffset("4242").getSeconds());
    128         assertEquals(-4242L, CorrelateGpxWithImages.Offset.parseOffset("-4242").getSeconds());
    129         assertEquals(0L, CorrelateGpxWithImages.Offset.parseOffset("-0").getSeconds());
    130         assertEquals(100L, CorrelateGpxWithImages.Offset.parseOffset("0.1").getMilliseconds());
    131         assertEquals(123L, CorrelateGpxWithImages.Offset.parseOffset("0.123").getMilliseconds());
    132         assertEquals(-42420L, CorrelateGpxWithImages.Offset.parseOffset("-42.42").getMilliseconds());
    133     }
    134 
    135     /**
    136      * Unit test of {@link CorrelateGpxWithImages.Offset#splitOutTimezone}.
    137      */
    138     @Test
    139     public void testSplitOutTimezone() {
    140         assertEquals("+1:00", CorrelateGpxWithImages.Offset.seconds(3602).splitOutTimezone().a.formatTimezone());
    141         assertEquals("2", CorrelateGpxWithImages.Offset.seconds(3602).splitOutTimezone().b.formatOffset());
    142         assertEquals("-7:00", CorrelateGpxWithImages.Offset.seconds(-7 * 3600 + 123).splitOutTimezone().a.formatTimezone());
    143         assertEquals("123", CorrelateGpxWithImages.Offset.seconds(-7 * 3600 + 123).splitOutTimezone().b.formatOffset());
    144         assertEquals(1, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).getDayOffset());
    145         assertEquals(11 * 3600 + 421, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).withoutDayOffset().getSeconds());
    146         assertEquals("+11:00", CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).splitOutTimezone().a.formatTimezone());
    147         assertEquals(86400 + 421, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).splitOutTimezone().b.getSeconds());
    148         assertEquals(421, CorrelateGpxWithImages.Offset.seconds(35 * 3600 + 421).withoutDayOffset().splitOutTimezone().b.getSeconds());
    149         assertEquals("+1:00", CorrelateGpxWithImages.Offset.milliseconds(3602987).splitOutTimezone().a.formatTimezone());
    150         assertEquals("2.987", CorrelateGpxWithImages.Offset.milliseconds(3602987).splitOutTimezone().b.formatOffset());
    151     }
    15288}
Note: See TracChangeset for help on using the changeset viewer.