Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java
r18775 r18776 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;18 17 import org.openstreetmap.josm.data.validation.OsmValidator; 19 import org.openstreetmap.josm.data.validation.Severity;20 18 import org.openstreetmap.josm.data.validation.TestError; 21 19 import org.openstreetmap.josm.data.validation.ValidationTask; … … 53 51 OsmValidator.initializeTests(); 54 52 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 }59 53 if (errors.stream().allMatch(TestError::isIgnored)) { 60 54 returnCode.set(true); -
trunk/src/org/openstreetmap/josm/data/validation/ValidationTask.java
r18752 r18776 108 108 } 109 109 if (this.onFinish != null) { 110 // Remove any low severity issues if they are not desired. 111 if (!(Boolean.TRUE.equals(ValidatorPrefHelper.PREF_OTHER.get()) && 112 (!this.beforeUpload || Boolean.TRUE.equals(ValidatorPrefHelper.PREF_OTHER_UPLOAD.get())))) { 113 // Use >= just in case we add additional levels. 114 this.errors.removeIf(error -> error.getSeverity().getLevel() >= Severity.OTHER.getLevel()); 115 } 110 116 this.onFinish.accept(this.errors); 111 117 } … … 125 131 getProgressMonitor().setCustomText(tr("Test {0}/{1}: Starting {2}", testCounter, tests.size(), test.getName())); 126 132 test.setBeforeUpload(this.beforeUpload); 127 test.setPartialSelection(formerValidatedPrimitives != null); 133 // Pre-upload checks only run on a partial selection. 134 test.setPartialSelection(this.beforeUpload || formerValidatedPrimitives != null); 128 135 test.startTest(getProgressMonitor().createSubTaskMonitor(validatedPrimitives.size(), false)); 129 136 test.visit(validatedPrimitives); -
trunk/test/unit/org/openstreetmap/josm/actions/upload/ValidateUploadHookTest.java
r18775 r18776 6 6 7 7 import java.util.Collections; 8 import java.util.stream.Stream; 8 9 9 10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 12 13 import org.junit.jupiter.api.extension.RegisterExtension; 13 14 import org.junit.jupiter.params.ParameterizedTest; 14 import org.junit.jupiter.params.provider.ValueSource; 15 import org.junit.jupiter.params.provider.Arguments; 16 import org.junit.jupiter.params.provider.MethodSource; 15 17 import org.openstreetmap.josm.TestUtils; 16 18 import org.openstreetmap.josm.data.APIDataSet; … … 48 50 } 49 51 52 static Stream<Arguments> testUploadOtherErrors() { 53 return Stream.of( 54 Arguments.of(true, true), 55 Arguments.of(true, false), 56 Arguments.of(false, false), 57 Arguments.of(false, true) 58 ); 59 } 60 50 61 @ParameterizedTest 51 @ValueSource(booleans = {true, false}) 52 void testUploadOtherErrors(boolean otherEnabled) { 53 ValidatorPrefHelper.PREF_OTHER_UPLOAD.put(otherEnabled); 62 @MethodSource 63 void testUploadOtherErrors(boolean otherUploadEnabled, boolean otherEnabled) { 64 ValidatorPrefHelper.PREF_OTHER.put(otherEnabled); 65 ValidatorPrefHelper.PREF_OTHER_UPLOAD.put(otherUploadEnabled); 54 66 final DataSet ds = new DataSet(); 55 67 final Way building = TestUtils.newWay("building=yes", new Node(new LatLon(33.2287665, -111.8259225)), … … 74 86 }; 75 87 new ValidateUploadHook().checkUpload(new APIDataSet(ds)); 76 assertEquals(! otherEnabled, mocker.getInvocationLog().isEmpty());88 assertEquals(!(otherEnabled && otherUploadEnabled), mocker.getInvocationLog().isEmpty()); 77 89 } 78 90 }
Note:
See TracChangeset
for help on using the changeset viewer.