Changeset 16160 in josm
- Timestamp:
- 2020-03-17T20:09:41+01:00 (4 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r14624 r16160 17 17 import java.util.ArrayList; 18 18 import java.util.Arrays; 19 import java.util.HashMap; 19 20 import java.util.Map; 20 21 import java.util.Objects; … … 49 50 import org.openstreetmap.josm.testutils.JOSMTestRules; 50 51 51 import com.google.common.collect.ImmutableMap;52 53 52 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 54 53 … … 530 529 this.paintSlippyMap(); 531 530 532 Map<Integer, String> paletteMap = ImmutableMap.<Integer, String>builder()533 .put(0xffffffff, "w")// white534 .put(0xff000000, "b")// black535 .put(0xfff0d1d1, "p")// pink536 .build();531 Map<Integer, String> paletteMap = new HashMap<Integer, String>() {{ 532 put(0xffffffff, "w"); // white 533 put(0xff000000, "b"); // black 534 put(0xfff0d1d1, "p"); // pink 535 }}; 537 536 538 537 Matcher rowMatcher = ImagePatternMatching.rowMatch( … … 680 679 this.paintSlippyMap(); 681 680 682 Map<Integer, String> paletteMap = ImmutableMap.<Integer, String>builder()683 .put(0xff00ff00, "g")// green684 .put(0xff000000, "b")// black685 .put(0xff8ad16b, "v")// viewport marker inner (pink+green mix)686 .put(0xff00df00, "d")// (shaded green)687 .put(0xff8ac46b, "q")// (shaded pink+green mix)688 .build();681 Map<Integer, String> paletteMap = new HashMap<Integer, String>() {{ 682 put(0xff00ff00, "g"); // green 683 put(0xff000000, "b"); // black 684 put(0xff8ad16b, "v"); // viewport marker inner (pink+green mix) 685 put(0xff00df00, "d"); // (shaded green) 686 put(0xff8ac46b, "q"); // (shaded pink+green mix) 687 }}; 689 688 690 689 // assert downloaded areas are not drawn … … 852 851 this.paintSlippyMap(); 853 852 854 Map<Integer, String> paletteMap = ImmutableMap.<Integer, String>builder()855 .put(0xff00ff00, "g")// green856 .put(0xff000000, "b")// black857 .put(0xff8ad16b, "v")// viewport marker inner (pink+green mix)858 .put(0xff00df00, "d")// (shaded green)859 .put(0xff8ac46b, "q")// (shaded pink+green mix)860 .build();853 Map<Integer, String> paletteMap = new HashMap<Integer, String>() {{ 854 put(0xff00ff00, "g"); // green 855 put(0xff000000, "b"); // black 856 put(0xff8ad16b, "v"); // viewport marker inner (pink+green mix) 857 put(0xff00df00, "d"); // (shaded green) 858 put(0xff8ac46b, "q"); // (shaded pink+green mix) 859 }}; 861 860 862 861 // the middle row should be entirely unshaded -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java
r14385 r16160 14 14 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 15 15 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 16 17 import com.google.common.collect.ImmutableMap;18 16 19 17 import mockit.Mock; … … 73 71 public void testDeleteCurrentRelationAction() { 74 72 TestUtils.assumeWorkingJMockit(); 75 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker( 76 ImmutableMap.<String, Object>of( 73 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker() { 74 public String getStringFromOriginalMessage(Object originalMessage) { 75 return ((JTextComponent) ((Container) originalMessage).getComponent(0)).getText(); 76 } 77 }; 78 jopsMocker.getMockResultMap().put( 77 79 "<html>\n <head>\n \n </head>\n <body>\n You are about to delete 1 " 78 80 + "relation:\n\n " 79 81 + "<ul>\n <li>\n incomplete\n </li>\n </ul>\n <br>\n " 80 82 + "This step is rarely necessary and cannot be undone easily after being \n " 81 + "uploaded to the server.<br>Do you really want to delete?\n </body>\n</html>\n", JOptionPane.YES_OPTION, 83 + "uploaded to the server.<br>Do you really want to delete?\n </body>\n</html>\n", JOptionPane.YES_OPTION); 84 jopsMocker.getMockResultMap().put( 82 85 "<html>\n <head>\n \n </head>\n <body>\n You are about to delete incomplete " 83 86 + "objects.<br>This will cause problems \n because you don\'t see the real object.<br>" 84 87 + "Do you really want to delete?\n </body>\n</html>\n", 85 JOptionPane.YES_OPTION 86 ) 87 ) { 88 public String getStringFromOriginalMessage(Object originalMessage) { 89 return ((JTextComponent) ((Container) originalMessage).getComponent(0)).getText(); 90 } 91 }; 88 JOptionPane.YES_OPTION); 92 89 93 90 new DeleteCurrentRelationAction(relationEditorAccess).actionPerformed(null); -
trunk/test/unit/org/openstreetmap/josm/gui/io/UploadDialogTest.java
r15051 r16160 29 29 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 30 30 31 import com.google.common.collect.ImmutableMap;32 33 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 34 32 import mockit.Invocation; … … 129 127 public void testUploadAction() { 130 128 TestUtils.assumeWorkingJMockit(); 131 ExtendedDialogMocker edMocker = new ExtendedDialogMocker( 132 ImmutableMap.<String, Object>of( 133 "<html>Your upload comment is <i>empty</i>, or <i>very short</i>.<br /><br />This is " 134 + "technically allowed, but please consider that many users who are<br />watching changes " 135 + "in their area depend on meaningful changeset comments<br />to understand what is going " 136 + "on!<br /><br />If you spend a minute now to explain your change, you will make life<br />" 137 + "easier for many other mappers.</html>", "Revise", 138 "<html>You did not specify a source for your changes.<br />It is technically allowed, " 139 + "but this information helps<br />other users to understand the origins of the data." 140 + "<br /><br />If you spend a minute now to explain your change, you will make life" 141 + "<br />easier for many other mappers.</html>", "Revise" 142 ) 143 ) { 129 ExtendedDialogMocker edMocker = new ExtendedDialogMocker() { 144 130 @Mock 145 131 void setupDialog(Invocation invocation) throws Exception { … … 159 145 } 160 146 }; 147 edMocker.getMockResultMap().put("<html>Your upload comment is <i>empty</i>, or <i>very short</i>.<br /><br />This is " 148 + "technically allowed, but please consider that many users who are<br />watching changes " 149 + "in their area depend on meaningful changeset comments<br />to understand what is going " 150 + "on!<br /><br />If you spend a minute now to explain your change, you will make life<br />" 151 + "easier for many other mappers.</html>", "Revise"); 152 edMocker.getMockResultMap().put("<html>You did not specify a source for your changes.<br />It is technically allowed, " 153 + "but this information helps<br />other users to understand the origins of the data." 154 + "<br /><br />If you spend a minute now to explain your change, you will make life" 155 + "<br />easier for many other mappers.</html>", "Revise"); 161 156 162 157 MockUploadDialog uploadDialog = new MockUploadDialog("comment", "source"); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java
r16006 r16160 6 6 import java.io.FileNotFoundException; 7 7 import java.io.IOException; 8 import java.util.Collections; 9 import java.util.HashMap; 8 10 import java.util.List; 9 11 import java.util.Map; … … 20 22 import org.openstreetmap.josm.tools.ColorHelper; 21 23 import org.xml.sax.SAXException; 22 23 import com.google.common.collect.ImmutableMap;24 24 25 25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 45 45 @Test 46 46 public void testTicket12312() throws FileNotFoundException, IOException, SAXException { 47 final List<String> colors = calculateColors(TestUtils.getRegressionDataFile(12312, "single_trackpoint.gpx"), 48 ImmutableMap.of("colormode.dynamic-range", "true", 49 "colormode", Integer.toString(ColorMode.VELOCITY.toIndex())), 50 1); 47 final Map<String, String> prefs = new HashMap<String, String>() {{ 48 put("colormode.dynamic-range", "true"); 49 put("colormode", Integer.toString(ColorMode.VELOCITY.toIndex())); 50 }}; 51 final List<String> colors = calculateColors(TestUtils.getRegressionDataFile(12312, "single_trackpoint.gpx"), prefs, 1); 51 52 assertEquals("[null]", colors.toString()); 52 53 } … … 60 61 @Test 61 62 public void testNone() throws IOException, SAXException { 62 final List<String> colors = calculateColors("nodist/data/2094047.gpx", ImmutableMap.of(), 10);63 final List<String> colors = calculateColors("nodist/data/2094047.gpx", Collections.emptyMap(), 10); 63 64 assertEquals("[#000000, #000000, #000000, #000000, #000000, #000000, #000000, #000000, #000000, #000000]", colors.toString()); 64 65 } … … 72 73 @Test 73 74 public void testVelocity() throws IOException, SAXException { 74 final List<String> colors = calculateColors("nodist/data/2094047.gpx",75 ImmutableMap.of("colormode", Integer.toString(ColorMode.VELOCITY.toIndex())), 10);75 final Map<String, String> prefs = Collections.singletonMap("colormode", Integer.toString(ColorMode.VELOCITY.toIndex())); 76 final List<String> colors = calculateColors("nodist/data/2094047.gpx", prefs, 10); 76 77 assertEquals("[#000000, #FFAD00, #FFA800, #FFA800, #FF9E00, #FF9400, #FF7000, #FF7000, #FF8000, #FF9400]", colors.toString()); 77 78 } … … 85 86 @Test 86 87 public void testVelocityDynamic() throws IOException, SAXException { 87 final List<String> colors = calculateColors("nodist/data/2094047.gpx", 88 ImmutableMap.of("colormode.dynamic-range", "true", 89 "colormode", Integer.toString(ColorMode.VELOCITY.toIndex())), 90 10); 88 final Map<String, String> prefs = new HashMap<String, String>() {{ 89 put("colormode.dynamic-range", "true"); 90 put("colormode", Integer.toString(ColorMode.VELOCITY.toIndex())); 91 }}; 92 final List<String> colors = calculateColors("nodist/data/2094047.gpx", prefs, 10); 91 93 assertEquals("[#000000, #00FFE0, #00FFC2, #00FFC2, #00FF75, #00FF3D, #99FF00, #94FF00, #38FF00, #00FF38]", colors.toString()); 92 94 } … … 100 102 @Test 101 103 public void testDirection() throws IOException, SAXException { 102 final List<String> colors = calculateColors("nodist/data/2094047.gpx",103 ImmutableMap.of("colormode", Integer.toString(ColorMode.DIRECTION.toIndex())), 10);104 final Map<String, String> prefs = Collections.singletonMap("colormode", Integer.toString(ColorMode.DIRECTION.toIndex())); 105 final List<String> colors = calculateColors("nodist/data/2094047.gpx", prefs, 10); 104 106 assertEquals("[#000000, #EAEC25, #EDEA26, #EDE525, #ECD322, #EBB81D, #E85A0D, #E73708, #E84D0B, #EA8A15]", colors.toString()); 105 107 } … … 113 115 @Test 114 116 public void testTime() throws IOException, SAXException { 115 final List<String> colors = calculateColors("nodist/data/2094047.gpx",116 ImmutableMap.of("colormode", Integer.toString(ColorMode.TIME.toIndex())), 10);117 final Map<String, String> prefs = Collections.singletonMap("colormode", Integer.toString(ColorMode.TIME.toIndex())); 118 final List<String> colors = calculateColors("nodist/data/2094047.gpx", prefs, 10); 117 119 assertEquals("[#000000, #FF0000, #FF0000, #FF0500, #FF0500, #FF0A00, #FF0A00, #FF1F00, #FF2E00, #FF3300]", colors.toString()); 118 120 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java
r14081 r16160 20 20 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 21 21 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 22 23 import com.google.common.collect.ImmutableMap;24 22 25 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 52 50 public void testPreferencesTable() { 53 51 TestUtils.assumeWorkingJMockit(); 54 new JOptionPaneSimpleMocker(ImmutableMap.of( 55 "Please select the row to edit.", JOptionPane.OK_OPTION, 56 "Please select the row to delete.", JOptionPane.OK_OPTION 57 )); 52 final JOptionPaneSimpleMocker mocker = new JOptionPaneSimpleMocker(); 53 mocker.getMockResultMap().put("Please select the row to edit.", JOptionPane.OK_OPTION); 54 mocker.getMockResultMap().put("Please select the row to delete.", JOptionPane.OK_OPTION); 58 55 new ExtendedDialogMocker() { 59 56 @Override -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java
r14138 r16160 20 20 import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; 21 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 23 import com.google.common.collect.ImmutableMap;24 22 25 23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 92 90 @Test 93 91 public void testNotifyDownloadResults() { 94 new HelpAwareOptionPaneMocker(ImmutableMap.<String, Object>builder() 95 .put("<html></html>", "OK") // (buildDownloadSummary() output was empty) 96 .put("<html>Please restart JOSM to activate the downloaded plugins.</html>", "OK") 97 .build() 98 ); 92 final HelpAwareOptionPaneMocker mocker = new HelpAwareOptionPaneMocker(); 93 mocker.getMockResultMap().put("<html></html>", "OK"); // (buildDownloadSummary() output was empty) 94 mocker.getMockResultMap().put("<html>Please restart JOSM to activate the downloaded plugins.</html>", "OK"); 99 95 100 96 PluginDownloadTask task = new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), ""); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
r16159 r16160 28 28 import com.github.tomakehurst.wiremock.junit.WireMockRule; 29 29 import com.google.common.collect.ImmutableList; 30 import com.google.common.collect.ImmutableMap;31 30 32 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 117 116 Config.getPref().putList("plugins", ImmutableList.of("dummy_plugin", "baz_plugin")); 118 117 119 final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(ImmutableMap.<String, Object>builder() 120 .put(this.bazPluginVersionReqString, "Download Plugin") 121 .put(this.dummyPluginVersionReqString, "Download Plugin") 122 .build() 123 ); 118 final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(); 119 edMocker.getMockResultMap().put(this.bazPluginVersionReqString, "Download Plugin"); 120 edMocker.getMockResultMap().put(this.dummyPluginVersionReqString, "Download Plugin"); 124 121 125 122 Files.copy(this.referenceDummyJarOld.toPath(), this.targetDummyJar.toPath()); … … 181 178 Config.getPref().putList("plugins", ImmutableList.of("dummy_plugin", "baz_plugin")); 182 179 183 final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(ImmutableMap.<String, Object>builder() 184 .put(this.bazPluginVersionReqString, "Download Plugin") 185 .put(this.dummyPluginVersionReqString, "Skip Download") 186 .build() 187 ); 188 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(ImmutableMap.<String, Object>builder() 189 .put(this.dummyPluginFailedString, "OK") 190 .build() 191 ); 180 final ExtendedDialogMocker edMocker = new ExtendedDialogMocker(); 181 edMocker.getMockResultMap().put(this.bazPluginVersionReqString, "Download Plugin"); 182 edMocker.getMockResultMap().put(this.dummyPluginVersionReqString, "Skip Download"); 183 final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(); 184 haMocker.getMockResultMap().put(this.dummyPluginFailedString, "OK"); 192 185 193 186 Files.copy(this.referenceDummyJarOld.toPath(), this.targetDummyJar.toPath()); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
r14213 r16160 9 9 import java.io.File; 10 10 import java.nio.file.Files; 11 import java.util.HashMap; 11 12 import java.util.List; 13 import java.util.Map; 12 14 13 15 import org.junit.Before; … … 25 27 import com.github.tomakehurst.wiremock.junit.WireMockRule; 26 28 import com.google.common.collect.ImmutableList; 27 import com.google.common.collect.ImmutableMap;28 29 29 30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 96 97 97 98 final String quxNewerServePath = "/qux/newer.jar"; 99 final Map<String, String> attrOverrides = new HashMap<String, String>() {{ 100 put("7500_Plugin-Url", "432;http://localhost:" + pluginServerRule.port() + quxNewerServePath); 101 put("7499_Plugin-Url", "346;http://localhost:" + pluginServerRule.port() + "/not/served.jar"); 102 put("6999_Plugin-Url", "345;http://localhost:" + pluginServerRule.port() + "/not/served/eithejar"); 103 }}; 98 104 final PluginServer pluginServer = new PluginServer( 99 105 new PluginServer.RemotePlugin(this.referenceBazJarOld), 100 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, ImmutableMap.of( 101 "7500_Plugin-Url", "432;http://localhost:" + this.pluginServerRule.port() + quxNewerServePath, 102 "7499_Plugin-Url", "346;http://localhost:" + this.pluginServerRule.port() + "/not/served.jar", 103 "6999_Plugin-Url", "345;http://localhost:" + this.pluginServerRule.port() + "/not/served/either.jar" 104 )) 106 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, attrOverrides) 105 107 ); 106 108 pluginServer.applyToWireMockServer(this.pluginServerRule); … … 161 163 TestUtils.assumeWorkingJMockit(); 162 164 165 final Map<String, String> attrOverrides = new HashMap<String, String>() {{ 166 put("7500_Plugin-Url", "432;http://localhost:" + pluginServerRule.port() + "/dont.jar"); 167 put("7499_Plugin-Url", "346;http://localhost:" + pluginServerRule.port() + "/even.jar"); 168 put("6999_Plugin-Url", "345;http://localhost:" + pluginServerRule.port() + "/bother.jar"); 169 }}; 163 170 final PluginServer pluginServer = new PluginServer( 164 171 new PluginServer.RemotePlugin(this.referenceBazJarOld), 165 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, ImmutableMap.of( 166 "7500_Plugin-Url", "432;http://localhost:" + this.pluginServerRule.port() + "/dont.jar", 167 "7499_Plugin-Url", "346;http://localhost:" + this.pluginServerRule.port() + "/even.jar", 168 "6999_Plugin-Url", "345;http://localhost:" + this.pluginServerRule.port() + "/bother.jar" 169 )) 172 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, attrOverrides) 170 173 ); 171 174 pluginServer.applyToWireMockServer(this.pluginServerRule); -
trunk/test/unit/org/openstreetmap/josm/testutils/mockers/JOptionPaneSimpleMocker.java
r14358 r16160 14 14 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil.MessagePanel; 15 15 import org.openstreetmap.josm.tools.Logging; 16 17 import com.google.common.collect.ImmutableMap;18 import com.google.common.primitives.Ints;19 16 20 17 import mockit.Invocation; … … 60 57 */ 61 58 public class JOptionPaneSimpleMocker extends BaseDialogMockUp<JOptionPane> { 62 protected static final Map<Integer, int[]> optionTypePermittedResults = ImmutableMap.of( 63 JOptionPane.YES_NO_OPTION, new int[] { 64 JOptionPane.YES_OPTION, 65 JOptionPane.NO_OPTION, 66 JOptionPane.CLOSED_OPTION 67 }, 68 JOptionPane.YES_NO_CANCEL_OPTION, new int[] { 69 JOptionPane.YES_OPTION, 70 JOptionPane.NO_OPTION, 71 JOptionPane.CANCEL_OPTION, 72 JOptionPane.CLOSED_OPTION 73 }, 74 JOptionPane.OK_CANCEL_OPTION, new int[] { 75 JOptionPane.OK_OPTION, 76 JOptionPane.CANCEL_OPTION, 77 JOptionPane.CLOSED_OPTION 78 }, 79 // it's hard to know much about DEFAULT_OPTION, so we can't really police anything here, so 80 // including all known options 81 JOptionPane.DEFAULT_OPTION, new int[] { 82 JOptionPane.OK_OPTION, 83 JOptionPane.CANCEL_OPTION, 84 JOptionPane.CLOSED_OPTION, 85 JOptionPane.YES_OPTION, 86 JOptionPane.NO_OPTION 87 } 88 ); 59 60 private boolean isPermittedResult(int option, int value) { 61 if (option == JOptionPane.YES_NO_OPTION) { 62 return value == JOptionPane.YES_OPTION || value == JOptionPane.NO_OPTION || value == JOptionPane.CLOSED_OPTION; 63 } else if (option == JOptionPane.YES_NO_CANCEL_OPTION) { 64 return value == JOptionPane.YES_OPTION || value == JOptionPane.NO_OPTION 65 || value == JOptionPane.CANCEL_OPTION || value == JOptionPane.CLOSED_OPTION; 66 } else if (option == JOptionPane.OK_CANCEL_OPTION) { 67 return value == JOptionPane.OK_OPTION || value == JOptionPane.CANCEL_OPTION || value == JOptionPane.CLOSED_OPTION; 68 } else if (option == JOptionPane.DEFAULT_OPTION) { 69 // it's hard to know much about DEFAULT_OPTION, so we can't really police anything here, so 70 // including all known options 71 return value == JOptionPane.OK_OPTION || value == JOptionPane.CANCEL_OPTION || value == JOptionPane.CLOSED_OPTION 72 || value == JOptionPane.YES_OPTION || value == JOptionPane.NO_OPTION; 73 } else { 74 return false; 75 } 76 } 89 77 90 78 protected final MessagePanelMocker messagePanelMocker; … … 286 274 this.act(message); 287 275 final Object result = this.getMockResultForMessage(message); 288 if (!(result instanceof Integer && Ints.contains(optionTypePermittedResults.get(optionType), (int) result))) {276 if (!(result instanceof Integer && isPermittedResult(optionType, (int) result))) { 289 277 fail(String.format( 290 278 "Invalid result for showConfirmDialog with optionType %d: %s",
Note:
See TracChangeset
for help on using the changeset viewer.