Changeset 16161 in josm for trunk/test/unit/org
- Timestamp:
- 2020-03-17T20:09:43+01:00 (5 years ago)
- 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 11 11 import java.util.HashSet; 12 12 import java.util.List; 13 import java.util.stream.Collectors; 13 14 14 15 import org.junit.Rule; … … 21 22 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 23 23 import com.google.common.collect.Sets;24 25 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 26 25 … … 36 35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 37 36 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 } 38 42 39 43 /** … … 48 52 tc.add(new Tag("building", "garage")); 49 53 TagConflictResolutionUtil.applyAutomaticTagConflictResolution(tc); 50 assertEquals( Sets.newHashSet("school", "garage"), new HashSet<>(tc.getValues("building")));54 assertEquals(newHashSet("school", "garage"), new HashSet<>(tc.getValues("building"))); 51 55 52 56 // Check US Tiger tag conflict resolution … … 55 59 tc.add(new Tag("tiger:test", "A")); 56 60 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"))); 58 62 59 63 // Check FR:cadastre source tag conflict resolution (most common values from taginfo except last one without accentuated characters) … … 84 88 tc.remove(otherSource); 85 89 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"), 87 91 new HashSet<>(tc.getValues("source"))); 88 92 … … 97 101 tc.add(new Tag("source", "NRCan-CanVec-12.0")); 98 102 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"))); 100 104 } 101 105 … … 209 213 public void testResolve() { 210 214 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"); 213 217 } 214 218 215 219 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"); 217 221 } 218 222 219 223 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")); 221 225 assertTrue(resolution.equals("3;x;1;4") || resolution.equals("4;x;3;1")); 222 226 } … … 383 387 assertEquals(group1.key, choiceKey1Group1.key); 384 388 assertEquals(group1.group, choiceKey1Group1.group); 385 assertEquals(new HashSet<>(group1.choices), Sets.newHashSet(choiceKey1Group1, choiceKey1Group1bis));389 assertEquals(new HashSet<>(group1.choices), newHashSet(choiceKey1Group1, choiceKey1Group1bis)); 386 390 387 391 groups = AutomaticChoiceGroup.groupChoices(Arrays.asList( … … 428 432 choiceKey1Group1.key, choiceKey1Group1.group, choiceKey1Group1.isRegex, 429 433 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))); 433 437 434 438 group = new AutomaticChoiceGroup( 435 439 choiceKey2Group1.key, choiceKey2Group2.group, choiceKey2Group2.isRegex, 436 440 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"))); 441 445 } 442 446 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r16159 r16161 11 11 import java.io.File; 12 12 import java.nio.file.Files; 13 import java.util.ArrayList; 14 import java.util.Arrays; 13 15 import java.util.Collection; 14 16 import java.util.Collections; 17 import java.util.stream.Collectors; 15 18 16 19 import javax.swing.JOptionPane; … … 26 29 import org.openstreetmap.josm.gui.util.GuiHelper; 27 30 import org.openstreetmap.josm.plugins.PluginHandler; 31 import org.openstreetmap.josm.plugins.PluginInformation; 28 32 import org.openstreetmap.josm.plugins.PluginProxy; 29 33 import org.openstreetmap.josm.spi.preferences.Config; … … 35 39 import com.github.tomakehurst.wiremock.client.WireMock; 36 40 import com.github.tomakehurst.wiremock.junit.WireMockRule; 37 import com.google.common.collect.ImmutableList;38 41 39 42 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 79 82 "pluginList" 80 83 ); 81 this.originalPluginList = ImmutableList.copyOf(pluginList);84 this.originalPluginList = new ArrayList<>(pluginList); 82 85 pluginList.clear(); 83 86 … … 85 88 Config.getPref().put("pluginmanager.lastupdate", "999"); 86 89 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())) 88 91 ); 89 92 … … 140 143 ); 141 144 pluginServer.applyToWireMockServer(this.pluginServerRule); 142 Config.getPref().putList("plugins", ImmutableList.of("dummy_plugin"));145 Config.getPref().putList("plugins", Collections.singletonList("dummy_plugin")); 143 146 144 147 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker( … … 181 184 182 185 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)"), 192 195 model.getAvailablePlugins().stream().map( 193 196 (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()) 199 202 ); 200 203 … … 203 206 204 207 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()) 216 215 ); 217 216 … … 248 247 // baz_plugin should have been added to the plugins list 249 248 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()) 252 251 ); 253 252 } … … 265 264 ); 266 265 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")); 268 267 269 268 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker( … … 305 304 306 305 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)"), 316 315 model.getAvailablePlugins().stream().map( 317 316 (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)"), 322 321 model.getAvailablePlugins().stream().map( 323 322 (pi) -> pi.version == null ? "(null)" : pi.version 324 ).collect( ImmutableList.toImmutableList())323 ).collect(Collectors.toList()) 325 324 ); 326 325 … … 330 329 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 331 330 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()) 336 333 ); 337 334 // questionably correct … … 369 366 // baz_plugin should have been removed from the installed plugins list 370 367 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()) 373 370 ); 374 371 } … … 389 386 ); 390 387 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")); 392 389 393 390 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(); … … 424 421 425 422 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"), 435 432 model.getAvailablePlugins().stream().map( 436 433 (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()) 442 439 ); 443 440 … … 447 444 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 448 445 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()) 453 448 ); 454 449 // questionably correct … … 502 497 // plugins list shouldn't have been altered, we haven't hit save yet 503 498 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()) 506 501 ); 507 502 … … 509 504 assertTrue(model.getNewlyActivatedPlugins().isEmpty()); 510 505 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()) 515 508 ); 516 509 assertTrue(model.getPluginsScheduledForUpdateOrDownload().isEmpty()); … … 524 517 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); 525 518 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()) 530 521 ); 531 522 … … 584 575 ); 585 576 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")); 587 578 588 579 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker( … … 623 614 624 615 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)"), 634 625 model.getAvailablePlugins().stream().map( 635 626 (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()) 641 632 ); 642 633 … … 676 667 // plugins list shouldn't have been altered 677 668 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()) 680 671 ); 681 672 … … 737 728 ); 738 729 pluginServer.applyToWireMockServer(this.pluginServerRule); 739 Config.getPref().putList("plugins", ImmutableList.of());730 Config.getPref().putList("plugins", Collections.emptyList()); 740 731 741 732 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(); … … 772 763 773 764 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()) 776 767 ); 777 768 assertTrue(model.getSelectedPlugins().isEmpty()); 778 769 assertEquals( 779 ImmutableList.of("(null)", "(null)"),770 Arrays.asList("(null)", "(null)"), 780 771 model.getAvailablePlugins().stream().map( 781 772 (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()) 787 778 ); 788 779 … … 792 783 // model should now reflect this 793 784 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()) 798 787 ); 799 788 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); … … 858 847 ) 859 848 ); 860 Config.getPref().putList("plugins", ImmutableList.of());849 Config.getPref().putList("plugins", Collections.emptyList()); 861 850 862 851 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(Collections.singletonMap( … … 895 884 896 885 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()) 899 888 ); 900 889 assertTrue(model.getSelectedPlugins().isEmpty()); 901 890 assertEquals( 902 ImmutableList.of("(null)", "(null)"),891 Arrays.asList("(null)", "(null)"), 903 892 model.getAvailablePlugins().stream().map( 904 893 (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()) 910 899 ); 911 900 … … 915 904 // model should now reflect this 916 905 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()) 921 908 ); 922 909 assertTrue(model.getNewlyDeactivatedPlugins().isEmpty()); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
r16160 r16161 10 10 import java.io.IOException; 11 11 import java.nio.file.Files; 12 import java.util.ArrayList; 13 import java.util.Arrays; 12 14 import java.util.Collections; 15 import java.util.Comparator; 13 16 import java.util.List; 17 import java.util.stream.Collectors; 14 18 15 19 import org.junit.Before; … … 27 31 import com.github.tomakehurst.wiremock.client.WireMock; 28 32 import com.github.tomakehurst.wiremock.junit.WireMockRule; 29 import com.google.common.collect.ImmutableList;30 33 31 34 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 60 63 Config.getPref().put("pluginmanager.lastupdate", "999"); 61 64 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())) 63 66 ); 64 67 … … 114 117 ); 115 118 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")); 117 120 118 121 final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(); … … 128 131 null, 129 132 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()); 131 134 132 135 assertEquals( 133 ImmutableList.of(134 this.dummyPluginVersionReqString,135 this.bazPluginVersionReqString136 ),136 Arrays.asList( 137 this.dummyPluginVersionReqString, 138 this.bazPluginVersionReqString 139 ), 137 140 edMocker.getInvocationLog().stream().map( 138 141 invocationEntry -> invocationEntry[1] 139 ).sorted().collect( ImmutableList.toImmutableList())142 ).sorted().collect(Collectors.toList()) 140 143 ); 141 144 … … 176 179 ); 177 180 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")); 179 182 180 183 final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(); … … 192 195 null, 193 196 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()); 195 198 196 199 assertEquals( 197 ImmutableList.of(198 this.dummyPluginVersionReqString,199 this.bazPluginVersionReqString200 ),200 Arrays.asList( 201 this.dummyPluginVersionReqString, 202 this.bazPluginVersionReqString 203 ), 201 204 edMocker.getInvocationLog().stream().map( 202 205 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), 210 210 haMocker.getInvocationLog().stream().map( 211 211 invocationEntry -> invocationEntry[1] 212 ).sorted().collect( ImmutableList.toImmutableList())212 ).sorted().collect(Collectors.toList()) 213 213 ); 214 214 … … 251 251 ); 252 252 pluginServer.applyToWireMockServer(this.pluginServerRule); 253 Config.getPref().putList("plugins", ImmutableList.of("baz_plugin"));253 Config.getPref().putList("plugins", Collections.singletonList("baz_plugin")); 254 254 255 255 // setting up blank ExtendedDialogMocker which would raise an exception if any attempt to show … … 259 259 Files.copy(this.referenceBazJarOld.toPath(), this.targetBazJar.toPath()); 260 260 261 final List<PluginInformation> updatedPlugins = ImmutableList.copyOf(PluginHandler.updatePlugins(261 final List<PluginInformation> updatedPlugins = new ArrayList<>(PluginHandler.updatePlugins( 262 262 MainApplication.getMainFrame(), 263 263 null, … … 309 309 ); 310 310 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")); 312 312 313 313 new ExtendedDialogMocker(Collections.singletonMap("JOSM version 7,500 required for plugin qux_plugin.", "Download Plugin")); … … 321 321 null, 322 322 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()); 324 324 325 325 assertEquals(2, updatedPlugins.size()); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
r16160 r16161 9 9 import java.io.File; 10 10 import java.nio.file.Files; 11 import java.util.Arrays; 12 import java.util.Collections; 13 import java.util.Comparator; 11 14 import java.util.HashMap; 12 15 import java.util.List; 13 16 import java.util.Map; 17 import java.util.stream.Collectors; 14 18 15 19 import org.junit.Before; … … 26 30 import com.github.tomakehurst.wiremock.client.WireMock; 27 31 import com.github.tomakehurst.wiremock.junit.WireMockRule; 28 import com.google.common.collect.ImmutableList;29 32 30 33 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 57 60 Config.getPref().put("pluginmanager.lastupdate", "999"); 58 61 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())) 60 63 ); 61 64 … … 115 118 ) 116 119 ); 117 Config.getPref().putList("plugins", ImmutableList.of("qux_plugin", "baz_plugin"));120 Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin")); 118 121 119 122 // catch any (unexpected) attempts to show us an ExtendedDialog … … 128 131 null, 129 132 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()); 131 134 132 135 assertEquals(2, updatedPlugins.size()); … … 173 176 ); 174 177 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")); 176 179 177 180 // catch any (unexpected) attempts to show us an ExtendedDialog … … 186 189 null, 187 190 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()); 189 192 190 193 assertEquals(2, updatedPlugins.size()); -
trunk/test/unit/org/openstreetmap/josm/testutils/PluginServer.java
r15735 r16161 7 7 import java.io.IOException; 8 8 import java.nio.file.Path; 9 import java.util.Arrays; 9 10 import java.util.HashMap; 10 11 import java.util.List; … … 13 14 import java.util.jar.JarFile; 14 15 import java.util.stream.Collectors; 16 import java.util.stream.StreamSupport; 15 17 16 18 import org.junit.runner.Description; … … 25 27 import com.github.tomakehurst.wiremock.core.Options; 26 28 import com.github.tomakehurst.wiremock.junit.WireMockRule; 27 import com.google.common.collect.ImmutableList;28 import com.google.common.collect.Streams;29 29 30 30 public class PluginServer { … … 120 120 if (jarPath.startsWith(filesRootPath)) { 121 121 // 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("/")); 123 126 } 124 127 } … … 187 190 188 191 public PluginServer(RemotePlugin... remotePlugins) { 189 this.pluginList = ImmutableList.copyOf(remotePlugins);192 this.pluginList = Arrays.asList(remotePlugins); 190 193 } 191 194
Note:
See TracChangeset
for help on using the changeset viewer.