source: josm/trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java

Last change on this file was 19227, checked in by taylor.smock, 10 months ago

Fix #20908: IllegalStateException: JOSM expected to find primitive in dataset after undoing a Parallel mode action

The test acts (roughly) like a user would, and performs click and drags via a new
utility class (MapModeUtils) which has various methods for performing mouse
actions on the map view.

  • Property svn:eol-style set to native
File size: 25.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import java.io.IOException;
7import java.net.HttpURLConnection;
8import java.net.SocketException;
9import java.net.URL;
10import java.net.UnknownHostException;
11import java.util.TimeZone;
12import java.util.function.Supplier;
13import java.util.stream.Stream;
14
15import org.junit.jupiter.api.BeforeEach;
16import org.junit.jupiter.api.Test;
17import org.junit.jupiter.params.ParameterizedTest;
18import org.junit.jupiter.params.provider.Arguments;
19import org.junit.jupiter.params.provider.MethodSource;
20import org.openstreetmap.josm.io.ChangesetClosedException;
21import org.openstreetmap.josm.io.IllegalDataException;
22import org.openstreetmap.josm.io.MissingOAuthAccessTokenException;
23import org.openstreetmap.josm.io.OfflineAccessException;
24import org.openstreetmap.josm.io.OsmApi;
25import org.openstreetmap.josm.io.OsmApiException;
26import org.openstreetmap.josm.io.OsmApiInitializationException;
27import org.openstreetmap.josm.io.auth.CredentialsManager;
28import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
29import org.openstreetmap.josm.tools.date.DateUtils;
30import org.openstreetmap.josm.tools.date.DateUtilsTest;
31
32/**
33 * Unit tests of {@link ExceptionUtil} class.
34 */
35@BasicPreferences
36@org.openstreetmap.josm.testutils.annotations.OsmApi(org.openstreetmap.josm.testutils.annotations.OsmApi.APIType.FAKE)
37class ExceptionUtilTest {
38 private static String baseUrl;
39 private static String serverUrl;
40 private static String host;
41 private static String user;
42
43 /**
44 * Setup test.
45 * @throws Exception in case of error
46 */
47 @BeforeEach
48 public void setUp() throws Exception {
49 OsmApi api = OsmApi.getOsmApi();
50 baseUrl = api.getBaseUrl();
51 serverUrl = api.getServerUrl();
52 host = new URL(serverUrl).getHost();
53 user = CredentialsManager.getInstance().getUsername();
54 DateUtils.PROP_ISO_DATES.put(Boolean.TRUE);
55 }
56
57 static Stream<Arguments> testExplainBadRequest() {
58 return Stream.of(
59 Arguments.of((Supplier<String>) () -> "<html>The OSM server '"+baseUrl+"' reported a bad request.<br></html>",
60 new OsmApiException("")),
61 Arguments.of((Supplier<String>) () -> "<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
62 "Error message(untranslated): header</html>", new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "header", "")),
63 Arguments.of((Supplier<String>) () -> "<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
64 "Error message(untranslated): header</html>",
65 new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "header", "", "invalid_url")),
66 Arguments.of((Supplier<String>) () -> "<html>The OSM server '"+host+"' reported a bad request.<br><br>"+
67 "Error message(untranslated): header</html>",
68 (Supplier<OsmApiException>) () -> new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "header", "", baseUrl)),
69 Arguments.of((Supplier<String>) () -> "<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
70 "The area you tried to download is too big or your request was too large.<br>"+
71 "Either request a smaller area or use an export file provided by the OSM community." +
72 "<br><br>Downloading a smaller area is <em>recommended</em>!" +
73 "<br><br>Advanced users can use one of the following options:<br><ul>" +
74 "<li><a href=\"https://josm.openstreetmap.de/wiki/Help/Action/Download#DownloadfromOverpassAPI\">Overpass</a></li>" +
75 "<li><a href=\"https://www.geofabrik.de/data/download.html\">Geofabrik</a></li>" +
76 "<li><a href=\"https://planet.openstreetmap.org/\">OSM Planet File</a></li></ul></html>",
77 new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "The maximum bbox", "")),
78 Arguments.of((Supplier<String>) () -> "<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
79 "The area you tried to download is too big or your request was too large.<br>"+
80 "Either request a smaller area or use an export file provided by the OSM community." +
81 "<br><br>Downloading a smaller area is <em>recommended</em>!" +
82 "<br><br>Advanced users can use one of the following options:<br><ul>" +
83 "<li><a href=\"https://josm.openstreetmap.de/wiki/Help/Action/Download#DownloadfromOverpassAPI\">Overpass</a></li>" +
84 "<li><a href=\"https://www.geofabrik.de/data/download.html\">Geofabrik</a></li>" +
85 "<li><a href=\"https://planet.openstreetmap.org/\">OSM Planet File</a></li></ul></html>",
86 new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "You requested too many nodes", ""))
87 );
88 }
89
90 /**
91 * Test of {@link ExceptionUtil#explainBadRequest} method.
92 */
93 @ParameterizedTest(name = "{1}")
94 @MethodSource
95 @SuppressWarnings("unchecked")
96 void testExplainBadRequest(Supplier<String> message, Object exception) {
97 assertEquals(message.get(), ExceptionUtil.explainBadRequest(
98 exception instanceof Supplier ? ((Supplier<OsmApiException>) exception).get() : (OsmApiException) exception
99 ));
100 }
101
102 /**
103 * Test of {@link ExceptionUtil#explainBandwidthLimitExceeded} method.
104 */
105 @Test
106 void testExplainBandwidthLimitExceeded() {
107 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. "+
108 "The server replied<br>the following error code and the following error message:<br>"+
109 "<strong>Error code:<strong> 0<br><strong>Error message (untranslated)</strong>: no error message available</html>",
110 ExceptionUtil.explainBandwidthLimitExceeded(new OsmApiException("")));
111 }
112
113 /**
114 * Test of {@link ExceptionUtil#explainChangesetClosedException} method.
115 */
116 @Test
117 void testExplainChangesetClosedException() {
118 assertEquals("<html>Failed to upload to changeset <strong>0</strong><br>because it has already been closed on ?.",
119 ExceptionUtil.explainChangesetClosedException(new ChangesetClosedException("")));
120
121 assertEquals("<html>Failed to upload to changeset <strong>1</strong><br>because it has already been closed on 2016-01-01 00:00:00.",
122 ExceptionUtil.explainChangesetClosedException(new ChangesetClosedException(1, DateUtils.parseInstant("2016-01-01"), null)));
123 }
124
125 /**
126 * Test of {@link ExceptionUtil#explainClientTimeout} method.
127 */
128 @Test
129 void testExplainClientTimeout() {
130 assertEquals("<html>Communication with the OSM server '"+baseUrl+"' timed out. Please retry later.</html>",
131 ExceptionUtil.explainClientTimeout(new OsmApiException("")));
132 }
133
134 /**
135 * Test of {@link ExceptionUtil#explainConflict} method.
136 */
137 @Test
138 void testExplainConflict() {
139 int code = HttpURLConnection.HTTP_CONFLICT;
140 assertEquals("<html>The server reported that it has detected a conflict.</html>",
141 ExceptionUtil.explainConflict(new OsmApiException("")));
142 assertEquals("<html>The server reported that it has detected a conflict.<br>Error message (untranslated):<br>header</html>",
143 ExceptionUtil.explainConflict(new OsmApiException(code, "header", "")));
144 assertEquals("<html>Closing of changeset <strong>1</strong> failed <br>because it has already been closed.",
145 ExceptionUtil.explainConflict(new OsmApiException(code, "The changeset 1 was closed at xxx", "")));
146 assertEquals("<html>Closing of changeset <strong>1</strong> failed<br> because it has already been closed on 2016-01-01 12:34:56.",
147 ExceptionUtil.explainConflict(new OsmApiException(code, "The changeset 1 was closed at 2016-01-01 12:34:56 UTC", "")));
148 DateUtilsTest.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
149 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
150 assertEquals("<html>Closing of changeset <strong>1</strong> failed<br> because it has already been closed on 2016-01-01 13:34:56.",
151 ExceptionUtil.explainConflict(new OsmApiException(code, "The changeset 1 was closed at 2016-01-01 12:34:56 UTC", "")));
152 }
153
154 /**
155 * Test of {@link ExceptionUtil#explainException} method.
156 */
157 @Test
158 void testExplainException() {
159 assertEquals("ResponseCode=0",
160 ExceptionUtil.explainException(new OsmApiException("")));
161 assertEquals("java.lang.Exception: ",
162 ExceptionUtil.explainException(new Exception("")));
163 assertEquals("java.lang.Exception",
164 ExceptionUtil.explainException(new Exception(null, null)));
165 assertEquals("test",
166 ExceptionUtil.explainException(new Exception("test")));
167 }
168
169 /**
170 * Test of {@link ExceptionUtil#explainFailedAuthorisation} method.
171 */
172 @Test
173 void testExplainFailedAuthorisation() {
174 assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+
175 "'The server replied an error with code 0.'</html>",
176 ExceptionUtil.explainFailedAuthorisation(new OsmApiException("")));
177 assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+
178 "'header (Code=403)'</html>",
179 ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "header", null)));
180 assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:"+
181 "<br>'header. body (Code=403)'</html>",
182 ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "header", "body")));
183 assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:"+
184 "<br>'header_body (Code=403)'</html>",
185 ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "header_body", "header_body")));
186 assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+
187 "'body (Code=403)'</html>",
188 ExceptionUtil.explainFailedAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, null, "body")));
189 }
190
191 /**
192 * Test of {@link ExceptionUtil#explainFailedOAuthAuthorisation} method.
193 */
194 @Test
195 void testExplainFailedOAuthAuthorisation() {
196 assertEquals("<html>Authorisation at the OSM server with the OAuth token 'null' failed.<br>"+
197 "The token is not authorised to access the protected resource<br>'unknown'.<br>"+
198 "Please launch the preferences dialog and retrieve another OAuth token.</html>",
199 ExceptionUtil.explainFailedOAuthAuthorisation(new OsmApiException("")));
200 assertEquals("<html>Authorisation at the OSM server with the OAuth token 'null' failed.<br>"+
201 "The token is not authorised to access the protected resource<br>'"+baseUrl+"'.<br>"+
202 "Please launch the preferences dialog and retrieve another OAuth token.</html>",
203 ExceptionUtil.explainFailedOAuthAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "", "", baseUrl)));
204 }
205
206 /**
207 * Test of {@link ExceptionUtil#explainFailedBasicAuthentication} method.
208 */
209 @Test
210 void testExplainFailedBasicAuthentication() {
211 assertEquals("<html>Authentication at the OSM server with the username '"+user+"' failed.<br>"+
212 "Please check the username and the password in the JOSM preferences.</html>",
213 ExceptionUtil.explainFailedBasicAuthentication(new OsmApiException("")));
214 }
215
216 /**
217 * Test of {@link ExceptionUtil#explainFailedOAuthAuthentication} method.
218 */
219 @Test
220 void testExplainFailedOAuthAuthentication() {
221 assertEquals("<html>Authentication at the OSM server with the OAuth token 'null' failed.<br>"+
222 "Please launch the preferences dialog and retrieve another OAuth token.</html>",
223 ExceptionUtil.explainFailedOAuthAuthentication(new OsmApiException("")));
224 }
225
226 /**
227 * Test of {@link ExceptionUtil#explainGenericOsmApiException} method.
228 */
229 @Test
230 void testExplainGenericOsmApiException() {
231 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
232 "the following error code and the following error message:<br><strong>Error code:<strong> 0<br>"+
233 "<strong>Error message (untranslated)</strong>: no error message available</html>",
234 ExceptionUtil.explainGenericOsmApiException(new OsmApiException("")));
235
236 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
237 "the following error code and the following error message:<br><strong>Error code:<strong> 500<br>"+
238 "<strong>Error message (untranslated)</strong>: header</html>",
239 ExceptionUtil.explainGenericOsmApiException(new OsmApiException(HttpURLConnection.HTTP_INTERNAL_ERROR, "header", null)));
240
241 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
242 "the following error code and the following error message:<br><strong>Error code:<strong> 500<br>"+
243 "<strong>Error message (untranslated)</strong>: body</html>",
244 ExceptionUtil.explainGenericOsmApiException(new OsmApiException(HttpURLConnection.HTTP_INTERNAL_ERROR, null, "body")));
245 }
246
247 /**
248 * Test of {@link ExceptionUtil#explainGoneForUnknownPrimitive} method.
249 */
250 @Test
251 void testExplainGoneForUnknownPrimitive() {
252 assertEquals("<html>The server reports that an object is deleted.<br>"+
253 "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "+
254 "<strong>Downloading failed</strong> if you tried to download this object.<br><br>"+
255 "The error message is:<br>ResponseCode=0</html>",
256 ExceptionUtil.explainGoneForUnknownPrimitive(new OsmApiException("")));
257 }
258
259 /**
260 * Test of {@link ExceptionUtil#explainInternalServerError} method.
261 */
262 @Test
263 void testExplainInternalServerError() {
264 assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+
265 "This is most likely a temporary problem. Please try again later.</html>",
266 ExceptionUtil.explainInternalServerError(new OsmApiException("")));
267 }
268
269 /**
270 * Test of {@link ExceptionUtil#explainMissingOAuthAccessTokenException} method.
271 */
272 @Test
273 void testExplainMissingOAuthAccessTokenException() {
274 assertEquals("<html>Failed to authenticate at the OSM server 'http://fake.xxx/api'.<br>"+
275 "You are using OAuth to authenticate but currently there is no<br>OAuth Access Token configured.<br>"+
276 "Please open the Preferences Dialog and generate or enter an Access Token.</html>",
277 ExceptionUtil.explainMissingOAuthAccessTokenException(new MissingOAuthAccessTokenException()));
278 }
279
280 /**
281 * Test of {@link ExceptionUtil#explainNestedIllegalDataException} method.
282 */
283 @Test
284 void testExplainNestedIllegalDataException() {
285 assertEquals("<html>Failed to download data. Its format is either unsupported, ill-formed, and/or inconsistent.<br><br>"+
286 "Details (untranslated): null</html>",
287 ExceptionUtil.explainNestedIllegalDataException(new OsmApiException("")));
288
289 assertEquals("<html>Failed to download data. Its format is either unsupported, ill-formed, and/or inconsistent.<br><br>"+
290 "Details (untranslated): test</html>",
291 ExceptionUtil.explainNestedIllegalDataException(new OsmApiException(new IllegalDataException("test"))));
292 }
293
294 /**
295 * Test of {@link ExceptionUtil#explainNestedIOException} method.
296 */
297 @Test
298 void testExplainNestedIOException() {
299 assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
300 "due to a problem with transferring data.<br>Details (untranslated): null</html>",
301 ExceptionUtil.explainNestedIOException(new OsmApiException("")));
302
303 assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
304 "due to a problem with transferring data.<br>Details (untranslated): test</html>",
305 ExceptionUtil.explainNestedIOException(new OsmApiException(new IOException("test"))));
306 }
307
308 /**
309 * Test of {@link ExceptionUtil#explainNestedSocketException} method.
310 */
311 @Test
312 void testExplainNestedSocketException() {
313 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
314 "Please check your internet connection.</html>",
315 ExceptionUtil.explainNestedSocketException(new OsmApiException("")));
316 }
317
318 /**
319 * Test of {@link ExceptionUtil#explainNestedUnknownHostException} method.
320 */
321 @Test
322 void testExplainNestedUnknownHostException() {
323 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
324 "Host name '"+host+"' could not be resolved. <br>"+
325 "Please check the API URL in your preferences and your internet connection.</html>",
326 ExceptionUtil.explainNestedUnknownHostException(new OsmApiException("")));
327 }
328
329 /**
330 * Test of {@link ExceptionUtil#explainNotFound} method.
331 */
332 @Test
333 void testExplainNotFound() {
334 assertEquals("<html>The OSM server '"+baseUrl+"' does not know about an object<br>"+
335 "you tried to read, update, or delete. Either the respective object<br>"+
336 "does not exist on the server or you are using an invalid URL to access<br>"+
337 "it. Please carefully check the server's address '"+baseUrl+"' for typos.</html>",
338 ExceptionUtil.explainNotFound(new OsmApiException("")));
339 }
340
341 /**
342 * Test of {@link ExceptionUtil#explainOfflineAccessException} method.
343 */
344 @Test
345 void testExplainOfflineAccessException() {
346 assertEquals("<html>Failed to download data.<br><br>Details: null</html>",
347 ExceptionUtil.explainOfflineAccessException(new OsmApiException("")));
348 assertEquals("<html>Failed to download data.<br><br>Details: test</html>",
349 ExceptionUtil.explainOfflineAccessException(new OsmApiException(new OfflineAccessException("test"))));
350 }
351
352 /**
353 * Test of {@link ExceptionUtil#explainOsmApiInitializationException} method.
354 */
355 @Test
356 void testExplainOsmApiInitializationException() {
357 assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+
358 "Check the server URL in your preferences and your internet connection.</html>",
359 ExceptionUtil.explainOsmApiInitializationException(new OsmApiInitializationException("")));
360 }
361
362 /**
363 * Test of {@link ExceptionUtil#explainOsmTransferException} method.
364 */
365 @Test
366 void testExplainOsmTransferException() {
367 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'<br>"+
368 "for security reasons. This is most likely because you are running<br>"+
369 "in an applet and because you did not load your applet from '"+host+"'.</html>",
370 ExceptionUtil.explainOsmTransferException(new OsmApiException(new SecurityException("test"))));
371
372 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
373 "Please check your internet connection.</html>",
374 ExceptionUtil.explainOsmTransferException(new OsmApiException(new SocketException("test"))));
375
376 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
377 "Host name '"+host+"' could not be resolved. <br>"+
378 "Please check the API URL in your preferences and your internet connection.</html>",
379 ExceptionUtil.explainOsmTransferException(new OsmApiException(new UnknownHostException("test"))));
380
381 assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
382 "due to a problem with transferring data.<br>Details (untranslated): test</html>",
383 ExceptionUtil.explainOsmTransferException(new OsmApiException(new IOException("test"))));
384
385 assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+
386 "Check the server URL in your preferences and your internet connection.</html>",
387 ExceptionUtil.explainOsmTransferException(new OsmApiInitializationException("")));
388
389 assertEquals("<html>Failed to upload to changeset <strong>0</strong><br>because it has already been closed on ?.",
390 ExceptionUtil.explainOsmTransferException(new ChangesetClosedException("")));
391
392 assertEquals("<html>Uploading to the server <strong>failed</strong> because your current<br>"+
393 "dataset violates a precondition.<br>The error message is:<br>ResponseCode=412</html>",
394 ExceptionUtil.explainOsmTransferException(new OsmApiException(HttpURLConnection.HTTP_PRECON_FAILED, "", "")));
395
396 assertEquals("<html>The server reports that an object is deleted.<br>"+
397 "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "+
398 "<strong>Downloading failed</strong> if you tried to download this object.<br><br>"+
399 "The error message is:<br>ResponseCode=410</html>",
400 ExceptionUtil.explainOsmTransferException(new OsmApiException(HttpURLConnection.HTTP_GONE, "", "")));
401
402 assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+
403 "This is most likely a temporary problem. Please try again later.</html>",
404 ExceptionUtil.explainOsmTransferException(new OsmApiException(HttpURLConnection.HTTP_INTERNAL_ERROR, "", "")));
405
406 assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>Error message(untranslated): </html>",
407 ExceptionUtil.explainOsmTransferException(new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "", "")));
408
409 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
410 "the following error code and the following error message:<br><strong>Error code:<strong> 509<br>"+
411 "<strong>Error message (untranslated)</strong>: </html>",
412 ExceptionUtil.explainOsmTransferException(new OsmApiException(509, "", "")));
413
414 assertEquals("ResponseCode=0",
415 ExceptionUtil.explainOsmTransferException(new OsmApiException("")));
416 }
417
418 /**
419 * Test of {@link ExceptionUtil#explainPreconditionFailed} method.
420 */
421 @Test
422 void testExplainPreconditionFailed() {
423 int code = HttpURLConnection.HTTP_PRECON_FAILED;
424 assertEquals("<html>Uploading to the server <strong>failed</strong> because your current<br>dataset violates a precondition.<br>"+
425 "The error message is:<br>ResponseCode=0</html>",
426 ExceptionUtil.explainPreconditionFailed(new OsmApiException("")));
427
428 assertEquals("<html>Uploading to the server <strong>failed</strong> because your current<br>dataset violates a precondition.<br>"+
429 "The error message is:<br>ResponseCode=412, Error Header=&lt;test&gt;</html>",
430 ExceptionUtil.explainPreconditionFailed(new OsmApiException(code, "test", "")));
431
432 assertEquals("<html><strong>Failed</strong> to delete <strong>node 1</strong>. It is still referred to by relation 1.<br>"+
433 "Please load the relation, remove the reference to the node, and upload again.</html>",
434 ExceptionUtil.explainPreconditionFailed(new OsmApiException(code, "Node 1 is still used by relation 1", "")));
435
436 assertEquals("<html><strong>Failed</strong> to delete <strong>node 1</strong>. It is still referred to by way 1.<br>"+
437 "Please load the way, remove the reference to the node, and upload again.</html>",
438 ExceptionUtil.explainPreconditionFailed(new OsmApiException(code, "Node 1 is still used by way 1", "")));
439
440 assertEquals("<html><strong>Failed</strong> to delete <strong>relation 1</strong>. It is still referred to by relation 2.<br>"+
441 "Please load the relation, remove the reference to the relation, and upload again.</html>",
442 ExceptionUtil.explainPreconditionFailed(new OsmApiException(code, "The relation 1 is used in relation 2", "")));
443
444 assertEquals("<html><strong>Failed</strong> to delete <strong>way 1</strong>. It is still referred to by relation 1.<br>"+
445 "Please load the relation, remove the reference to the way, and upload again.</html>",
446 ExceptionUtil.explainPreconditionFailed(new OsmApiException(code, "Way 1 is still used by relation 1", "")));
447
448 assertEquals("<html><strong>Failed</strong> to upload <strong>way 1</strong>. It refers to deleted nodes [1, 2].<br>"+
449 "Please load the nodes, remove the reference in the way, and upload again.</html>",
450 ExceptionUtil.explainPreconditionFailed(new OsmApiException(code, "Way 1 requires the nodes with id in 1,2", "")));
451 }
452}
Note: See TracBrowser for help on using the repository browser.