Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java
r18752 r18775 15 15 import org.openstreetmap.josm.data.APIDataSet; 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; 17 18 import org.openstreetmap.josm.data.validation.OsmValidator; 19 import org.openstreetmap.josm.data.validation.Severity; 18 20 import org.openstreetmap.josm.data.validation.TestError; 19 21 import org.openstreetmap.josm.data.validation.ValidationTask; … … 51 53 OsmValidator.initializeTests(); 52 54 new ValidationTask(errors -> { 55 if (!Boolean.TRUE.equals(ValidatorPrefHelper.PREF_OTHER_UPLOAD.get())) { 56 // Use >= just in case we add additional levels. 57 errors.removeIf(error -> error.getSeverity().getLevel() >= Severity.OTHER.getLevel()); 58 } 53 59 if (errors.stream().allMatch(TestError::isIgnored)) { 54 60 returnCode.set(true); -
trunk/test/unit/org/openstreetmap/josm/actions/upload/ValidateUploadHookTest.java
r17275 r18775 2 2 package org.openstreetmap.josm.actions.upload; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 6 import org.junit.jupiter.api.extension.RegisterExtension; 7 import org.junit.jupiter.api.Test; 8 import org.openstreetmap.josm.data.APIDataSet; 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 7 import java.util.Collections; 10 8 11 9 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 10 import mockit.Mock; 11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.extension.RegisterExtension; 13 import org.junit.jupiter.params.ParameterizedTest; 14 import org.junit.jupiter.params.provider.ValueSource; 15 import org.openstreetmap.josm.TestUtils; 16 import org.openstreetmap.josm.data.APIDataSet; 17 import org.openstreetmap.josm.data.Bounds; 18 import org.openstreetmap.josm.data.DataSource; 19 import org.openstreetmap.josm.data.coor.LatLon; 20 import org.openstreetmap.josm.data.osm.DataSet; 21 import org.openstreetmap.josm.data.osm.Node; 22 import org.openstreetmap.josm.data.osm.Way; 23 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; 24 import org.openstreetmap.josm.gui.ExtendedDialog; 25 import org.openstreetmap.josm.gui.MainApplication; 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 import org.openstreetmap.josm.testutils.JOSMTestRules; 28 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 12 29 13 30 /** … … 21 38 @RegisterExtension 22 39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 23 public JOSMTestRules test = new JOSMTestRules(). fakeAPI().timeout(30000);40 public JOSMTestRules test = new JOSMTestRules().main().projection().fakeAPI().timeout(30000); 24 41 25 42 /** … … 30 47 assertTrue(new ValidateUploadHook().checkUpload(new APIDataSet())); 31 48 } 49 50 @ParameterizedTest 51 @ValueSource(booleans = {true, false}) 52 void testUploadOtherErrors(boolean otherEnabled) { 53 ValidatorPrefHelper.PREF_OTHER_UPLOAD.put(otherEnabled); 54 final DataSet ds = new DataSet(); 55 final Way building = TestUtils.newWay("building=yes", new Node(new LatLon(33.2287665, -111.8259225)), 56 new Node(new LatLon(33.2287335, -111.8257513)), new Node(new LatLon(33.2285316, -111.8258086)), 57 new Node(new LatLon(33.2285696, -111.8259781))); 58 ds.addPrimitiveRecursive(building); 59 building.addNode(building.firstNode()); 60 ds.addDataSource(new DataSource(new Bounds(33, -112, 34, -111), "")); 61 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, 62 "ValidateUploadHookTest#testUploadOtherErrors", null)); 63 final ExtendedDialogMocker mocker = 64 new ExtendedDialogMocker(Collections.singletonMap("Suspicious data found. Upload anyway?", "Cancel")) { 65 @Override 66 protected String getString(ExtendedDialog instance) { 67 return instance.getTitle(); 68 } 69 70 @Mock 71 public void dispose() { 72 // Do nothing 73 } 74 }; 75 new ValidateUploadHook().checkUpload(new APIDataSet(ds)); 76 assertEquals(!otherEnabled, mocker.getInvocationLog().isEmpty()); 77 } 32 78 }
Note:
See TracChangeset
for help on using the changeset viewer.