11package org .usfirst .frc .team199 .Robot2018 ;
22
3- import static org .junit .jupiter .api .Assertions .*;
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
5+ import static org .mockito .Mockito .mock ;
6+ import static org .mockito .Mockito .when ;
47
58import org .junit .jupiter .api .BeforeEach ;
69import org .junit .jupiter .api .Test ;
10+ import org .usfirst .frc .team199 .Robot2018 .autonomous .AutoUtils ;
11+ import org .usfirst .frc .team199 .Robot2018 .commands .AutoMoveTo ;
12+ import org .usfirst .frc .team199 .Robot2018 .subsystems .DrivetrainInterface ;
713
8- import static org .mockito .Mockito .*;
9-
10- import edu .wpi .first .wpilibj .command .Command ;
11- import edu .wpi .first .wpilibj .command .CommandGroup ;
12- import edu .wpi .first .wpilibj .command .Subsystem ;
13- import edu .wpi .first .wpilibj .internal .HardwareTimer ;
1414import edu .wpi .first .wpilibj .HLUsageReporting ;
1515import edu .wpi .first .wpilibj .PIDController ;
16+ import edu .wpi .first .wpilibj .PIDOutput ;
1617import edu .wpi .first .wpilibj .PIDSource ;
1718import edu .wpi .first .wpilibj .PIDSourceType ;
1819import edu .wpi .first .wpilibj .Timer ;
19- import edu .wpi .first .wpilibj .PIDOutput ;
20- import edu .wpi .first .wpilibj .livewindow .LiveWindow ;
21-
22- import com .kauailabs .navx .frc .AHRS ;
23-
24- import org .usfirst .frc .team199 .Robot2018 .commands .Autonomous ;
25- import org .usfirst .frc .team199 .Robot2018 .commands .TeleopDrive ;
26- import org .usfirst .frc .team199 .Robot2018 .commands .Autonomous .Position ;
27- import org .usfirst .frc .team199 .Robot2018 .commands .Autonomous .Strategy ;
28- import org .usfirst .frc .team199 .Robot2018 .subsystems .DrivetrainInterface ;
29- import org .usfirst .frc .team199 .Robot2018 .autonomous .AutoUtils ;
30- import org .usfirst .frc .team199 .Robot2018 .commands .AutoMoveTo ;
31-
32- import java .util .HashMap ;
33- import java .util .Map ;
20+ import edu .wpi .first .wpilibj .command .Command ;
21+ import edu .wpi .first .wpilibj .command .CommandGroup ;
22+ import edu .wpi .first .wpilibj .command .Subsystem ;
23+ import edu .wpi .first .wpilibj .internal .HardwareTimer ;
3424
3525class AutoMoveToTest {
3626
37- // May need a BeforeEach to reset AutoUtils.
27+ // May need a BeforeEach to reset AutoUtils
3828
3929 @ BeforeEach
4030 void setUp () {
@@ -48,90 +38,96 @@ void setUp() {
4838 HLUsageReporting .Interface usageReporter = mock (HLUsageReporting .Interface .class );
4939 HLUsageReporting .SetImplementation (usageReporter );
5040 }
51-
41+
5242 @ Test
5343 void testWPICommand () {
5444 Command command = new Command () {
55- protected boolean isFinished () { return false ; }
45+ protected boolean isFinished () {
46+ return false ;
47+ }
5648 };
5749 assertNotNull (command );
5850 }
59-
51+
6052 @ Test
6153 void testWPICommandGroup () {
6254 CommandGroup group = new CommandGroup ();
6355 assertNotNull (group );
6456
6557 Command command = new Command () {
66- protected boolean isFinished () { return false ; }
58+ protected boolean isFinished () {
59+ return false ;
60+ }
6761 };
6862 group .addSequential (command );
6963 }
70-
64+
7165 @ Test
7266 void testPIDController () {
7367 PIDSource source = mock (PIDSource .class );
74- PIDOutput output = mock (PIDOutput .class );
75-
68+ PIDOutput output = mock (PIDOutput .class );
69+
7670 PIDController ctrl = new PIDController (0 , 0 , 0 , source , output );
7771 assertNotNull (ctrl );
7872 }
79-
80- //@Test
73+
74+ // @Test
8175 // Problem instantiating Subsystem because of SendableBase using network tables.
8276 void testWPISubsystem () {
83- //LiveWindow.setEnabled(false);
77+ // LiveWindow.setEnabled(false);
8478 Subsystem subsystem = new Subsystem () {
8579 protected void initDefaultCommand () {
8680 setDefaultCommand (new Command () {
87- protected boolean isFinished () { return false ; }
81+ protected boolean isFinished () {
82+ return false ;
83+ }
8884 });
8985 }
9086 };
9187 assertNotNull (subsystem );
9288 }
93-
89+
9490 @ Test
9591 void testForwardAndRight () {
96- String [] args = {"(0,12)" ,"(12,12)" };
97-
98- AutoUtils .setRot (0 );
99- AutoUtils .setX (0 );
100- AutoUtils .setY (0 );
101-
92+ String [] args = { "(0,12)" , "(12,12)" };
93+
94+ AutoUtils .position . setRot (0 );
95+ AutoUtils .position . setX (0 );
96+ AutoUtils .position . setY (0 );
97+
10298 PIDSource pidGyroSrc = mock (PIDSource .class );
10399 when (pidGyroSrc .getPIDSourceType ()).thenReturn (PIDSourceType .kDisplacement );
104100 DrivetrainInterface dt = mock (DrivetrainInterface .class );
105- when (dt .getGyro ()).thenReturn (pidGyroSrc );
101+ when (dt .getGyro ()).thenReturn (pidGyroSrc );
106102 SmartDashboardInterface sd = mock (SmartDashboardInterface .class );
107103 PIDSource pidMoveSrc = mock (PIDSource .class );
108-
104+
109105 AutoMoveTo testAMT = new AutoMoveTo (args , dt , sd , pidMoveSrc );
110-
111- assertEquals (90 , AutoUtils .getRot ());
112- assertEquals (12 , AutoUtils .getX ());
113- assertEquals (12 , AutoUtils .getY ());
106+
107+ assertEquals (90 , AutoUtils .position . getRot ());
108+ assertEquals (12 , AutoUtils .position . getX ());
109+ assertEquals (12 , AutoUtils .position . getY ());
114110 }
115111
116112 @ Test
117113 void testForward () {
118- String [] args = {"(0,12)" };
119-
120- AutoUtils .setRot (0 );
121- AutoUtils .setX (0 );
122- AutoUtils .setY (0 );
123-
114+ String [] args = { "(0,12)" };
115+
116+ AutoUtils .position . setRot (0 );
117+ AutoUtils .position . setX (0 );
118+ AutoUtils .position . setY (0 );
119+
124120 PIDSource pidGyroSrc = mock (PIDSource .class );
125121 when (pidGyroSrc .getPIDSourceType ()).thenReturn (PIDSourceType .kDisplacement );
126122 DrivetrainInterface dt = mock (DrivetrainInterface .class );
127- when (dt .getGyro ()).thenReturn (pidGyroSrc );
123+ when (dt .getGyro ()).thenReturn (pidGyroSrc );
128124 SmartDashboardInterface sd = mock (SmartDashboardInterface .class );
129125 PIDSource pidMoveSrc = mock (PIDSource .class );
130-
126+
131127 AutoMoveTo testAMT = new AutoMoveTo (args , dt , sd , pidMoveSrc );
132-
133- assertEquals (0 , AutoUtils .getRot ());
134- assertEquals (0 , AutoUtils .getX ());
135- assertEquals (12 , AutoUtils .getY ());
128+
129+ assertEquals (0 , AutoUtils .position . getRot ());
130+ assertEquals (0 , AutoUtils .position . getX ());
131+ assertEquals (12 , AutoUtils .position . getY ());
136132 }
137133}
0 commit comments