@@ -12,84 +12,101 @@ import org.junit.runners.Parameterized
1212class WaypointExTest {
1313
1414 @RunWith(Parameterized ::class )
15- class FilterTest (
15+ class FilterTest internal constructor (
1616 private val waypoints : List <Waypoint >,
17- private val requestedWaypointsExpected : List <@ Waypoint.Type Int >,
18- private val legsWaypointsExpected : List <@ Waypoint.Type Int >
17+ private val requestedWaypointsExpected : List <Waypoint .InternalType >,
18+ private val legsWaypointsExpected : List <Waypoint .InternalType >
1919 ) {
2020 companion object {
2121 @JvmStatic
2222 @Parameterized.Parameters
2323 fun data () = listOf (
2424 arrayOf(
25- provideWaypoints(Waypoint .REGULAR , Waypoint .SILENT , Waypoint .REGULAR ),
26- listOf (Waypoint .REGULAR , Waypoint .SILENT , Waypoint .REGULAR ),
27- listOf (Waypoint .REGULAR , Waypoint .REGULAR ),
25+ provideWaypoints(
26+ Waypoint .InternalType .Regular ,
27+ Waypoint .InternalType .Silent ,
28+ Waypoint .InternalType .Regular
29+ ),
30+ listOf (
31+ Waypoint .InternalType .Regular ,
32+ Waypoint .InternalType .Silent ,
33+ Waypoint .InternalType .Regular
34+ ),
35+ listOf (Waypoint .InternalType .Regular , Waypoint .InternalType .Regular ),
2836 ),
2937 arrayOf(
3038 provideWaypoints(
31- Waypoint .REGULAR ,
32- Waypoint .SILENT ,
33- Waypoint .EV_CHARGING ,
34- Waypoint .SILENT ,
35- Waypoint .REGULAR
36- ),
37- listOf (Waypoint .REGULAR , Waypoint .SILENT , Waypoint .SILENT , Waypoint .REGULAR ),
38- listOf (Waypoint .REGULAR , Waypoint .EV_CHARGING , Waypoint .REGULAR ),
39+ Waypoint .InternalType .Regular ,
40+ Waypoint .InternalType .Silent ,
41+ Waypoint .InternalType .EvCharging ,
42+ Waypoint .InternalType .Silent ,
43+ Waypoint .InternalType .Regular
44+ ),
45+ listOf (
46+ Waypoint .InternalType .Regular ,
47+ Waypoint .InternalType .Silent ,
48+ Waypoint .InternalType .Silent ,
49+ Waypoint .InternalType .Regular
50+ ),
51+ listOf (
52+ Waypoint .InternalType .Regular ,
53+ Waypoint .InternalType .EvCharging ,
54+ Waypoint .InternalType .Regular
55+ ),
3956 ),
4057 arrayOf(
4158 provideWaypoints(
42- Waypoint .REGULAR ,
43- Waypoint .EV_CHARGING ,
44- Waypoint .EV_CHARGING ,
45- Waypoint .EV_CHARGING ,
46- Waypoint .REGULAR
59+ Waypoint .InternalType . Regular ,
60+ Waypoint .InternalType . EvCharging ,
61+ Waypoint .InternalType . EvCharging ,
62+ Waypoint .InternalType . EvCharging ,
63+ Waypoint .InternalType . Regular
4764 ),
48- listOf (Waypoint .REGULAR , Waypoint .REGULAR ),
65+ listOf (Waypoint .InternalType . Regular , Waypoint .InternalType . Regular ),
4966 listOf (
50- Waypoint .REGULAR ,
51- Waypoint .EV_CHARGING ,
52- Waypoint .EV_CHARGING ,
53- Waypoint .EV_CHARGING ,
54- Waypoint .REGULAR
67+ Waypoint .InternalType . Regular ,
68+ Waypoint .InternalType . EvCharging ,
69+ Waypoint .InternalType . EvCharging ,
70+ Waypoint .InternalType . EvCharging ,
71+ Waypoint .InternalType . Regular
5572 ),
5673 ),
5774 arrayOf(
5875 provideWaypoints(
59- Waypoint .REGULAR ,
60- Waypoint .SILENT ,
61- Waypoint .REGULAR ,
62- Waypoint .REGULAR ,
63- Waypoint .EV_CHARGING ,
64- Waypoint .REGULAR
76+ Waypoint .InternalType . Regular ,
77+ Waypoint .InternalType . Silent ,
78+ Waypoint .InternalType . Regular ,
79+ Waypoint .InternalType . Regular ,
80+ Waypoint .InternalType . EvCharging ,
81+ Waypoint .InternalType . Regular
6582 ),
6683 listOf (
67- Waypoint .REGULAR ,
68- Waypoint .SILENT ,
69- Waypoint .REGULAR ,
70- Waypoint .REGULAR ,
71- Waypoint .REGULAR
84+ Waypoint .InternalType . Regular ,
85+ Waypoint .InternalType . Silent ,
86+ Waypoint .InternalType . Regular ,
87+ Waypoint .InternalType . Regular ,
88+ Waypoint .InternalType . Regular
7289 ),
7390 listOf (
74- Waypoint .REGULAR ,
75- Waypoint .REGULAR ,
76- Waypoint .REGULAR ,
77- Waypoint .EV_CHARGING ,
78- Waypoint .REGULAR
91+ Waypoint .InternalType . Regular ,
92+ Waypoint .InternalType . Regular ,
93+ Waypoint .InternalType . Regular ,
94+ Waypoint .InternalType . EvCharging ,
95+ Waypoint .InternalType . Regular
7996 ),
8097 ),
8198 )
8299
83- fun checkWaypoints (
84- expectedWaypoints : List <@ Waypoint.Type Int >,
100+ private fun checkWaypoints (
101+ expectedWaypoints : List <Waypoint .InternalType >,
85102 modified : List <Waypoint >,
86103 original : List <Waypoint >,
87104 ) {
88105 assertEquals(expectedWaypoints.size, modified.size)
89106
90107 var bufferIndex = - 1
91108 modified.forEachIndexed { index, waypoint ->
92- assertEquals(expectedWaypoints[index], waypoint.type )
109+ assertEquals(expectedWaypoints[index], waypoint.internalType )
93110 assertTrue(original.contains(waypoint))
94111 val idx = original.indexOf(waypoint)
95112 assertTrue(idx > bufferIndex)
@@ -101,10 +118,14 @@ class WaypointExTest {
101118 @Test
102119 fun testCases () {
103120 checkWaypoints(
104- requestedWaypointsExpected, waypoints.filter { it.isRequestedWaypoint() }, waypoints
121+ requestedWaypointsExpected,
122+ waypoints.filter { it.isRequestedWaypoint() },
123+ waypoints
105124 )
106125 checkWaypoints(
107- legsWaypointsExpected, waypoints.filter { it.isLegWaypoint() }, waypoints
126+ legsWaypointsExpected,
127+ waypoints.filter { it.isLegWaypoint() },
128+ waypoints
108129 )
109130 }
110131 }
@@ -124,73 +145,73 @@ class WaypointExTest {
124145 arrayOf(
125146 " Next index: 1 for 2 relevant waypoints and remaining waypoint 1" ,
126147 provideWaypoints(
127- Waypoint .REGULAR ,
128- Waypoint .REGULAR
148+ Waypoint .InternalType . Regular ,
149+ Waypoint .InternalType . Regular
129150 ),
130151 1 ,
131152 1 ,
132153 ),
133154 arrayOf(
134155 " Next index: 1 for 3 relevant waypoints and remaining waypoint 2" ,
135156 provideWaypoints(
136- Waypoint .REGULAR ,
137- Waypoint .SILENT ,
138- Waypoint .REGULAR
157+ Waypoint .InternalType . Regular ,
158+ Waypoint .InternalType . Silent ,
159+ Waypoint .InternalType . Regular
139160 ),
140161 2 ,
141162 1 ,
142163 ),
143164 arrayOf(
144165 " Next index: 2 for 3 relevant waypoints and remaining waypoint 1" ,
145166 provideWaypoints(
146- Waypoint .REGULAR ,
147- Waypoint .SILENT ,
148- Waypoint .REGULAR
167+ Waypoint .InternalType . Regular ,
168+ Waypoint .InternalType . Silent ,
169+ Waypoint .InternalType . Regular
149170 ),
150171 1 ,
151172 2 ,
152173 ),
153174 arrayOf(
154175 " Next index: 3 for 4 relevant waypoints and remaining waypoint 1" ,
155176 provideWaypoints(
156- Waypoint .REGULAR ,
157- Waypoint .SILENT ,
158- Waypoint .SILENT ,
159- Waypoint .REGULAR
177+ Waypoint .InternalType . Regular ,
178+ Waypoint .InternalType . Silent ,
179+ Waypoint .InternalType . Silent ,
180+ Waypoint .InternalType . Regular
160181 ),
161182 1 ,
162183 3 ,
163184 ),
164185 arrayOf(
165186 " Next index: 1 for 2 relevant waypoints (1 is EV) and remaining waypoint 2" ,
166187 provideWaypoints(
167- Waypoint .REGULAR ,
168- Waypoint .EV_CHARGING ,
169- Waypoint .REGULAR
188+ Waypoint .InternalType . Regular ,
189+ Waypoint .InternalType . EvCharging ,
190+ Waypoint .InternalType . Regular
170191 ),
171192 2 ,
172193 1 ,
173194 ),
174195 arrayOf(
175196 " Next index: 1 for 3 relevant waypoints (2 is EV) and remaining waypoint 4" ,
176197 provideWaypoints(
177- Waypoint .REGULAR ,
178- Waypoint .EV_CHARGING ,
179- Waypoint .SILENT ,
180- Waypoint .EV_CHARGING ,
181- Waypoint .REGULAR
198+ Waypoint .InternalType . Regular ,
199+ Waypoint .InternalType . EvCharging ,
200+ Waypoint .InternalType . Silent ,
201+ Waypoint .InternalType . EvCharging ,
202+ Waypoint .InternalType . Regular
182203 ),
183204 4 ,
184205 1 ,
185206 ),
186207 arrayOf(
187208 " Next index: 1 for 3 relevant waypoints (2 is EV) and remaining waypoint 2" ,
188209 provideWaypoints(
189- Waypoint .REGULAR ,
190- Waypoint .EV_CHARGING ,
191- Waypoint .SILENT ,
192- Waypoint .EV_CHARGING ,
193- Waypoint .REGULAR
210+ Waypoint .InternalType . Regular ,
211+ Waypoint .InternalType . EvCharging ,
212+ Waypoint .InternalType . Silent ,
213+ Waypoint .InternalType . EvCharging ,
214+ Waypoint .InternalType . Regular
194215 ),
195216 2 ,
196217 2 ,
@@ -199,23 +220,23 @@ class WaypointExTest {
199220 " Next index: null for non-valid case - 3 relevant waypoints (2 is EV) and " +
200221 " remaining waypoint 7" ,
201222 provideWaypoints(
202- Waypoint .REGULAR ,
203- Waypoint .EV_CHARGING ,
204- Waypoint .SILENT ,
205- Waypoint .EV_CHARGING ,
206- Waypoint .REGULAR
223+ Waypoint .InternalType . Regular ,
224+ Waypoint .InternalType . EvCharging ,
225+ Waypoint .InternalType . Silent ,
226+ Waypoint .InternalType . EvCharging ,
227+ Waypoint .InternalType . Regular
207228 ),
208229 7 ,
209230 null ,
210231 ),
211232 arrayOf(
212233 " Next index: 0 for 3 relevant waypoints (2 is EV) and remaining waypoint 5" ,
213234 provideWaypoints(
214- Waypoint .REGULAR ,
215- Waypoint .EV_CHARGING ,
216- Waypoint .SILENT ,
217- Waypoint .EV_CHARGING ,
218- Waypoint .REGULAR
235+ Waypoint .InternalType . Regular ,
236+ Waypoint .InternalType . EvCharging ,
237+ Waypoint .InternalType . Silent ,
238+ Waypoint .InternalType . EvCharging ,
239+ Waypoint .InternalType . Regular
219240 ),
220241 5 ,
221242 0 ,
@@ -234,7 +255,7 @@ class WaypointExTest {
234255 }
235256}
236257
237- private fun provideWaypoints (@Waypoint. Type vararg waypointType : Int ): List <Waypoint > =
258+ private fun provideWaypoints (vararg waypointType : Waypoint . InternalType ): List <Waypoint > =
238259 waypointType.map { mapToType ->
239- mockk { every { type } returns mapToType }
260+ mockk { every { internalType } returns mapToType }
240261 }
0 commit comments