Changeset 17310 in josm for trunk/test/unit


Ignore:
Timestamp:
2020-11-14T16:31:36+01:00 (4 years ago)
Author:
Don-vip
Message:

see #16567 - rewrite ImageDataTest to get rid of problematic JMockit annotation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/ImageDataTest.java

    r17275 r17310  
    99import java.io.File;
    1010import java.util.ArrayList;
     11import java.util.Arrays;
    1112import java.util.Collections;
     13import java.util.Date;
    1214import java.util.List;
    1315
     
    2022import mockit.Mock;
    2123import mockit.MockUp;
    22 import mockit.Mocked;
    23 import mockit.Verifications;
    2424
    2525/**
     
    2828class ImageDataTest {
    2929
     30    private static ImageEntry newImageEntry(String file, Date exifTime) {
     31        ImageEntry entry = new ImageEntry(new File(file));
     32        entry.setExifTime(exifTime);
     33        return entry;
     34    }
     35
    3036    private static List<ImageEntry> getOneImage() {
    3137        ArrayList<ImageEntry> list = new ArrayList<>();
    32         list.add(new ImageEntry(new File("test")));
     38        list.add(newImageEntry("test", null));
    3339        return list;
    3440    }
     
    5864
    5965    @Test
    60     void testSortData(@Mocked Collections ignore) {
    61         List<ImageEntry> list = getOneImage();
    62 
    63         new ImageData(list);
    64 
    65         new Verifications() {{
    66             Collections.sort(list);
    67         }};
     66    void testSortData() {
     67        ImageEntry entry1 = newImageEntry("test1", new Date(1_000_000));
     68        ImageEntry entry2 = newImageEntry("test2", new Date(2_000_000));
     69
     70        ArrayList<ImageEntry> list = new ArrayList<>();
     71        list.add(entry2);
     72        list.add(entry1);
     73
     74        assertEquals(Arrays.asList(entry1, entry2), new ImageData(list).getImages());
    6875    }
    6976
Note: See TracChangeset for help on using the changeset viewer.