Class MockTelemetryBackend

java.lang.Object
org.wpilib.telemetry.MockTelemetryBackend
All Implemented Interfaces:
AutoCloseable, TelemetryBackend

public class MockTelemetryBackend extends Object implements TelemetryBackend
A telemetry backend that saves logged data to an array for unit testing purposes.

Logging is thread-safe, but callers must quiesce or externally synchronize logging while inspecting live results returned by this class.

  • Constructor Details

    • MockTelemetryBackend

      public MockTelemetryBackend()
      Constructor.
  • Method Details

    • getActions

      public List<MockTelemetryBackend.Action> getActions()
      Get logged actions.
      Returns:
      list of actions
    • clear

      public void clear()
      Clear logged actions.
    • getLastAction

      public MockTelemetryBackend.Action getLastAction(String path)
      Get the last action for a particular path.
      Parameters:
      path - path
      Returns:
      Action, or null if no update to that path
    • getLastValue

      public <T> T getLastValue(String path, Class<T> cls)
      Get the last action value for a particular path.
      Type Parameters:
      T - data type
      Parameters:
      path - path
      cls - class for desired data type
      Returns:
      Value, or null if no update to that path
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getEntry

      public TelemetryEntry getEntry(String path)
      Description copied from interface: TelemetryBackend
      Create an entry for the given path.

      Backend implementations must not throw from this method. Recoverable failures should be reported through TelemetryRegistry.reportWarning(String, String) and represented with a discard entry.

      Specified by:
      getEntry in interface TelemetryBackend
      Parameters:
      path - full name
      Returns:
      telemetry entry
    • removeEntry

      public void removeEntry(String path)
      Description copied from interface: TelemetryBackend
      Removes an entry for the given path.

      Backend implementations must not throw from this method.

      Specified by:
      removeEntry in interface TelemetryBackend
      Parameters:
      path - normalized full name