Changeset 11115 in josm for trunk/test


Ignore:
Timestamp:
2016-10-11T19:05:20+02:00 (3 years ago)
Author:
simon04
Message:

fix #13785 - Use streams, add unit tests (patch by alno, modified)

Location:
trunk/test/unit/org/openstreetmap/josm/data/osm
Files:
3 added
1 edited

Legend:

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

    r11105 r11115  
    77import static org.junit.Assert.assertTrue;
    88
     9import java.util.ArrayList;
     10import java.util.Collections;
    911import java.util.List;
    1012
     13import org.junit.Assert;
    1114import org.junit.Test;
    1215import org.openstreetmap.josm.TestUtils;
     
    180183        cache.removeChangesetCacheListener(listener);
    181184    }
     185
     186    /**
     187     * Unit test of method {@link ChangesetCache#getOpenChangesets}.
     188     */
     189    @Test
     190    public void testGetOpenChangesets() {
     191        final ChangesetCache cache = ChangesetCache.getInstance();
     192        // empty cache => empty list
     193        Assert.assertTrue(
     194                "Empty cache should produce an empty list.",
     195                cache.getOpenChangesets().isEmpty()
     196        );
     197
     198        // cache with only closed changesets => empty list
     199        Changeset closedCs = new Changeset(1);
     200        closedCs.setOpen(false);
     201        cache.update(closedCs);
     202        Assert.assertTrue(
     203                "Cache with only closed changesets should produce an empty list.",
     204                cache.getOpenChangesets().isEmpty()
     205        );
     206
     207        // cache with open and closed changesets => list with only the open ones
     208        Changeset openCs = new Changeset(2);
     209        openCs.setOpen(true);
     210        cache.update(openCs);
     211        Assert.assertEquals(
     212                Collections.singletonList(openCs),
     213                cache.getOpenChangesets()
     214        );
     215    }
    182216}
Note: See TracChangeset for help on using the changeset viewer.