Changeset 17393 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2020-12-07T11:52:15+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/AlignInCircleActionTest.java
r17386 r17393 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 import static org.junit.jupiter.api.Assertions.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 7 9 8 10 import java.nio.file.Files; … … 14 16 import org.junit.jupiter.api.extension.RegisterExtension; 15 17 import org.openstreetmap.josm.TestUtils; 18 import org.openstreetmap.josm.actions.AlignInCircleAction.InvalidSelection; 16 19 import org.openstreetmap.josm.command.Command; 17 20 import org.openstreetmap.josm.data.osm.DataSet; 18 21 import org.openstreetmap.josm.data.osm.Node; 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 23 import org.openstreetmap.josm.data.osm.Way; 20 24 import org.openstreetmap.josm.io.OsmReader; 21 25 import org.openstreetmap.josm.testutils.JOSMTestRules; 26 import org.opentest4j.AssertionFailedError; 22 27 23 28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 71 76 /** 72 77 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/20041">Bug #20041</a>. 73 * Don't create move commands when no node is visibly moved 78 * Don't create move commands when no node is visibly moved. 74 79 * @throws Exception if an error occurs 75 80 */ … … 88 93 if (roundabout != null) { 89 94 ds.setSelected(roundabout); 90 assert Throws(AlignInCircleAction.InvalidSelection.class, () ->AlignInCircleAction.buildCommand(ds));95 assertNull(AlignInCircleAction.buildCommand(ds)); 91 96 } 92 97 } … … 150 155 } 151 156 157 /** 158 * Various cases of selections in file 159 * @throws Exception if an error occurs 160 */ 161 @Test 162 void testSelectionEvaluation() throws Exception { 163 DataSet ds = OsmReader.parseDataSet( 164 Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "alignCircleCases.osm")), null); 165 166 for (int i = 0; i < 80; i++) { 167 final String selVal = Integer.toString(i); 168 Set<OsmPrimitive> sel = ds.allPrimitives().stream().filter(p -> p.hasTag("sel", selVal)) 169 .collect(Collectors.toSet()); 170 if (sel.isEmpty()) 171 continue; 172 ds.setSelected(sel); 173 boolean selValid = sel.stream().noneMatch(p -> p.hasKey("invalid-selection")); 174 try { 175 AlignInCircleAction.buildCommand(ds); 176 assertTrue(selValid, "sel=" + selVal + " is not valid?"); 177 } catch (InvalidSelection e) { 178 assertFalse(selValid, "sel=" + selVal + " is not invalid?"); 179 } catch (Exception e) { 180 throw new AssertionFailedError("test failed: sel=" + selVal,e); 181 } 182 } 183 } 152 184 }
Note:
See TracChangeset
for help on using the changeset viewer.