From a48f62fc07b5728c3cfb6e24dc965140cd9afdde Mon Sep 17 00:00:00 2001 From: Kevin Cooney Date: Sun, 12 Oct 2025 18:18:27 -0700 Subject: [PATCH] Add accessors for 'demand' and 'controlMode' in FakeMotor This is in preparation for making the 'demand' field package-scope. Now that FakeMotor has an 'isStopped' field, allowing code outside of FakeMotor to directly update the value is error-prone. --- .../ParameterizedIntakeSubsystemTest.java | 6 +++--- .../com/team2813/lib2813/testing/FakeMotor.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/src/test/java/com/team2813/lib2813/subsystems/ParameterizedIntakeSubsystemTest.java b/lib/src/test/java/com/team2813/lib2813/subsystems/ParameterizedIntakeSubsystemTest.java index 45eea151..9eccbac2 100644 --- a/lib/src/test/java/com/team2813/lib2813/subsystems/ParameterizedIntakeSubsystemTest.java +++ b/lib/src/test/java/com/team2813/lib2813/subsystems/ParameterizedIntakeSubsystemTest.java @@ -52,7 +52,7 @@ public void intakeItem(CommandTester commandTester) { commandTester.runUntilComplete(command); - assertThat(fakeMotor.demand).isWithin(0.01).of(params.intakeDemand()); + assertThat(fakeMotor.getDemand()).isWithin(0.01).of(params.intakeDemand()); } } @@ -80,7 +80,7 @@ public void outtakeItem(CommandTester commandTester) { commandTester.runUntilComplete(command); - assertThat(fakeMotor.demand).isWithin(0.01).of(params.outtakeDemand()); + assertThat(fakeMotor.getDemand()).isWithin(0.01).of(params.outtakeDemand()); } } @@ -101,6 +101,6 @@ public void stopAfterOuttakingItem(CommandTester commandTester) { } private void assertMotorIsRunning() { - assertThat(fakeMotor.demand).isNotWithin(0.01).of(0.0); + assertThat(fakeMotor.getDemand()).isNotWithin(0.01).of(0.0); } } diff --git a/testing/src/main/java/com/team2813/lib2813/testing/FakeMotor.java b/testing/src/main/java/com/team2813/lib2813/testing/FakeMotor.java index 93cf31aa..1e6d453e 100644 --- a/testing/src/main/java/com/team2813/lib2813/testing/FakeMotor.java +++ b/testing/src/main/java/com/team2813/lib2813/testing/FakeMotor.java @@ -24,6 +24,19 @@ public class FakeMotor implements Motor { public Resistance resistance = Resistance.ofBaseUnits(0.025f, Units.Ohms); private ControlMode controlMode = ControlMode.VOLTAGE; + /** Gets the most recently applied demand value for this motor. */ + public final double getDemand() { + return demand; + } + + /** + * Gets the control mode used for the most recent time the demand value was updated for this + * motor. + */ + public final ControlMode getControlMode() { + return controlMode; + } + /** * Gets the current voltage being applied to the motor. *