Class MockTelemetryBackend
java.lang.Object
org.wpilib.telemetry.MockTelemetryBackend
- All Implemented Interfaces:
AutoCloseable, 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA logged action.static final recordValue for keepDuplicate() action.static final recordValue for logProtobuf() action.static final recordValue for logRaw() action.static final recordValue for logString() action.static final recordValue for logStructArray() action.static final recordValue for logStruct() action.static final recordValue for setProperty() action. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear logged actions.voidclose()Get logged actions.Create an entry for the given path.getLastAction(String path) Get the last action for a particular path.<T> TgetLastValue(String path, Class<T> cls) Get the last action value for a particular path.voidremoveEntry(String path) Removes an entry for the given path.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TelemetryBackend
ownsBackend, sharesBackendWith
-
Constructor Details
-
MockTelemetryBackend
public MockTelemetryBackend()Constructor.
-
-
Method Details
-
getActions
-
clear
public void clear()Clear logged actions. -
getLastAction
Get the last action for a particular path.- Parameters:
path- path- Returns:
- Action, or null if no update to that path
-
getLastValue
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getEntry
Description copied from interface:TelemetryBackendCreate 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:
getEntryin interfaceTelemetryBackend- Parameters:
path- full name- Returns:
- telemetry entry
-
removeEntry
Description copied from interface:TelemetryBackendRemoves an entry for the given path.Backend implementations must not throw from this method.
- Specified by:
removeEntryin interfaceTelemetryBackend- Parameters:
path- normalized full name
-