Changeset 19228 in josm for trunk/test/unit
- Timestamp:
- 2024-09-20T14:06:54+02:00 (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r19175 r19228 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 8 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 9 import static org.junit.jupiter.api.Assertions.assertNotSame; … … 11 13 import static org.junit.jupiter.api.Assertions.fail; 12 14 15 import java.io.File; 16 import java.io.IOException; 13 17 import java.io.StringWriter; 14 18 import java.time.Instant; 15 19 import java.util.Arrays; 20 import java.util.List; 16 21 import java.util.function.BiConsumer; 22 import java.util.stream.Collectors; 17 23 import java.util.stream.Stream; 18 24 … … 22 28 import org.junit.jupiter.params.ParameterizedTest; 23 29 import org.junit.jupiter.params.provider.MethodSource; 30 import org.openstreetmap.josm.TestUtils; 31 import org.openstreetmap.josm.data.conflict.Conflict; 32 import org.openstreetmap.josm.data.conflict.ConflictCollection; 24 33 import org.openstreetmap.josm.data.coor.LatLon; 25 34 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 26 35 import org.openstreetmap.josm.data.projection.Projections; 36 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 37 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 38 import org.openstreetmap.josm.io.IllegalDataException; 39 import org.openstreetmap.josm.io.session.SessionReader; 40 import org.openstreetmap.josm.tools.Logging; 28 41 29 42 /** … … 1361 1374 } 1362 1375 1363 static Stream<BiConsumer<Node, Node>> test NonRegression23846() {1376 static Stream<BiConsumer<Node, Node>> testTicket23846() { 1364 1377 return Stream.of( 1365 1378 (firstNode, secondNode) -> firstNode.setModified(true), … … 1370 1383 @ParameterizedTest 1371 1384 @MethodSource 1372 void test NonRegression23846(BiConsumer<Node, Node> nodeSetup) {1385 void testTicket23846(BiConsumer<Node, Node> nodeSetup) { 1373 1386 final Node firstNode = new Node(1234, 1); 1374 1387 final Node secondNode = new Node(1234, 1); … … 1386 1399 assertTrue(secondNode.isReferrersDownloaded()); 1387 1400 } 1401 1402 /** 1403 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/23930">#23930</a> 1404 */ 1405 @Test 1406 void testTicket23930() throws IOException, IllegalDataException { 1407 final File file = new File(TestUtils.getRegressionDataFile(23930, "JOSM_conflict.joz")); 1408 final SessionReader reader = new SessionReader(); 1409 reader.loadSession(file, true, NullProgressMonitor.INSTANCE); 1410 final List<OsmDataLayer> layers = reader.getLayers().stream() 1411 .filter(OsmDataLayer.class::isInstance).map(OsmDataLayer.class::cast).collect(Collectors.toList()); 1412 final DataSet newWay = layers.stream().filter(layer -> layer.getName().equals("new_way.osm")) 1413 .map(OsmDataLayer::getDataSet).findFirst().orElseThrow(); 1414 final DataSet nodeDeleted = layers.stream().filter(layer -> layer.getName().equals("node_deleted.osm")) 1415 .map(OsmDataLayer::getDataSet).findFirst().orElseThrow(); 1416 final DataSetMerger merge = new DataSetMerger(nodeDeleted, newWay); 1417 Logging.clearLastErrorAndWarnings(); 1418 assertDoesNotThrow(() -> merge.merge(NullProgressMonitor.INSTANCE)); 1419 assertTrue(Logging.getLastErrorAndWarnings().isEmpty(), String.join("\n", Logging.getLastErrorAndWarnings())); 1420 final ConflictCollection conflicts = merge.getConflicts(); 1421 // There are a few differences in the files 1422 // 1. New node in layer 2: No need for conflict 1423 // 2. node 2427358529: layer 1 deletes it, layer 2 modifies it (conflict required) 1424 // 3. new way in layer 2 with new node and node 2427358529 (conflict required) 1425 // 4. Modification of way 32277602 in layer 1 removing node 2427358529 (conflict required) 1426 // Therefore, conflicts are as follows: 1427 // 1. A deleted node (n2427358529) with referrers (w32277602 and new way) and new tags ("fix tag=recheck position") 1428 assertEquals(1, conflicts.size()); 1429 final Conflict<?> conflict = conflicts.iterator().next(); 1430 final Node myNode = assertInstanceOf(Node.class, conflict.getMy()); 1431 final Node theirNode = assertInstanceOf(Node.class, conflict.getTheir()); 1432 assertFalse(theirNode.isDeleted()); 1433 assertFalse(myNode.isDeleted()); 1434 } 1388 1435 }
Note:
See TracChangeset
for help on using the changeset viewer.