Changeset 10638 in josm for trunk/test


Ignore:
Timestamp:
2016-07-25T21:19:38+02:00 (3 years ago)
Author:
Don-vip
Message:

see #11390, fix #13206 - Migrate Function interface to java 8 (patch by michael2402, modified) - gsoc-core

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java

    r9938 r10638  
    1010import java.util.EnumSet;
    1111import java.util.List;
     12import java.util.stream.Collectors;
    1213
    1314import org.junit.BeforeClass;
     
    2021import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassification;
    2122import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassifications;
    22 import org.openstreetmap.josm.tools.Utils;
    2323import org.xml.sax.SAXException;
    2424
     
    4848
    4949    private List<String> getMatchingPresetNames(String searchText, OsmPrimitive w) {
    50         return Utils.transform(getMatchingPresets(searchText, w), new Utils.Function<PresetClassification, String>() {
    51             @Override
    52             public String apply(PresetClassification x) {
    53                 return x.preset.name;
    54             }
    55         });
     50        return getMatchingPresets(searchText, w).stream().map(x -> x.preset.name).collect(Collectors.toList());
    5651    }
    5752
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java

    r10378 r10638  
    55import static org.junit.Assert.assertEquals;
    66import static org.junit.Assert.assertThat;
     7import static org.junit.Assert.assertTrue;
    78
    89import java.io.IOException;
    910import java.util.Collection;
    1011import java.util.List;
     12import java.util.stream.Collectors;
    1113
    1214import org.junit.Assert;
     
    1719import org.openstreetmap.josm.gui.tagging.presets.items.Check;
    1820import org.openstreetmap.josm.gui.tagging.presets.items.Key;
    19 import org.openstreetmap.josm.tools.Utils;
    2021import org.xml.sax.SAXException;
    2122
     
    5960        assertThat(presets, hasSize(1));
    6061        final TaggingPreset abc = presets.iterator().next();
    61         final List<String> keys = Utils.transform(abc.data, new Utils.Function<TaggingPresetItem, String>() {
    62             @Override
    63             public String apply(TaggingPresetItem x) {
    64                 return x instanceof Key ? ((Key) x).key : null;
    65             }
    66         });
     62        assertTrue(abc.data.stream().allMatch(Key.class::isInstance));
     63        final List<String> keys = abc.data.stream().map(x -> ((Key) x).key).collect(Collectors.toList());
    6764        assertEquals("[A1, A2, A3, B1, B2, B3, C1, C2, C3]", keys.toString());
    6865    }
  • trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java

    r9958 r10638  
    22package org.openstreetmap.josm.io;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.Assert.assertArrayEquals;
    55
    66import java.util.ArrayList;
     
    1111import org.junit.Test;
    1212import org.openstreetmap.josm.data.osm.NodeData;
    13 import org.openstreetmap.josm.tools.Utils;
    1413
    1514/**
     
    3332        Collections.sort(ids, OsmWriter.byIdComparator);
    3433
    35         final String idsAsString = Utils.transform(ids, new Utils.Function<NodeData, Object>() {
    36             @Override
    37             public Object apply(NodeData x) {
    38                 return x.getUniqueId();
    39             }
    40         }).toString();
    41 
    42         assertEquals("[-3, -12, -20, -9223372036854775808, 0, 2, 12, 65, 9223372036854775807]", idsAsString);
     34        final long[] longIds = ids.stream().mapToLong(x -> x.getUniqueId()).toArray();
     35        assertArrayEquals(new long[] {
     36                -3, -12, -20, -9223372036854775808L, 0, 2, 12, 65, 9223372036854775807L
     37        }, longIds);
    4338    }
    4439}
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r10513 r10638  
    88import java.net.URL;
    99import java.util.Arrays;
     10import java.util.Collections;
     11import java.util.List;
    1012import java.util.Locale;
    1113
     
    176178     */
    177179    @Test
    178     public void testSizeString() throws Exception {
     180    public void testSizeString() {
    179181        assertEquals("0 B", Utils.getSizeString(0, Locale.ENGLISH));
    180182        assertEquals("123 B", Utils.getSizeString(123, Locale.ENGLISH));
     
    189191     */
    190192    @Test(expected = IllegalArgumentException.class)
    191     public void testSizeStringNegative() throws Exception {
     193    public void testSizeStringNegative() {
    192194        Utils.getSizeString(-1, Locale.ENGLISH);
    193195    }
    194196
     197    /**
     198     * Test {@link Utils#joinAsHtmlUnorderedList(Iterable)}
     199     */
     200    @Test
     201    public void joinAsHtmlUnorderedList() {
     202        List<? extends Object> items = Arrays.asList("1", new Integer(2));
     203        assertEquals("<ul><li>1</li><li>2</li></ul>", Utils.joinAsHtmlUnorderedList(items));
     204        assertEquals("<ul></ul>", Utils.joinAsHtmlUnorderedList(Collections.emptyList()));
     205    }
    195206}
Note: See TracChangeset for help on using the changeset viewer.