mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[build] Apply spotless for java formatting (#1768)
Update checkstyle config to be compatible with spotless. Co-authored-by: Austin Shalit <austinshalit@gmail.com>
This commit is contained in:
@@ -7,9 +7,7 @@ package edu.wpi.first.wpilibj.fixtures;
|
||||
import edu.wpi.first.wpilibj.AnalogInput;
|
||||
import edu.wpi.first.wpilibj.AnalogOutput;
|
||||
|
||||
/**
|
||||
* A fixture that connects an {@link AnalogInput} and an {@link AnalogOutput}.
|
||||
*/
|
||||
/** A fixture that connects an {@link AnalogInput} and an {@link AnalogOutput}. */
|
||||
public abstract class AnalogCrossConnectFixture implements ITestFixture {
|
||||
private boolean m_initialized = false;
|
||||
|
||||
@@ -20,7 +18,6 @@ public abstract class AnalogCrossConnectFixture implements ITestFixture {
|
||||
|
||||
protected abstract AnalogOutput giveAnalogOutput();
|
||||
|
||||
|
||||
private void initialize() {
|
||||
synchronized (this) {
|
||||
if (!m_initialized) {
|
||||
@@ -66,9 +63,7 @@ public abstract class AnalogCrossConnectFixture implements ITestFixture {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analog Output.
|
||||
*/
|
||||
/** Analog Output. */
|
||||
public final AnalogOutput getOutput() {
|
||||
initialize();
|
||||
return m_output;
|
||||
@@ -78,6 +73,4 @@ public abstract class AnalogCrossConnectFixture implements ITestFixture {
|
||||
initialize();
|
||||
return m_input;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,15 +4,12 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.fixtures;
|
||||
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.DigitalOutput;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.DigitalOutput;
|
||||
|
||||
/**
|
||||
* Connects a digital input to a digital output.
|
||||
*/
|
||||
/** Connects a digital input to a digital output. */
|
||||
public class DIOCrossConnectFixture implements ITestFixture {
|
||||
private static final Logger logger = Logger.getLogger(DIOCrossConnectFixture.class.getName());
|
||||
|
||||
@@ -23,7 +20,7 @@ public class DIOCrossConnectFixture implements ITestFixture {
|
||||
/**
|
||||
* Constructs using two pre-allocated digital objects.
|
||||
*
|
||||
* @param input The input
|
||||
* @param input The input
|
||||
* @param output The output.
|
||||
*/
|
||||
public DIOCrossConnectFixture(DigitalInput input, DigitalOutput output) {
|
||||
@@ -37,7 +34,7 @@ public class DIOCrossConnectFixture implements ITestFixture {
|
||||
/**
|
||||
* Constructs a {@link DIOCrossConnectFixture} using the ports of the digital objects.
|
||||
*
|
||||
* @param input The port of the {@link DigitalInput}
|
||||
* @param input The port of the {@link DigitalInput}
|
||||
* @param output The port of the {@link DigitalOutput}
|
||||
*/
|
||||
public DIOCrossConnectFixture(Integer input, Integer output) {
|
||||
@@ -83,5 +80,4 @@ public class DIOCrossConnectFixture implements ITestFixture {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,15 +4,12 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.fixtures;
|
||||
|
||||
import edu.wpi.first.wpilibj.Counter;
|
||||
import edu.wpi.first.wpilibj.mockhardware.FakeCounterSource;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.Counter;
|
||||
import edu.wpi.first.wpilibj.mockhardware.FakeCounterSource;
|
||||
|
||||
/**
|
||||
* A fixture that can test the {@link Counter} using a {@link DIOCrossConnectFixture}.
|
||||
*/
|
||||
/** A fixture that can test the {@link Counter} using a {@link DIOCrossConnectFixture}. */
|
||||
public class FakeCounterFixture implements ITestFixture {
|
||||
private static final Logger logger = Logger.getLogger(FakeEncoderFixture.class.getName());
|
||||
|
||||
@@ -33,11 +30,10 @@ public class FakeCounterFixture implements ITestFixture {
|
||||
m_counter = new Counter(dio.getInput());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a FakeCounterFixture using two port numbers.
|
||||
*
|
||||
* @param input the input port
|
||||
* @param input the input port
|
||||
* @param output the output port
|
||||
*/
|
||||
public FakeCounterFixture(int input, int output) {
|
||||
@@ -65,7 +61,6 @@ public class FakeCounterFixture implements ITestFixture {
|
||||
return m_counter;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -74,7 +69,6 @@ public class FakeCounterFixture implements ITestFixture {
|
||||
@Override
|
||||
public boolean setup() {
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -104,6 +98,4 @@ public class FakeCounterFixture implements ITestFixture {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.fixtures;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.Encoder;
|
||||
import edu.wpi.first.wpilibj.mockhardware.FakeEncoderSource;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* An encoder that uses two {@link DIOCrossConnectFixture DIOCrossConnectFixtures} to test the
|
||||
@@ -25,9 +24,7 @@ public class FakeEncoderFixture implements ITestFixture {
|
||||
private final Encoder m_encoder;
|
||||
private int[] m_encoderPort = new int[2];
|
||||
|
||||
/**
|
||||
* Constructs a FakeEncoderFixture from two DIOCrossConnectFixture.
|
||||
*/
|
||||
/** Constructs a FakeEncoderFixture from two DIOCrossConnectFixture. */
|
||||
public FakeEncoderFixture(DIOCrossConnectFixture dio1, DIOCrossConnectFixture dio2) {
|
||||
assert dio1 != null;
|
||||
assert dio2 != null;
|
||||
@@ -38,9 +35,7 @@ public class FakeEncoderFixture implements ITestFixture {
|
||||
m_encoder = new Encoder(dio1.getInput(), dio2.getInput());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construcst a FakeEncoderFixture from a set of Digital I/O ports.
|
||||
*/
|
||||
/** Construcst a FakeEncoderFixture from a set of Digital I/O ports. */
|
||||
public FakeEncoderFixture(int inputA, int outputA, int inputB, int outputB) {
|
||||
assert outputA != outputB;
|
||||
assert outputA != inputA;
|
||||
@@ -108,6 +103,4 @@ public class FakeEncoderFixture implements ITestFixture {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.fixtures;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.Counter;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.Encoder;
|
||||
@@ -14,13 +11,16 @@ import edu.wpi.first.wpilibj.PWM;
|
||||
import edu.wpi.first.wpilibj.SpeedController;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Represents a physically connected Motor and Encoder to allow for unit tests on these different
|
||||
* pairs<br> Designed to allow the user to easily setup and tear down the fixture to allow for
|
||||
* reuse. This class should be explicitly instantiated in the TestBed class to allow any test to
|
||||
* access this fixture. This allows tests to be mailable so that you can easily reconfigure the
|
||||
* physical testbed without breaking the tests.
|
||||
* pairs<br>
|
||||
* Designed to allow the user to easily setup and tear down the fixture to allow for reuse. This
|
||||
* class should be explicitly instantiated in the TestBed class to allow any test to access this
|
||||
* fixture. This allows tests to be mailable so that you can easily reconfigure the physical testbed
|
||||
* without breaking the tests.
|
||||
*/
|
||||
public abstract class MotorEncoderFixture<T extends SpeedController> implements ITestFixture {
|
||||
private static final Logger logger = Logger.getLogger(MotorEncoderFixture.class.getName());
|
||||
@@ -32,11 +32,8 @@ public abstract class MotorEncoderFixture<T extends SpeedController> implements
|
||||
protected DigitalInput m_alphaSource; // Stored so it can be freed at tear down
|
||||
protected DigitalInput m_betaSource;
|
||||
|
||||
/**
|
||||
* Default constructor for a MotorEncoderFixture.
|
||||
*/
|
||||
public MotorEncoderFixture() {
|
||||
}
|
||||
/** Default constructor for a MotorEncoderFixture. */
|
||||
public MotorEncoderFixture() {}
|
||||
|
||||
public abstract int getPDPChannel();
|
||||
|
||||
@@ -75,7 +72,6 @@ public abstract class MotorEncoderFixture<T extends SpeedController> implements
|
||||
m_alphaSource = giveDigitalInputA();
|
||||
m_betaSource = giveDigitalInputB();
|
||||
|
||||
|
||||
m_encoder = new Encoder(m_alphaSource, m_betaSource);
|
||||
m_counters[0] = new Counter(m_alphaSource);
|
||||
m_counters[1] = new Counter(m_betaSource);
|
||||
@@ -130,7 +126,7 @@ public abstract class MotorEncoderFixture<T extends SpeedController> implements
|
||||
* Checks to see if the speed of the motor is within some range of a given value. This is used
|
||||
* instead of equals() because doubles can have inaccuracies.
|
||||
*
|
||||
* @param value The value to compare against
|
||||
* @param value The value to compare against
|
||||
* @param accuracy The accuracy range to check against to see if the
|
||||
* @return true if the range of values between motors speed accuracy contains the 'value'.
|
||||
*/
|
||||
@@ -160,7 +156,6 @@ public abstract class MotorEncoderFixture<T extends SpeedController> implements
|
||||
return wasReset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Safely tears down the MotorEncoder Fixture in a way that makes sure that even if an object
|
||||
* fails to initialize the rest of the fixture can still be torn down and the resources
|
||||
@@ -232,11 +227,10 @@ public abstract class MotorEncoderFixture<T extends SpeedController> implements
|
||||
// Get the generic type as a class
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<T> class1 =
|
||||
(Class<T>) ((ParameterizedType) getClass().getGenericSuperclass())
|
||||
.getActualTypeArguments()[0];
|
||||
(Class<T>)
|
||||
((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
string.append(class1.getSimpleName());
|
||||
string.append(">");
|
||||
return string.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ package edu.wpi.first.wpilibj.fixtures;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.Relay;
|
||||
|
||||
/**
|
||||
* A connection between a {@link Relay} and two {@link DigitalInput DigitalInputs}.
|
||||
*/
|
||||
/** A connection between a {@link Relay} and two {@link DigitalInput DigitalInputs}. */
|
||||
public abstract class RelayCrossConnectFixture implements ITestFixture {
|
||||
private DigitalInput m_inputOne;
|
||||
private DigitalInput m_inputTwo;
|
||||
@@ -18,7 +16,6 @@ public abstract class RelayCrossConnectFixture implements ITestFixture {
|
||||
private boolean m_initialized = false;
|
||||
private boolean m_freed = false;
|
||||
|
||||
|
||||
protected abstract Relay giveRelay();
|
||||
|
||||
protected abstract DigitalInput giveInputOne();
|
||||
@@ -86,8 +83,10 @@ public abstract class RelayCrossConnectFixture implements ITestFixture {
|
||||
m_inputTwo.close();
|
||||
m_freed = true;
|
||||
} else {
|
||||
throw new RuntimeException("You attempted to free the "
|
||||
+ RelayCrossConnectFixture.class.getSimpleName() + " multiple times");
|
||||
throw new RuntimeException(
|
||||
"You attempted to free the "
|
||||
+ RelayCrossConnectFixture.class.getSimpleName()
|
||||
+ " multiple times");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.fixtures;
|
||||
|
||||
|
||||
/**
|
||||
* This is an example of how to use the {@link ITestFixture} interface to create test fixtures for a
|
||||
* test.
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.fixtures;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.Servo;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A class to represent the a physical Camera with two servos (tilt and pan) designed to test to see
|
||||
@@ -24,7 +23,6 @@ public abstract class TiltPanCameraFixture implements ITestFixture {
|
||||
private Servo m_pan;
|
||||
private boolean m_initialized = false;
|
||||
|
||||
|
||||
protected abstract AnalogGyro giveGyro();
|
||||
|
||||
protected abstract AnalogGyro giveGyroParam(int center, double offset);
|
||||
@@ -33,11 +31,8 @@ public abstract class TiltPanCameraFixture implements ITestFixture {
|
||||
|
||||
protected abstract Servo givePan();
|
||||
|
||||
/**
|
||||
* Constructs the TiltPanCamera.
|
||||
*/
|
||||
public TiltPanCameraFixture() {
|
||||
}
|
||||
/** Constructs the TiltPanCamera. */
|
||||
public TiltPanCameraFixture() {}
|
||||
|
||||
@Override
|
||||
public boolean setup() {
|
||||
@@ -99,15 +94,14 @@ public abstract class TiltPanCameraFixture implements ITestFixture {
|
||||
m_tilt = null;
|
||||
m_pan.close();
|
||||
m_pan = null;
|
||||
if (m_gyro != null) { //in case not freed during gyro tests
|
||||
if (m_gyro != null) { // in case not freed during gyro tests
|
||||
m_gyro.close();
|
||||
m_gyro = null;
|
||||
}
|
||||
if (m_gyroParam != null) { //in case gyro tests failed before getting to this point
|
||||
if (m_gyroParam != null) { // in case gyro tests failed before getting to this point
|
||||
m_gyroParam.close();
|
||||
m_gyroParam = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user