Changeset 33410 in osm for applications/editors/josm/plugins/pt_assistant
- Timestamp:
- 2017-06-22T22:13:09+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutTest.java
r33404 r33410 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.actions; 2 3 … … 29 30 public class SplitRoundaboutTest extends AbstractTest { 30 31 31 32 33 34 35 32 DataSet ds; 33 OsmDataLayer layer; 34 SplitRoundaboutAction action; 35 SplitWayAction swa; 36 Way r1, r2, r3; 36 37 37 38 38 @Before 39 public void init() throws FileNotFoundException, IllegalDataException { 39 40 40 41 new JOSMFixture("../../JOSM/test/config/unit-josm.home").init(true); 41 42 42 43 ds = OsmReader.parseDataSet(new FileInputStream(AbstractTest.PATH_TO_ROUNDABOUT), null); 43 44 layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null); 44 45 Main.getLayerManager().addLayer(layer); 45 46 46 47 47 Main.pref.put("pt_assistant.roundabout-splitter.alignalways", true); 48 action = new SplitRoundaboutAction(); 48 49 swa = Main.main.menu.splitWay; 49 50 swa.setEnabled(true); 50 51 52 53 51 r1 = (Way) ds.getPrimitiveById(new SimplePrimitiveId(293302077L, OsmPrimitiveType.WAY)); 52 r2 = (Way) ds.getPrimitiveById(new SimplePrimitiveId(205833435L, OsmPrimitiveType.WAY)); 53 r3 = (Way) ds.getPrimitiveById(new SimplePrimitiveId(25739002L, OsmPrimitiveType.WAY)); 54 } 54 55 55 56 56 @Test 57 public void test1() { 57 58 58 Map<Relation, Integer> savedPositions = action.getSavedPositions(r1); 59 List<Node> splitNodes = action.getSplitNodes(r1); 60 assertEquals(4, splitNodes.size()); 61 ds.setSelected(splitNodes); 62 swa.actionPerformed(null); 63 64 Collection<Way> splitWays = ds.getSelectedWays(); 65 action.updateRelations(savedPositions, splitNodes, splitWays); 66 67 splitWays.forEach(w -> { 68 if (w.firstNode().getUniqueId() == 267843779L && w.lastNode().getUniqueId() == 2968718407L) 69 assertEquals(w.getReferrers().size(), 5); 70 else if (w.firstNode().getUniqueId() == 2968718407L && w.lastNode().getUniqueId() == 2383688231L) 71 assertEquals(w.getReferrers().size(), 0); 72 else if (w.firstNode().getUniqueId() == 2383688231L && w.lastNode().getUniqueId() == 267843741L) 73 assertEquals(w.getReferrers().size(), 5); 74 else if (w.firstNode().getUniqueId() == 267843741L && w.lastNode().getUniqueId() == 267843779L) 75 assertEquals(w.getReferrers().size(), 0); 76 else 77 fail(); 78 }); 79 } 80 81 @Test 82 public void test2() { 83 Map<Relation, Integer> savedPositions = action.getSavedPositions(r2); 84 List<Node> splitNodes = action.getSplitNodes(r2); 85 assertEquals(4, splitNodes.size()); 86 ds.setSelected(splitNodes); 59 Map<Relation, Integer> savedPositions = action.getSavedPositions(r1); 60 List<Node> splitNodes = action.getSplitNodes(r1); 61 assertEquals(4, splitNodes.size()); 62 ds.setSelected(splitNodes); 87 63 swa.actionPerformed(null); 88 64 89 90 65 Collection<Way> splitWays = ds.getSelectedWays(); 66 action.updateRelations(savedPositions, splitNodes, splitWays); 91 67 92 93 if(w.firstNode().getUniqueId() == 2158181809L && w.lastNode().getUniqueId() == 2158181798L)94 assertEquals(w.getReferrers().size(), 8);95 else if (w.firstNode().getUniqueId() == 2158181798L && w.lastNode().getUniqueId() == 2158181789L)96 97 else if (w.firstNode().getUniqueId() == 2158181789L && w.lastNode().getUniqueId() == 2158181803L)98 assertEquals(w.getReferrers().size(), 8);99 else if (w.firstNode().getUniqueId() == 2158181803L && w.lastNode().getUniqueId() == 2158181809L)100 101 102 103 104 68 splitWays.forEach(w -> { 69 if (w.firstNode().getUniqueId() == 267843779L && w.lastNode().getUniqueId() == 2968718407L) 70 assertEquals(w.getReferrers().size(), 5); 71 else if (w.firstNode().getUniqueId() == 2968718407L && w.lastNode().getUniqueId() == 2383688231L) 72 assertEquals(w.getReferrers().size(), 0); 73 else if (w.firstNode().getUniqueId() == 2383688231L && w.lastNode().getUniqueId() == 267843741L) 74 assertEquals(w.getReferrers().size(), 5); 75 else if (w.firstNode().getUniqueId() == 267843741L && w.lastNode().getUniqueId() == 267843779L) 76 assertEquals(w.getReferrers().size(), 0); 77 else 78 fail(); 79 }); 80 } 105 81 106 107 public void test3() {108 Map<Relation, Integer> savedPositions = action.getSavedPositions(r3);109 List<Node> splitNodes = action.getSplitNodes(r3);110 111 82 @Test 83 public void test2() { 84 Map<Relation, Integer> savedPositions = action.getSavedPositions(r2); 85 List<Node> splitNodes = action.getSplitNodes(r2); 86 assertEquals(4, splitNodes.size()); 87 ds.setSelected(splitNodes); 112 88 swa.actionPerformed(null); 113 89 114 115 90 Collection<Way> splitWays = ds.getSelectedWays(); 91 action.updateRelations(savedPositions, splitNodes, splitWays); 116 92 117 118 if(w.firstNode().getUniqueId() == 280697532L && w.lastNode().getUniqueId() == 280697452L)119 assertEquals(w.getReferrers().size(), 0);120 else if (w.firstNode().getUniqueId() == 280697452L && w.lastNode().getUniqueId() == 280697591L)121 assertEquals(w.getReferrers().size(), 2);122 else if (w.firstNode().getUniqueId() == 280697591L && w.lastNode().getUniqueId() == 280697534L)123 assertEquals(w.getReferrers().size(), 0);124 else if (w.firstNode().getUniqueId() == 280697534L && w.lastNode().getUniqueId() == 280697532L)125 assertEquals(w.getReferrers().size(), 1);126 127 128 129 93 splitWays.forEach(w -> { 94 if(w.firstNode().getUniqueId() == 2158181809L && w.lastNode().getUniqueId() == 2158181798L) 95 assertEquals(w.getReferrers().size(), 8); 96 else if (w.firstNode().getUniqueId() == 2158181798L && w.lastNode().getUniqueId() == 2158181789L) 97 assertEquals(w.getReferrers().size(), 0); 98 else if (w.firstNode().getUniqueId() == 2158181789L && w.lastNode().getUniqueId() == 2158181803L) 99 assertEquals(w.getReferrers().size(), 8); 100 else if (w.firstNode().getUniqueId() == 2158181803L && w.lastNode().getUniqueId() == 2158181809L) 101 assertEquals(w.getReferrers().size(), 0); 102 else 103 fail(); 104 }); 105 } 130 106 131 @After 132 public void end() { 107 @Test 108 public void test3() { 109 Map<Relation, Integer> savedPositions = action.getSavedPositions(r3); 110 List<Node> splitNodes = action.getSplitNodes(r3); 111 assertEquals(4, splitNodes.size()); 112 ds.setSelected(splitNodes); 113 swa.actionPerformed(null); 114 115 Collection<Way> splitWays = ds.getSelectedWays(); 116 action.updateRelations(savedPositions, splitNodes, splitWays); 117 118 splitWays.forEach(w -> { 119 if(w.firstNode().getUniqueId() == 280697532L && w.lastNode().getUniqueId() == 280697452L) 120 assertEquals(w.getReferrers().size(), 0); 121 else if (w.firstNode().getUniqueId() == 280697452L && w.lastNode().getUniqueId() == 280697591L) 122 assertEquals(w.getReferrers().size(), 2); 123 else if (w.firstNode().getUniqueId() == 280697591L && w.lastNode().getUniqueId() == 280697534L) 124 assertEquals(w.getReferrers().size(), 0); 125 else if (w.firstNode().getUniqueId() == 280697534L && w.lastNode().getUniqueId() == 280697532L) 126 assertEquals(w.getReferrers().size(), 1); 127 else 128 fail(); 129 }); 130 } 131 132 @After 133 public void end() { 133 134 Main.getLayerManager().removeLayer(layer); 134 135 } 135 136 }
Note:
See TracChangeset
for help on using the changeset viewer.