public class Test extends java.lang.Object implements OsmPrimitiveVisitor
A test is a primitive visitor, so that it can access to all data to be validated. These primitives are always visited in the same order: nodes first, then ways.
Modifier and Type | Class and Description |
---|---|
static class |
Test.TagTest
A test that forwards all primitives to
Test.TagTest.check(OsmPrimitive) . |
Modifier and Type | Field and Description |
---|---|
protected javax.swing.JCheckBox |
checkBeforeUpload
The preferences check for validation on upload
|
protected javax.swing.JCheckBox |
checkEnabled
The preferences check for validation
|
protected java.lang.String |
description
Description of the test
|
boolean |
enabled
Whether this test is enabled.
|
protected java.util.List<TestError> |
errors
The list of errors
|
protected static java.util.function.Predicate<OsmPrimitive> |
IN_DOWNLOADED_AREA |
protected static java.util.function.Predicate<OsmPrimitive> |
IN_DOWNLOADED_AREA_STRICT |
protected boolean |
isBeforeUpload
Whether this test is performing just before an upload
|
protected java.lang.String |
name
Name of the test
|
protected boolean |
partialSelection
Whether the test is run on a partial selection data
|
protected ProgressMonitor |
progressMonitor
the progress monitor to use
|
private boolean |
showElementCount |
protected Stopwatch |
stopwatch
the start time to compute elapsed time when test finishes
|
boolean |
testBeforeUpload
Whether this test must check before upload.
|
Constructor and Description |
---|
Test(java.lang.String name)
Constructor
|
Test(java.lang.String name,
java.lang.String description)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addGui(javax.swing.JPanel testPanel)
Allow the tester to manage its own preferences
|
void |
clear()
Free resources.
|
protected Command |
deletePrimitivesIfNeeded(java.util.Collection<? extends OsmPrimitive> primitives)
Build a Delete command on all primitives that have not yet been deleted manually by user, or by another error fix.
|
void |
endTest()
Notification of the end of the test.
|
Command |
fixError(TestError testError)
Fixes the error with the appropriate command
|
java.util.List<TestError> |
getErrors()
Gets the validation errors accumulated until this moment.
|
java.lang.String |
getName()
Returns the test name.
|
void |
initialize()
Initializes any global data used this tester.
|
protected static boolean |
isBuilding(OsmPrimitive p)
Determines if the specified primitive denotes a building.
|
boolean |
isCanceled()
Determines if the test has been canceled.
|
boolean |
isFixable(TestError testError)
Returns true if the given error can be fixed automatically
|
boolean |
isPrimitiveUsable(OsmPrimitive p)
Determines if the primitive is usable for tests.
|
protected static boolean |
isResidentialArea(OsmPrimitive p)
Determines if the specified primitive denotes a residential area.
|
boolean |
ok()
Called when the used submits the preferences
|
void |
setBeforeUpload(boolean isUpload)
Sets the flag that marks an upload check
|
void |
setPartialSelection(boolean partialSelection)
Flag notifying that this test is run over a partial data selection
|
protected void |
setShowElements(boolean b) |
void |
startTest(ProgressMonitor progressMonitor)
Start the test using a given progress monitor
|
boolean |
testBeforeUpload()
Returns true if this plugin must check the uploaded data before uploading
|
void |
visit(java.util.Collection<OsmPrimitive> selection)
Visits all primitives to be tested.
|
void |
visit(Node n)
Visiting call for points.
|
void |
visit(Relation r)
Visiting call for relations.
|
void |
visit(Way w)
Visiting call for lines.
|
protected static final java.util.function.Predicate<OsmPrimitive> IN_DOWNLOADED_AREA
protected static final java.util.function.Predicate<OsmPrimitive> IN_DOWNLOADED_AREA_STRICT
protected final java.lang.String name
protected final java.lang.String description
public boolean enabled
protected javax.swing.JCheckBox checkEnabled
protected javax.swing.JCheckBox checkBeforeUpload
public boolean testBeforeUpload
protected boolean isBeforeUpload
protected boolean partialSelection
protected ProgressMonitor progressMonitor
private boolean showElementCount
public Test(java.lang.String name, java.lang.String description)
name
- Name of the testdescription
- Description of the testpublic Test(java.lang.String name)
name
- Name of the testpublic void initialize() throws java.lang.Exception
java.lang.Exception
- When cannot initialize the testpublic void startTest(ProgressMonitor progressMonitor)
progressMonitor
- the progress monitorpublic void setPartialSelection(boolean partialSelection)
partialSelection
- Whether the test is on a partial selection datapublic java.util.List<TestError> getErrors()
public void endTest()
If you override this method, don't forget to cleanup progressMonitor
(most overrides call super.endTest()
to do this).
public void visit(java.util.Collection<OsmPrimitive> selection)
selection
- The primitives to be testedpublic boolean isPrimitiveUsable(OsmPrimitive p)
p
- The primitivetrue
if the primitive can be tested, false
otherwisepublic void visit(Node n)
OsmPrimitiveVisitor
visit
in interface OsmPrimitiveVisitor
n
- The node to inspect.public void visit(Way w)
OsmPrimitiveVisitor
visit
in interface OsmPrimitiveVisitor
w
- The way to inspect.public void visit(Relation r)
OsmPrimitiveVisitor
visit
in interface OsmPrimitiveVisitor
r
- The relation to inspect.public void addGui(javax.swing.JPanel testPanel)
testPanel
- The panel to add any preferences componentpublic boolean ok()
true
if restart is required, false
otherwisepublic Command fixError(TestError testError)
testError
- error to fixpublic boolean isFixable(TestError testError)
testError
- The error to check if can be fixedpublic boolean testBeforeUpload()
public void setBeforeUpload(boolean isUpload)
isUpload
- if true, the test is before uploadpublic java.lang.String getName()
public boolean isCanceled()
true
if the test has been canceled, false
otherwiseprotected final Command deletePrimitivesIfNeeded(java.util.Collection<? extends OsmPrimitive> primitives)
primitives
- The primitives wanted for deletionprotected static final boolean isBuilding(OsmPrimitive p)
p
- The primitive to be testedprotected static final boolean isResidentialArea(OsmPrimitive p)
p
- The primitive to be testedpublic void clear()
protected void setShowElements(boolean b)