Class Test

    • Constructor Summary

      Constructors 
      Constructor Description
      Test​(java.lang.String name)
      Constructor
      Test​(java.lang.String name, java.lang.String description)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      java.lang.Object getSource()
      Returns the name of this class.
      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 removeIrrelevantErrors​(java.util.Collection<? extends OsmPrimitive> given)
      Filter the list of errors, remove all which do not concern the given list of primitives
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • name

        protected final java.lang.String name
        Name of the test
      • description

        protected final java.lang.String description
        Description of the test
      • enabled

        public boolean enabled
        Whether this test is enabled. Enabled by default
      • checkEnabled

        protected javax.swing.JCheckBox checkEnabled
        The preferences check for validation
      • checkBeforeUpload

        protected javax.swing.JCheckBox checkBeforeUpload
        The preferences check for validation on upload
      • testBeforeUpload

        public boolean testBeforeUpload
        Whether this test must check before upload. Enabled by default
      • isBeforeUpload

        protected boolean isBeforeUpload
        Whether this test is performing just before an upload
      • partialSelection

        protected boolean partialSelection
        Whether the test is run on a partial selection data
      • stopwatch

        protected Stopwatch stopwatch
        the start time to compute elapsed time when test finishes
    • Constructor Detail

      • Test

        public Test​(java.lang.String name,
                    java.lang.String description)
        Constructor
        Parameters:
        name - Name of the test
        description - Description of the test
      • Test

        public Test​(java.lang.String name)
        Constructor
        Parameters:
        name - Name of the test
    • Method Detail

      • initialize

        public void initialize()
                        throws java.lang.Exception
        Initializes any global data used this tester.
        Throws:
        java.lang.Exception - When cannot initialize the test
      • startTest

        public void startTest​(ProgressMonitor progressMonitor)
        Start the test using a given progress monitor
        Parameters:
        progressMonitor - the progress monitor
      • setPartialSelection

        public void setPartialSelection​(boolean partialSelection)
        Flag notifying that this test is run over a partial data selection
        Parameters:
        partialSelection - Whether the test is on a partial selection data
      • getErrors

        public java.util.List<TestErrorgetErrors()
        Gets the validation errors accumulated until this moment.
        Returns:
        The list of errors
      • endTest

        public void endTest()
        Notification of the end of the test. The tester may perform additional actions and destroy the used structures.

        If you override this method, don't forget to cleanup progressMonitor (most overrides call super.endTest() to do this).

      • visit

        public void visit​(java.util.Collection<OsmPrimitive> selection)
        Visits all primitives to be tested. These primitives are always visited in the same order: nodes first, then ways.
        Parameters:
        selection - The primitives to be tested
      • isPrimitiveUsable

        public boolean isPrimitiveUsable​(OsmPrimitive p)
        Determines if the primitive is usable for tests.
        Parameters:
        p - The primitive
        Returns:
        true if the primitive can be tested, false otherwise
      • addGui

        public void addGui​(javax.swing.JPanel testPanel)
        Allow the tester to manage its own preferences
        Parameters:
        testPanel - The panel to add any preferences component
      • ok

        public boolean ok()
        Called when the used submits the preferences
        Returns:
        true if restart is required, false otherwise
      • fixError

        public Command fixError​(TestError testError)
        Fixes the error with the appropriate command
        Parameters:
        testError - error to fix
        Returns:
        The command to fix the error
      • isFixable

        public boolean isFixable​(TestError testError)
        Returns true if the given error can be fixed automatically
        Parameters:
        testError - The error to check if can be fixed
        Returns:
        true if the error can be fixed
      • testBeforeUpload

        public boolean testBeforeUpload()
        Returns true if this plugin must check the uploaded data before uploading
        Returns:
        true if this plugin must check the uploaded data before uploading
      • setBeforeUpload

        public void setBeforeUpload​(boolean isUpload)
        Sets the flag that marks an upload check
        Parameters:
        isUpload - if true, the test is before upload
      • getName

        public java.lang.String getName()
        Returns the test name.
        Returns:
        The test name
      • isCanceled

        public boolean isCanceled()
        Determines if the test has been canceled.
        Returns:
        true if the test has been canceled, false otherwise
      • deletePrimitivesIfNeeded

        protected final 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. If all primitives have already been deleted, null is returned.
        Parameters:
        primitives - The primitives wanted for deletion
        Returns:
        a Delete command on all primitives that have not yet been deleted, or null otherwise
      • isBuilding

        protected static final boolean isBuilding​(OsmPrimitive p)
        Determines if the specified primitive denotes a building.
        Parameters:
        p - The primitive to be tested
        Returns:
        True if building key is set and different from no,entrance
      • isResidentialArea

        protected static final boolean isResidentialArea​(OsmPrimitive p)
        Determines if the specified primitive denotes a residential area.
        Parameters:
        p - The primitive to be tested
        Returns:
        True if landuse key is equal to residential
      • clear

        public void clear()
        Free resources.
      • getSource

        public java.lang.Object getSource()
        Returns the name of this class.
        Returns:
        the name of this class (for ToolTip)
        Since:
        15972
      • removeIrrelevantErrors

        public void removeIrrelevantErrors​(java.util.Collection<? extends OsmPrimitive> given)
        Filter the list of errors, remove all which do not concern the given list of primitives
        Parameters:
        given - the list of primitives
        Since:
        18960