Changeset 16161 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2020-03-17T20:09:43+01:00 (5 years ago)
Author:
simon04
Message:

see #18948 - Get rid of remaining com.google.common.collect

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

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtilTest.java

    r14201 r16161  
    1111import java.util.HashSet;
    1212import java.util.List;
     13import java.util.stream.Collectors;
    1314
    1415import org.junit.Rule;
     
    2122import org.openstreetmap.josm.testutils.JOSMTestRules;
    2223
    23 import com.google.common.collect.Sets;
    24 
    2524import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2625
     
    3635    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3736    public JOSMTestRules test = new JOSMTestRules();
     37
     38    @SafeVarargs
     39    private static <T> HashSet<T> newHashSet(T... values) {
     40        return Arrays.stream(values).collect(Collectors.toCollection(HashSet::new));
     41    }
    3842
    3943    /**
     
    4852        tc.add(new Tag("building", "garage"));
    4953        TagConflictResolutionUtil.applyAutomaticTagConflictResolution(tc);
    50         assertEquals(Sets.newHashSet("school", "garage"), new HashSet<>(tc.getValues("building")));
     54        assertEquals(newHashSet("school", "garage"), new HashSet<>(tc.getValues("building")));
    5155
    5256        // Check US Tiger tag conflict resolution
     
    5559        tc.add(new Tag("tiger:test", "A"));
    5660        TagConflictResolutionUtil.applyAutomaticTagConflictResolution(tc);
    57         assertEquals(Sets.newHashSet("A:B"), new HashSet<>(tc.getValues("tiger:test")));
     61        assertEquals(newHashSet("A:B"), new HashSet<>(tc.getValues("tiger:test")));
    5862
    5963        // Check FR:cadastre source tag conflict resolution (most common values from taginfo except last one without accentuated characters)
     
    8488        tc.remove(otherSource);
    8589        TagConflictResolutionUtil.applyAutomaticTagConflictResolution(tc);
    86         assertEquals(Sets.newHashSet("cadastre-dgi-fr source : Direction Generale des Finances Publiques - Cadastre. Mise a jour : 2015"),
     90        assertEquals(newHashSet("cadastre-dgi-fr source : Direction Generale des Finances Publiques - Cadastre. Mise a jour : 2015"),
    8791                new HashSet<>(tc.getValues("source")));
    8892
     
    97101        tc.add(new Tag("source", "NRCan-CanVec-12.0"));
    98102        TagConflictResolutionUtil.applyAutomaticTagConflictResolution(tc);
    99         assertEquals(Sets.newHashSet("NRCan-CanVec-12.0"), new HashSet<>(tc.getValues("source")));
     103        assertEquals(newHashSet("NRCan-CanVec-12.0"), new HashSet<>(tc.getValues("source")));
    100104    }
    101105
     
    209213        public void testResolve() {
    210214            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine("random", "", true, "|", "String"))) {
    211                 assertEquals(resolver.resolve(Sets.newHashSet("value1", "value2")), "value1|value2");
    212                 assertEquals(resolver.resolve(Sets.newHashSet("3|1", "4|2|1", "6|05", "3;1")), "05|1|2|3|3;1|4|6");
     215                assertEquals(resolver.resolve(newHashSet("value1", "value2")), "value1|value2");
     216                assertEquals(resolver.resolve(newHashSet("3|1", "4|2|1", "6|05", "3;1")), "05|1|2|3|3;1|4|6");
    213217            }
    214218
    215219            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine("test[45].*", "", true, ";", "Integer"))) {
    216                 assertEquals(resolver.resolve(Sets.newHashSet("1254545;95;24", "25;24;3")), "3;24;25;95;1254545");
     220                assertEquals(resolver.resolve(newHashSet("1254545;95;24", "25;24;3")), "3;24;25;95;1254545");
    217221            }
    218222
    219223            for (AutomaticCombine resolver: differentlyConstructed(new AutomaticCombine("AB", "", true, ";", null))) {
    220                 String resolution = resolver.resolve(Sets.newHashSet("3;x;1", "4;x"));
     224                String resolution = resolver.resolve(newHashSet("3;x;1", "4;x"));
    221225                assertTrue(resolution.equals("3;x;1;4") || resolution.equals("4;x;3;1"));
    222226            }
     
    383387            assertEquals(group1.key, choiceKey1Group1.key);
    384388            assertEquals(group1.group, choiceKey1Group1.group);
    385             assertEquals(new HashSet<>(group1.choices), Sets.newHashSet(choiceKey1Group1, choiceKey1Group1bis));
     389            assertEquals(new HashSet<>(group1.choices), newHashSet(choiceKey1Group1, choiceKey1Group1bis));
    386390
    387391            groups = AutomaticChoiceGroup.groupChoices(Arrays.asList(
     
    428432                    choiceKey1Group1.key, choiceKey1Group1.group, choiceKey1Group1.isRegex,
    429433                    Arrays.asList(choiceKey1Group1, choiceKey1Group1bis));
    430             assertEquals(group.resolve(Sets.newHashSet(choiceKey1Group1.value)), choiceKey1Group1.value);
    431             assertEquals(group.resolve(Sets.newHashSet(choiceKey1Group1.value, choiceKey1Group1bis.value)), choiceKey1Group1bis.value);
    432             assertNull(group.resolve(Sets.newHashSet("random", choiceKey1Group1.value, choiceKey1Group1bis.value)));
     434            assertEquals(group.resolve(newHashSet(choiceKey1Group1.value)), choiceKey1Group1.value);
     435            assertEquals(group.resolve(newHashSet(choiceKey1Group1.value, choiceKey1Group1bis.value)), choiceKey1Group1bis.value);
     436            assertNull(group.resolve(newHashSet("random", choiceKey1Group1.value, choiceKey1Group1bis.value)));
    433437
    434438            group = new AutomaticChoiceGroup(
    435439                    choiceKey2Group1.key, choiceKey2Group2.group, choiceKey2Group2.isRegex,
    436440                    Arrays.asList(choiceKey2Group2, choiceKey2Group2bis));
    437             assertEquals(group.resolve(Sets.newHashSet("value1")), "value1");
    438             assertEquals(group.resolve(Sets.newHashSet("value1Z", "value2A")), "value1Z");
    439             assertEquals(group.resolve(Sets.newHashSet("value1A", "value2Z")), "value2Z");
    440             assertNull(group.resolve(Sets.newHashSet("value1Z", "value2A", "other not matched value")));
     441            assertEquals(group.resolve(newHashSet("value1")), "value1");
     442            assertEquals(group.resolve(newHashSet("value1Z", "value2A")), "value1Z");
     443            assertEquals(group.resolve(newHashSet("value1A", "value2Z")), "value2Z");
     444            assertNull(group.resolve(newHashSet("value1Z", "value2A", "other not matched value")));
    441445        }
    442446    }
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java

    r16159 r16161  
    1111import java.io.File;
    1212import java.nio.file.Files;
     13import java.util.ArrayList;
     14import java.util.Arrays;
    1315import java.util.Collection;
    1416import java.util.Collections;
     17import java.util.stream.Collectors;
    1518
    1619import javax.swing.JOptionPane;
     
    2629import org.openstreetmap.josm.gui.util.GuiHelper;
    2730import org.openstreetmap.josm.plugins.PluginHandler;
     31import org.openstreetmap.josm.plugins.PluginInformation;
    2832import org.openstreetmap.josm.plugins.PluginProxy;
    2933import org.openstreetmap.josm.spi.preferences.Config;
     
    3539import com.github.tomakehurst.wiremock.client.WireMock;
    3640import com.github.tomakehurst.wiremock.junit.WireMockRule;
    37 import com.google.common.collect.ImmutableList;
    3841
    3942import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    7982            "pluginList"
    8083        );
    81         this.originalPluginList = ImmutableList.copyOf(pluginList);
     84        this.originalPluginList = new ArrayList<>(pluginList);
    8285        pluginList.clear();
    8386
     
    8588        Config.getPref().put("pluginmanager.lastupdate", "999");
    8689        Config.getPref().putList("pluginmanager.sites",
    87             ImmutableList.of(String.format("http://localhost:%s/plugins", this.pluginServerRule.port()))
     90            Collections.singletonList(String.format("http://localhost:%s/plugins", this.pluginServerRule.port()))
    8891        );
    8992
     
    140143        );
    141144        pluginServer.applyToWireMockServer(this.pluginServerRule);
    142         Config.getPref().putList("plugins", ImmutableList.of("dummy_plugin"));
     145        Config.getPref().putList("plugins", Collections.singletonList("dummy_plugin"));
    143146
    144147        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(
     
    181184
    182185        assertEquals(
    183             ImmutableList.of("baz_plugin", "dummy_plugin", "irrelevant_plugin"),
    184             model.getAvailablePlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    185         );
    186         assertEquals(
    187             ImmutableList.of("dummy_plugin"),
    188             model.getSelectedPlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    189         );
    190         assertEquals(
    191             ImmutableList.of("(null)", "31701", "(null)"),
     186            Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"),
     187            model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     188        );
     189        assertEquals(
     190            Collections.singletonList("dummy_plugin"),
     191            model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     192        );
     193        assertEquals(
     194            Arrays.asList("(null)", "31701", "(null)"),
    192195            model.getAvailablePlugins().stream().map(
    193196                (pi) -> pi.localversion == null ? "(null)" : pi.localversion
    194             ).collect(ImmutableList.toImmutableList())
    195         );
    196         assertEquals(
    197             ImmutableList.of("6", "31772", "2"),
    198             model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(ImmutableList.toImmutableList())
     197            ).collect(Collectors.toList())
     198        );
     199        assertEquals(
     200            Arrays.asList("6", "31772", "2"),
     201            model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())
    199202        );
    200203
     
    203206
    204207        assertEquals(
    205             ImmutableList.of("baz_plugin"),
    206             model.getNewlyActivatedPlugins().stream().map(
    207                 (pi) -> pi.getName()
    208             ).collect(ImmutableList.toImmutableList())
    209         );
    210         assertTrue(model.getNewlyDeactivatedPlugins().isEmpty());
    211         assertEquals(
    212             ImmutableList.of("baz_plugin"),
    213             model.getPluginsScheduledForUpdateOrDownload().stream().map(
    214                 (pi) -> pi.getName()
    215             ).collect(ImmutableList.toImmutableList())
     208            Collections.singletonList("baz_plugin"),
     209            model.getNewlyActivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     210        );
     211        assertTrue(model.getNewlyDeactivatedPlugins().isEmpty());
     212        assertEquals(
     213            Collections.singletonList("baz_plugin"),
     214            model.getPluginsScheduledForUpdateOrDownload().stream().map(PluginInformation::getName).collect(Collectors.toList())
    216215        );
    217216
     
    248247        // baz_plugin should have been added to the plugins list
    249248        assertEquals(
    250             ImmutableList.of("baz_plugin", "dummy_plugin"),
    251             Config.getPref().getList("plugins", null).stream().sorted().collect(ImmutableList.toImmutableList())
     249            Arrays.asList("baz_plugin", "dummy_plugin"),
     250            Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList())
    252251        );
    253252    }
     
    265264        );
    266265        pluginServer.applyToWireMockServer(this.pluginServerRule);
    267         Config.getPref().putList("plugins", ImmutableList.of("baz_plugin", "dummy_plugin"));
     266        Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin"));
    268267
    269268        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(
     
    305304
    306305        assertEquals(
    307             ImmutableList.of("baz_plugin", "dummy_plugin", "irrelevant_plugin"),
    308             model.getAvailablePlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    309         );
    310         assertEquals(
    311             ImmutableList.of("baz_plugin", "dummy_plugin"),
    312             model.getSelectedPlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    313         );
    314         assertEquals(
    315             ImmutableList.of("6", "31701", "(null)"),
     306            Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"),
     307            model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     308        );
     309        assertEquals(
     310            Arrays.asList("baz_plugin", "dummy_plugin"),
     311            model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     312        );
     313        assertEquals(
     314            Arrays.asList("6", "31701", "(null)"),
    316315            model.getAvailablePlugins().stream().map(
    317316                (pi) -> pi.localversion == null ? "(null)" : pi.localversion
    318             ).collect(ImmutableList.toImmutableList())
    319         );
    320         assertEquals(
    321             ImmutableList.of("7", "31772", "(null)"),
     317            ).collect(Collectors.toList())
     318        );
     319        assertEquals(
     320            Arrays.asList("7", "31772", "(null)"),
    322321            model.getAvailablePlugins().stream().map(
    323322                (pi) -> pi.version == null ? "(null)" : pi.version
    324             ).collect(ImmutableList.toImmutableList())
     323            ).collect(Collectors.toList())
    325324        );
    326325
     
    330329        assertTrue(model.getNewlyActivatedPlugins().isEmpty());
    331330        assertEquals(
    332             ImmutableList.of("baz_plugin"),
    333             model.getNewlyDeactivatedPlugins().stream().map(
    334                 (pi) -> pi.getName()
    335             ).collect(ImmutableList.toImmutableList())
     331            Collections.singletonList("baz_plugin"),
     332            model.getNewlyDeactivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
    336333        );
    337334        // questionably correct
     
    369366        // baz_plugin should have been removed from the installed plugins list
    370367        assertEquals(
    371             ImmutableList.of("dummy_plugin"),
    372             Config.getPref().getList("plugins", null).stream().sorted().collect(ImmutableList.toImmutableList())
     368            Collections.singletonList("dummy_plugin"),
     369            Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList())
    373370        );
    374371    }
     
    389386        );
    390387        pluginServer.applyToWireMockServer(this.pluginServerRule);
    391         Config.getPref().putList("plugins", ImmutableList.of("baz_plugin", "dummy_plugin"));
     388        Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin"));
    392389
    393390        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker();
     
    424421
    425422        assertEquals(
    426             ImmutableList.of("baz_plugin", "dummy_plugin"),
    427             model.getAvailablePlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    428         );
    429         assertEquals(
    430             ImmutableList.of("baz_plugin", "dummy_plugin"),
    431             model.getSelectedPlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    432         );
    433         assertEquals(
    434             ImmutableList.of("6", "31701"),
     423            Arrays.asList("baz_plugin", "dummy_plugin"),
     424            model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     425        );
     426        assertEquals(
     427            Arrays.asList("baz_plugin", "dummy_plugin"),
     428            model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     429        );
     430        assertEquals(
     431            Arrays.asList("6", "31701"),
    435432            model.getAvailablePlugins().stream().map(
    436433                (pi) -> pi.localversion == null ? "(null)" : pi.localversion
    437             ).collect(ImmutableList.toImmutableList())
    438         );
    439         assertEquals(
    440             ImmutableList.of("7", "31772"),
    441             model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(ImmutableList.toImmutableList())
     434            ).collect(Collectors.toList())
     435        );
     436        assertEquals(
     437            Arrays.asList("7", "31772"),
     438            model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())
    442439        );
    443440
     
    447444        assertTrue(model.getNewlyActivatedPlugins().isEmpty());
    448445        assertEquals(
    449             ImmutableList.of("baz_plugin"),
    450             model.getNewlyDeactivatedPlugins().stream().map(
    451                 pi -> pi.getName()
    452             ).collect(ImmutableList.toImmutableList())
     446            Collections.singletonList("baz_plugin"),
     447            model.getNewlyDeactivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
    453448        );
    454449        // questionably correct
     
    502497        // plugins list shouldn't have been altered, we haven't hit save yet
    503498        assertEquals(
    504             ImmutableList.of("baz_plugin", "dummy_plugin"),
    505             Config.getPref().getList("plugins", null).stream().sorted().collect(ImmutableList.toImmutableList())
     499                Arrays.asList("baz_plugin", "dummy_plugin"),
     500            Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList())
    506501        );
    507502
     
    509504        assertTrue(model.getNewlyActivatedPlugins().isEmpty());
    510505        assertEquals(
    511             ImmutableList.of("baz_plugin"),
    512             model.getNewlyDeactivatedPlugins().stream().map(
    513                 (pi) -> pi.getName()
    514             ).collect(ImmutableList.toImmutableList())
     506            Collections.singletonList("baz_plugin"),
     507            model.getNewlyDeactivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
    515508        );
    516509        assertTrue(model.getPluginsScheduledForUpdateOrDownload().isEmpty());
     
    524517        assertTrue(model.getNewlyDeactivatedPlugins().isEmpty());
    525518        assertEquals(
    526             ImmutableList.of("baz_plugin"),
    527             model.getPluginsScheduledForUpdateOrDownload().stream().map(
    528                 (pi) -> pi.getName()
    529             ).collect(ImmutableList.toImmutableList())
     519            Collections.singletonList("baz_plugin"),
     520            model.getPluginsScheduledForUpdateOrDownload().stream().map(PluginInformation::getName).collect(Collectors.toList())
    530521        );
    531522
     
    584575        );
    585576        pluginServer.applyToWireMockServer(this.pluginServerRule);
    586         Config.getPref().putList("plugins", ImmutableList.of("baz_plugin", "dummy_plugin"));
     577        Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin"));
    587578
    588579        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(
     
    623614
    624615        assertEquals(
    625             ImmutableList.of("baz_plugin", "dummy_plugin", "irrelevant_plugin"),
    626             model.getAvailablePlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    627         );
    628         assertEquals(
    629             ImmutableList.of("baz_plugin", "dummy_plugin"),
    630             model.getSelectedPlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
    631         );
    632         assertEquals(
    633             ImmutableList.of("6", "31701", "(null)"),
     616            Arrays.asList("baz_plugin", "dummy_plugin", "irrelevant_plugin"),
     617            model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     618        );
     619        assertEquals(
     620            Arrays.asList("baz_plugin", "dummy_plugin"),
     621            model.getSelectedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
     622        );
     623        assertEquals(
     624            Arrays.asList("6", "31701", "(null)"),
    634625            model.getAvailablePlugins().stream().map(
    635626                (pi) -> pi.localversion == null ? "(null)" : pi.localversion
    636             ).collect(ImmutableList.toImmutableList())
    637         );
    638         assertEquals(
    639             ImmutableList.of("6", "31701", "123"),
    640             model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(ImmutableList.toImmutableList())
     627            ).collect(Collectors.toList())
     628        );
     629        assertEquals(
     630            Arrays.asList("6", "31701", "123"),
     631            model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())
    641632        );
    642633
     
    676667        // plugins list shouldn't have been altered
    677668        assertEquals(
    678             ImmutableList.of("baz_plugin", "dummy_plugin"),
    679             Config.getPref().getList("plugins", null).stream().sorted().collect(ImmutableList.toImmutableList())
     669            Arrays.asList("baz_plugin", "dummy_plugin"),
     670            Config.getPref().getList("plugins", null).stream().sorted().collect(Collectors.toList())
    680671        );
    681672
     
    737728        );
    738729        pluginServer.applyToWireMockServer(this.pluginServerRule);
    739         Config.getPref().putList("plugins", ImmutableList.of());
     730        Config.getPref().putList("plugins", Collections.emptyList());
    740731
    741732        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker();
     
    772763
    773764        assertEquals(
    774             ImmutableList.of("baz_plugin", "dummy_plugin"),
    775             model.getAvailablePlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
     765            Arrays.asList("baz_plugin", "dummy_plugin"),
     766            model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
    776767        );
    777768        assertTrue(model.getSelectedPlugins().isEmpty());
    778769        assertEquals(
    779             ImmutableList.of("(null)", "(null)"),
     770            Arrays.asList("(null)", "(null)"),
    780771            model.getAvailablePlugins().stream().map(
    781772                (pi) -> pi.localversion == null ? "(null)" : pi.localversion
    782             ).collect(ImmutableList.toImmutableList())
    783         );
    784         assertEquals(
    785             ImmutableList.of("7", "31772"),
    786             model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(ImmutableList.toImmutableList())
     773            ).collect(Collectors.toList())
     774        );
     775        assertEquals(
     776            Arrays.asList("7", "31772"),
     777            model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())
    787778        );
    788779
     
    792783        // model should now reflect this
    793784        assertEquals(
    794             ImmutableList.of("dummy_plugin"),
    795             model.getNewlyActivatedPlugins().stream().map(
    796                 pi -> pi.getName()
    797             ).collect(ImmutableList.toImmutableList())
     785            Collections.singletonList("dummy_plugin"),
     786            model.getNewlyActivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
    798787        );
    799788        assertTrue(model.getNewlyDeactivatedPlugins().isEmpty());
     
    858847            )
    859848        );
    860         Config.getPref().putList("plugins", ImmutableList.of());
     849        Config.getPref().putList("plugins", Collections.emptyList());
    861850
    862851        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(Collections.singletonMap(
     
    895884
    896885        assertEquals(
    897             ImmutableList.of("baz_plugin", "dummy_plugin"),
    898             model.getAvailablePlugins().stream().map((pi) -> pi.getName()).collect(ImmutableList.toImmutableList())
     886            Arrays.asList("baz_plugin", "dummy_plugin"),
     887            model.getAvailablePlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
    899888        );
    900889        assertTrue(model.getSelectedPlugins().isEmpty());
    901890        assertEquals(
    902             ImmutableList.of("(null)", "(null)"),
     891            Arrays.asList("(null)", "(null)"),
    903892            model.getAvailablePlugins().stream().map(
    904893                (pi) -> pi.localversion == null ? "(null)" : pi.localversion
    905             ).collect(ImmutableList.toImmutableList())
    906         );
    907         assertEquals(
    908             ImmutableList.of("6", "31772"),
    909             model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(ImmutableList.toImmutableList())
     894            ).collect(Collectors.toList())
     895        );
     896        assertEquals(
     897            Arrays.asList("6", "31772"),
     898            model.getAvailablePlugins().stream().map((pi) -> pi.version).collect(Collectors.toList())
    910899        );
    911900
     
    915904        // model should now reflect this
    916905        assertEquals(
    917             ImmutableList.of("baz_plugin"),
    918             model.getNewlyActivatedPlugins().stream().map(
    919                 pi -> pi.getName()
    920             ).collect(ImmutableList.toImmutableList())
     906            Collections.singletonList("baz_plugin"),
     907            model.getNewlyActivatedPlugins().stream().map(PluginInformation::getName).collect(Collectors.toList())
    921908        );
    922909        assertTrue(model.getNewlyDeactivatedPlugins().isEmpty());
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java

    r16160 r16161  
    1010import java.io.IOException;
    1111import java.nio.file.Files;
     12import java.util.ArrayList;
     13import java.util.Arrays;
    1214import java.util.Collections;
     15import java.util.Comparator;
    1316import java.util.List;
     17import java.util.stream.Collectors;
    1418
    1519import org.junit.Before;
     
    2731import com.github.tomakehurst.wiremock.client.WireMock;
    2832import com.github.tomakehurst.wiremock.junit.WireMockRule;
    29 import com.google.common.collect.ImmutableList;
    3033
    3134import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    6063        Config.getPref().put("pluginmanager.lastupdate", "999");
    6164        Config.getPref().putList("pluginmanager.sites",
    62             ImmutableList.of(String.format("http://localhost:%s/plugins", this.pluginServerRule.port()))
     65                Collections.singletonList(String.format("http://localhost:%s/plugins", this.pluginServerRule.port()))
    6366        );
    6467
     
    114117        );
    115118        pluginServer.applyToWireMockServer(this.pluginServerRule);
    116         Config.getPref().putList("plugins", ImmutableList.of("dummy_plugin", "baz_plugin"));
     119        Config.getPref().putList("plugins", Arrays.asList("dummy_plugin", "baz_plugin"));
    117120
    118121        final ExtendedDialogMocker edMocker = new ExtendedDialogMocker();
     
    128131            null,
    129132            false
    130         ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList());
     133        ).stream().sorted(Comparator.comparing(a -> a.name)).collect(Collectors.toList());
    131134
    132135        assertEquals(
    133             ImmutableList.of(
    134                 this.dummyPluginVersionReqString,
    135                 this.bazPluginVersionReqString
    136             ),
     136                Arrays.asList(
     137                        this.dummyPluginVersionReqString,
     138                        this.bazPluginVersionReqString
     139                ),
    137140            edMocker.getInvocationLog().stream().map(
    138141                invocationEntry -> invocationEntry[1]
    139             ).sorted().collect(ImmutableList.toImmutableList())
     142            ).sorted().collect(Collectors.toList())
    140143        );
    141144
     
    176179        );
    177180        pluginServer.applyToWireMockServer(this.pluginServerRule);
    178         Config.getPref().putList("plugins", ImmutableList.of("dummy_plugin", "baz_plugin"));
     181        Config.getPref().putList("plugins", Arrays.asList("dummy_plugin", "baz_plugin"));
    179182
    180183        final ExtendedDialogMocker edMocker = new ExtendedDialogMocker();
     
    192195            null,
    193196            false
    194         ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList());
     197        ).stream().sorted(Comparator.comparing(a -> a.name)).collect(Collectors.toList());
    195198
    196199        assertEquals(
    197             ImmutableList.of(
    198                 this.dummyPluginVersionReqString,
    199                 this.bazPluginVersionReqString
    200             ),
     200                Arrays.asList(
     201                        this.dummyPluginVersionReqString,
     202                        this.bazPluginVersionReqString
     203                ),
    201204            edMocker.getInvocationLog().stream().map(
    202205                invocationEntry -> invocationEntry[1]
    203             ).sorted().collect(ImmutableList.toImmutableList())
    204         );
    205 
    206         assertEquals(
    207             ImmutableList.of(
    208                 this.dummyPluginFailedString
    209             ),
     206            ).sorted().collect(Collectors.toList())
     207        );
     208
     209        assertEquals(Collections.singletonList(this.dummyPluginFailedString),
    210210            haMocker.getInvocationLog().stream().map(
    211211                invocationEntry -> invocationEntry[1]
    212             ).sorted().collect(ImmutableList.toImmutableList())
     212            ).sorted().collect(Collectors.toList())
    213213        );
    214214
     
    251251        );
    252252        pluginServer.applyToWireMockServer(this.pluginServerRule);
    253         Config.getPref().putList("plugins", ImmutableList.of("baz_plugin"));
     253        Config.getPref().putList("plugins", Collections.singletonList("baz_plugin"));
    254254
    255255        // setting up blank ExtendedDialogMocker which would raise an exception if any attempt to show
     
    259259        Files.copy(this.referenceBazJarOld.toPath(), this.targetBazJar.toPath());
    260260
    261         final List<PluginInformation> updatedPlugins = ImmutableList.copyOf(PluginHandler.updatePlugins(
     261        final List<PluginInformation> updatedPlugins = new ArrayList<>(PluginHandler.updatePlugins(
    262262            MainApplication.getMainFrame(),
    263263            null,
     
    309309        );
    310310        pluginServer.applyToWireMockServer(this.pluginServerRule);
    311         Config.getPref().putList("plugins", ImmutableList.of("qux_plugin", "baz_plugin"));
     311        Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin"));
    312312
    313313        new ExtendedDialogMocker(Collections.singletonMap("JOSM version 7,500 required for plugin qux_plugin.", "Download Plugin"));
     
    321321            null,
    322322            false
    323         ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList());
     323        ).stream().sorted(Comparator.comparing(a -> a.name)).collect(Collectors.toList());
    324324
    325325        assertEquals(2, updatedPlugins.size());
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java

    r16160 r16161  
    99import java.io.File;
    1010import java.nio.file.Files;
     11import java.util.Arrays;
     12import java.util.Collections;
     13import java.util.Comparator;
    1114import java.util.HashMap;
    1215import java.util.List;
    1316import java.util.Map;
     17import java.util.stream.Collectors;
    1418
    1519import org.junit.Before;
     
    2630import com.github.tomakehurst.wiremock.client.WireMock;
    2731import com.github.tomakehurst.wiremock.junit.WireMockRule;
    28 import com.google.common.collect.ImmutableList;
    2932
    3033import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    5760        Config.getPref().put("pluginmanager.lastupdate", "999");
    5861        Config.getPref().putList("pluginmanager.sites",
    59             ImmutableList.of(String.format("http://localhost:%s/plugins", this.pluginServerRule.port()))
     62                Collections.singletonList(String.format("http://localhost:%s/plugins", this.pluginServerRule.port()))
    6063        );
    6164
     
    115118            )
    116119        );
    117         Config.getPref().putList("plugins", ImmutableList.of("qux_plugin", "baz_plugin"));
     120        Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin"));
    118121
    119122        // catch any (unexpected) attempts to show us an ExtendedDialog
     
    128131            null,
    129132            false
    130         ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList());
     133        ).stream().sorted(Comparator.comparing(a -> a.name)).collect(Collectors.toList());
    131134
    132135        assertEquals(2, updatedPlugins.size());
     
    173176        );
    174177        pluginServer.applyToWireMockServer(this.pluginServerRule);
    175         Config.getPref().putList("plugins", ImmutableList.of("qux_plugin", "baz_plugin"));
     178        Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin"));
    176179
    177180        // catch any (unexpected) attempts to show us an ExtendedDialog
     
    186189            null,
    187190            false
    188         ).stream().sorted((a, b) -> a.name.compareTo(b.name)).collect(ImmutableList.toImmutableList());
     191        ).stream().sorted(Comparator.comparing(a -> a.name)).collect(Collectors.toList());
    189192
    190193        assertEquals(2, updatedPlugins.size());
  • trunk/test/unit/org/openstreetmap/josm/testutils/PluginServer.java

    r15735 r16161  
    77import java.io.IOException;
    88import java.nio.file.Path;
     9import java.util.Arrays;
    910import java.util.HashMap;
    1011import java.util.List;
     
    1314import java.util.jar.JarFile;
    1415import java.util.stream.Collectors;
     16import java.util.stream.StreamSupport;
    1517
    1618import org.junit.runner.Description;
     
    2527import com.github.tomakehurst.wiremock.core.Options;
    2628import com.github.tomakehurst.wiremock.junit.WireMockRule;
    27 import com.google.common.collect.ImmutableList;
    28 import com.google.common.collect.Streams;
    2929
    3030public class PluginServer {
     
    120120                if (jarPath.startsWith(filesRootPath)) {
    121121                    // would just use .toString() but need to force use of *forward slash* path separators on all platforms
    122                     return Streams.stream(filesRootPath.relativize(jarPath)).map(p -> p.toString()).collect(Collectors.joining("/"));
     122                    final Path path = filesRootPath.relativize(jarPath);
     123                    return StreamSupport.stream(path.spliterator(), false)
     124                            .map(Path::toString)
     125                            .collect(Collectors.joining("/"));
    123126                }
    124127            }
     
    187190
    188191    public PluginServer(RemotePlugin... remotePlugins) {
    189         this.pluginList = ImmutableList.copyOf(remotePlugins);
     192        this.pluginList = Arrays.asList(remotePlugins);
    190193    }
    191194
Note: See TracChangeset for help on using the changeset viewer.