Skip to content

Commit 14f2d6b

Browse files
Configure formatting for sandbox code
1 parent a8ad459 commit 14f2d6b

File tree

24 files changed

+277
-212
lines changed

24 files changed

+277
-212
lines changed

application/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ void calculateFareThatIncludesNoFreeTransfers() {
226226
);
227227
calculateFare(rides, FareType.youth, Money.ZERO_USD);
228228
// We don't get any fares for the skagit transit leg below here because they don't accept ORCA (electronic)
229-
calculateFare(rides, FareType.electronicSpecial, ONE_DOLLAR.plus(ONE_DOLLAR).plus(DEFAULT_TEST_RIDE_PRICE.times(2)));
230229
calculateFare(
231230
rides,
232-
FareType.electronicRegular,
233-
DEFAULT_TEST_RIDE_PRICE.times(4)
231+
FareType.electronicSpecial,
232+
ONE_DOLLAR.plus(ONE_DOLLAR).plus(DEFAULT_TEST_RIDE_PRICE.times(2))
234233
);
234+
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(4));
235235
calculateFare(
236236
rides,
237237
FareType.electronicSenior,

application/src/ext-test/java/org/opentripplanner/ext/flex/FlexStopTimesForTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,4 @@ public static StopTime regularStop(int arrivalTime, int departureTime) {
9696
stopTime.setTrip(TRIP);
9797
return stopTime;
9898
}
99-
100-
101-
10299
}

application/src/ext-test/java/org/opentripplanner/ext/flex/trip/ScheduledDeviatedTripTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ private static List<List<StopTime>> isNotScheduledDeviatedTripCases() {
4545
areaWithContinuousStopping("10:40"),
4646
regularStop("10:50", "11:00")
4747
),
48-
List.of(
49-
regularStop("10:10"),
50-
regularStop("10:20")
51-
)
48+
List.of(regularStop("10:10"), regularStop("10:20"))
5249
);
5350
}
5451

@@ -57,6 +54,4 @@ private static List<List<StopTime>> isNotScheduledDeviatedTripCases() {
5754
void isNotScheduledDeviatedTrip(List<StopTime> stopTimes) {
5855
assertFalse(ScheduledDeviatedTrip.isScheduledDeviatedFlexTrip(stopTimes));
5956
}
60-
61-
62-
}
57+
}

application/src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledTripTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,20 @@ class IsUnscheduledTrip {
4848

4949
private static final StopTime SCHEDULED_STOP = FlexStopTimesForTest.regularStop("10:00");
5050
private static final StopTime UNSCHEDULED_STOP = FlexStopTimesForTest.area("10:10", "10:20");
51-
private static final StopTime CONTINUOUS_PICKUP_STOP = FlexStopTimesForTest.regularStopWithContinuousPickup("10:30");
52-
private static final StopTime CONTINUOUS_DROP_OFF_STOP = FlexStopTimesForTest.regularStopWithContinuousDropOff("10:40");
51+
private static final StopTime CONTINUOUS_PICKUP_STOP = FlexStopTimesForTest.regularStopWithContinuousPickup(
52+
"10:30"
53+
);
54+
private static final StopTime CONTINUOUS_DROP_OFF_STOP = FlexStopTimesForTest.regularStopWithContinuousDropOff(
55+
"10:40"
56+
);
5357

5458
// disallowed by the GTFS spec
55-
private static final StopTime FLEX_AND_CONTINUOUS_PICKUP_STOP = FlexStopTimesForTest.areaWithContinuousPickup("10:50");
56-
private static final StopTime FLEX_AND_CONTINUOUS_DROP_OFF_STOP = FlexStopTimesForTest.areaWithContinuousDropOff("11:00");
59+
private static final StopTime FLEX_AND_CONTINUOUS_PICKUP_STOP = FlexStopTimesForTest.areaWithContinuousPickup(
60+
"10:50"
61+
);
62+
private static final StopTime FLEX_AND_CONTINUOUS_DROP_OFF_STOP = FlexStopTimesForTest.areaWithContinuousDropOff(
63+
"11:00"
64+
);
5765

5866
static List<List<StopTime>> notUnscheduled() {
5967
return List.of(

application/src/ext-test/java/org/opentripplanner/ext/restapi/mapping/EnumMapperTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,4 @@ private <D extends Enum<?>, A extends Enum<?>> void verifyExplicitMatch(
4646
}
4747
assertTrue(rest.isEmpty());
4848
}
49-
5049
}

application/src/ext-test/java/org/opentripplanner/ext/siri/updater/azure/AbstractAzureSiriUpdaterTest.java

Lines changed: 101 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.opentripplanner.ext.siri.updater.azure;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
45
import static org.junit.jupiter.api.Assertions.assertThrows;
56
import static org.junit.jupiter.api.Assertions.assertTrue;
6-
import static org.junit.jupiter.api.Assertions.assertFalse;
77
import static org.mockito.Mockito.*;
88

99
import com.azure.core.util.ExpandableStringEnum;
@@ -56,21 +56,22 @@ public void setUp() throws Exception {
5656
when(mockConfig.isFuzzyTripMatching()).thenReturn(true);
5757

5858
// Create a spy on AbstractAzureSiriUpdater with the mock configuration
59-
updater = spy(new AbstractAzureSiriUpdater(mockConfig) {
60-
@Override
61-
protected void messageConsumer(ServiceBusReceivedMessageContext messageContext) {
62-
}
63-
64-
@Override
65-
protected void errorConsumer(ServiceBusErrorContext errorContext) {
66-
}
67-
68-
@Override
69-
protected void initializeData(String url,
70-
Consumer<ServiceBusReceivedMessageContext> consumer
71-
) throws URISyntaxException {
72-
}
73-
});
59+
updater =
60+
spy(
61+
new AbstractAzureSiriUpdater(mockConfig) {
62+
@Override
63+
protected void messageConsumer(ServiceBusReceivedMessageContext messageContext) {}
64+
65+
@Override
66+
protected void errorConsumer(ServiceBusErrorContext errorContext) {}
67+
68+
@Override
69+
protected void initializeData(
70+
String url,
71+
Consumer<ServiceBusReceivedMessageContext> consumer
72+
) throws URISyntaxException {}
73+
}
74+
);
7475

7576
task = mock(AbstractAzureSiriUpdater.CheckedRunnable.class);
7677
}
@@ -81,8 +82,8 @@ protected void initializeData(String url,
8182
*/
8283
@Test
8384
void testExecuteWithRetry_FullBackoffSequence() throws Throwable {
84-
final int totalRunCalls = 10; // 9 failures + 1 success
85-
final int totalSleepCalls = 9; // 9 retries
85+
final int totalRunCalls = 10; // 9 failures + 1 success
86+
final int totalSleepCalls = 9; // 9 retries
8687

8788
doNothing().when(updater).sleep(anyInt());
8889

@@ -97,7 +98,8 @@ void testExecuteWithRetry_FullBackoffSequence() throws Throwable {
9798
.doThrow(createServiceBusException(ServiceBusFailureReason.SERVICE_BUSY))
9899
.doThrow(createServiceBusException(ServiceBusFailureReason.SERVICE_BUSY))
99100
.doNothing() // Succeed on the 10th attempt
100-
.when(task).run();
101+
.when(task)
102+
.run();
101103

102104
updater.executeWithRetry(task, "Test Task");
103105

@@ -126,14 +128,20 @@ void testExecuteWithRetry_FullBackoffSequence() throws Throwable {
126128
public void testExecuteWithRetry_NonRetryableException() throws Throwable {
127129
doNothing().when(updater).sleep(anyInt());
128130

129-
ServiceBusException serviceBusException = createServiceBusException(ServiceBusFailureReason.MESSAGE_SIZE_EXCEEDED);
131+
ServiceBusException serviceBusException = createServiceBusException(
132+
ServiceBusFailureReason.MESSAGE_SIZE_EXCEEDED
133+
);
130134

131135
doThrow(serviceBusException).when(task).run();
132136

133137
try {
134138
updater.executeWithRetry(task, "Test Task");
135139
} catch (ServiceBusException e) {
136-
assertEquals(ServiceBusFailureReason.MESSAGE_SIZE_EXCEEDED, e.getReason(), "Exception should have reason MESSAGE_SIZE_EXCEEDED");
140+
assertEquals(
141+
ServiceBusFailureReason.MESSAGE_SIZE_EXCEEDED,
142+
e.getReason(),
143+
"Exception should have reason MESSAGE_SIZE_EXCEEDED"
144+
);
137145
}
138146

139147
verify(updater, never()).sleep(anyInt());
@@ -153,12 +161,15 @@ public void testExecuteWithRetry_MultipleRetriesThenSuccess() throws Throwable {
153161
.doThrow(createServiceBusException(ServiceBusFailureReason.SERVICE_BUSY))
154162
.doThrow(createServiceBusException(ServiceBusFailureReason.SERVICE_BUSY))
155163
.doNothing()
156-
.when(task).run();
164+
.when(task)
165+
.run();
157166

158167
doAnswer(invocation -> {
159-
latch.countDown();
160-
return null;
161-
}).when(updater).sleep(anyInt());
168+
latch.countDown();
169+
return null;
170+
})
171+
.when(updater)
172+
.sleep(anyInt());
162173

163174
updater.executeWithRetry(task, "Test Task");
164175

@@ -169,11 +180,14 @@ public void testExecuteWithRetry_MultipleRetriesThenSuccess() throws Throwable {
169180
verify(updater, times(retriesBeforeSuccess)).sleep(sleepCaptor.capture());
170181

171182
var sleepDurations = sleepCaptor.getAllValues();
172-
long[] expectedBackoffSequence = {1000, 2000, 4000};
183+
long[] expectedBackoffSequence = { 1000, 2000, 4000 };
173184

174185
for (int i = 0; i < expectedBackoffSequence.length; i++) {
175-
assertEquals(expectedBackoffSequence[i], Long.valueOf(sleepDurations.get(i)),
176-
"Backoff duration mismatch at retry " + (i + 1));
186+
assertEquals(
187+
expectedBackoffSequence[i],
188+
Long.valueOf(sleepDurations.get(i)),
189+
"Backoff duration mismatch at retry " + (i + 1)
190+
);
177191
}
178192

179193
verify(task, times(retriesBeforeSuccess + 1)).run();
@@ -205,14 +219,17 @@ public void testExecuteWithRetry_OneRetryThenSuccess() throws Throwable {
205219

206220
doThrow(createServiceBusException(ServiceBusFailureReason.SERVICE_BUSY))
207221
.doNothing()
208-
.when(task).run();
222+
.when(task)
223+
.run();
209224

210225
doAnswer(invocation -> {
211-
if (invocation.getArgument(0).equals(1000)) {
212-
latch.countDown();
213-
}
214-
return null;
215-
}).when(updater).sleep(anyInt());
226+
if (invocation.getArgument(0).equals(1000)) {
227+
latch.countDown();
228+
}
229+
return null;
230+
})
231+
.when(updater)
232+
.sleep(anyInt());
216233

217234
updater.executeWithRetry(task, "Test Task");
218235

@@ -232,10 +249,17 @@ public void testExecuteWithRetry_OneRetryThenSuccess() throws Throwable {
232249
@ParameterizedTest(name = "shouldRetry with reason {0} should return {1}")
233250
@MethodSource("provideServiceBusFailureReasons")
234251
@DisplayName("Test shouldRetry for all ServiceBusFailureReason values")
235-
void testShouldRetry_ServiceBusFailureReasons(ServiceBusFailureReason reason, boolean expectedRetry) throws Exception {
252+
void testShouldRetry_ServiceBusFailureReasons(
253+
ServiceBusFailureReason reason,
254+
boolean expectedRetry
255+
) throws Exception {
236256
ServiceBusException serviceBusException = createServiceBusException(reason);
237257
boolean result = updater.shouldRetry(serviceBusException);
238-
assertEquals(expectedRetry, result, "shouldRetry should return " + expectedRetry + " for reason " + reason);
258+
assertEquals(
259+
expectedRetry,
260+
result,
261+
"shouldRetry should return " + expectedRetry + " for reason " + reason
262+
);
239263
}
240264

241265
/**
@@ -258,7 +282,11 @@ public void testShouldRetry_NonServiceBusException() {
258282
public void testShouldRetry_CoversAllReasons() {
259283
long enumCount = getExpandableStringEnumValues(ServiceBusFailureReason.class).size();
260284
long testCaseCount = provideServiceBusFailureReasons().count();
261-
assertEquals(enumCount, testCaseCount, "All ServiceBusFailureReason values should be covered by tests.");
285+
assertEquals(
286+
enumCount,
287+
testCaseCount,
288+
"All ServiceBusFailureReason values should be covered by tests."
289+
);
262290
}
263291

264292
@Test
@@ -268,15 +296,24 @@ void testExecuteWithRetry_InterruptedException() throws Throwable {
268296

269297
doThrow(createServiceBusException(ServiceBusFailureReason.SERVICE_BUSY))
270298
.doThrow(new InterruptedException("Sleep interrupted"))
271-
.when(task).run();
299+
.when(task)
300+
.run();
272301

273302
doNothing().when(updater).sleep(1000);
274303

275-
InterruptedException thrownException = assertThrows(InterruptedException.class, () -> {
276-
updater.executeWithRetry(task, "Test Task");
277-
}, "Expected executeWithRetry to throw InterruptedException");
304+
InterruptedException thrownException = assertThrows(
305+
InterruptedException.class,
306+
() -> {
307+
updater.executeWithRetry(task, "Test Task");
308+
},
309+
"Expected executeWithRetry to throw InterruptedException"
310+
);
278311

279-
assertEquals("Sleep interrupted", thrownException.getMessage(), "Exception message should match");
312+
assertEquals(
313+
"Sleep interrupted",
314+
thrownException.getMessage(),
315+
"Exception message should match"
316+
);
280317
verify(updater, times(expectedSleepCalls)).sleep(1000);
281318
verify(task, times(expectedRunCalls)).run();
282319
assertTrue(Thread.currentThread().isInterrupted(), "Thread should be interrupted");
@@ -291,7 +328,8 @@ void testExecuteWithRetry_OtpHttpClientException() throws Throwable {
291328
.doThrow(new OtpHttpClientException("could not get historical data"))
292329
.doThrow(new OtpHttpClientException("could not get historical data"))
293330
.doNothing()
294-
.when(task).run();
331+
.when(task)
332+
.run();
295333

296334
doNothing().when(updater).sleep(anyInt());
297335

@@ -304,8 +342,11 @@ void testExecuteWithRetry_OtpHttpClientException() throws Throwable {
304342
List<Integer> expectedBackoffSequence = Arrays.asList(1000, 2000, 4000);
305343

306344
for (int i = 0; i < retryAttempts; i++) {
307-
assertEquals(expectedBackoffSequence.get(i), sleepDurations.get(i),
308-
"Backoff duration mismatch at retry " + (i + 1));
345+
assertEquals(
346+
expectedBackoffSequence.get(i),
347+
sleepDurations.get(i),
348+
"Backoff duration mismatch at retry " + (i + 1)
349+
);
309350
}
310351

311352
verify(task, times(retryAttempts + 1)).run();
@@ -318,9 +359,13 @@ void testExecuteWithRetry_UnexpectedException() throws Throwable {
318359
Exception unexpectedException = new NullPointerException("Unexpected null value");
319360
doThrow(unexpectedException).when(task).run();
320361

321-
Exception thrown = assertThrows(NullPointerException.class, () -> {
322-
updater.executeWithRetry(task, "Test Task");
323-
}, "Expected executeWithRetry to throw NullPointerException");
362+
Exception thrown = assertThrows(
363+
NullPointerException.class,
364+
() -> {
365+
updater.executeWithRetry(task, "Test Task");
366+
},
367+
"Expected executeWithRetry to throw NullPointerException"
368+
);
324369

325370
assertEquals("Unexpected null value", thrown.getMessage(), "Exception message should match");
326371
verify(updater, never()).sleep(anyInt());
@@ -344,7 +389,6 @@ private static Stream<Arguments> provideServiceBusFailureReasons() {
344389
Arguments.of(ServiceBusFailureReason.QUOTA_EXCEEDED, true),
345390
Arguments.of(ServiceBusFailureReason.GENERAL_ERROR, true),
346391
Arguments.of(ServiceBusFailureReason.UNAUTHORIZED, true),
347-
348392
// Non-Retryable Errors
349393
Arguments.of(ServiceBusFailureReason.MESSAGING_ENTITY_NOT_FOUND, false),
350394
Arguments.of(ServiceBusFailureReason.MESSAGING_ENTITY_DISABLED, false),
@@ -361,7 +405,10 @@ private static Stream<Arguments> provideServiceBusFailureReasons() {
361405
* @return A ServiceBusException instance with the specified reason.
362406
*/
363407
private ServiceBusException createServiceBusException(ServiceBusFailureReason reason) {
364-
ServiceBusException exception = new ServiceBusException(new Throwable(), ServiceBusErrorSource.RECEIVE);
408+
ServiceBusException exception = new ServiceBusException(
409+
new Throwable(),
410+
ServiceBusErrorSource.RECEIVE
411+
);
365412
try {
366413
Field reasonField = ServiceBusException.class.getDeclaredField("reason");
367414
reasonField.setAccessible(true);
@@ -379,7 +426,9 @@ private ServiceBusException createServiceBusException(ServiceBusFailureReason re
379426
* @param <T> The type parameter extending ExpandableStringEnum.
380427
* @return A Collection of all registered instances.
381428
*/
382-
private static <T extends ExpandableStringEnum<T>> Collection<T> getExpandableStringEnumValues(Class<T> clazz) {
429+
private static <T extends ExpandableStringEnum<T>> Collection<T> getExpandableStringEnumValues(
430+
Class<T> clazz
431+
) {
383432
try {
384433
Method valuesMethod = ExpandableStringEnum.class.getDeclaredMethod("values", Class.class);
385434
valuesMethod.setAccessible(true);
@@ -390,4 +439,4 @@ private static <T extends ExpandableStringEnum<T>> Collection<T> getExpandableSt
390439
throw new RuntimeException("Failed to retrieve values from ExpandableStringEnum.", e);
391440
}
392441
}
393-
}
442+
}

application/src/ext-test/java/org/opentripplanner/ext/smoovebikerental/SmooveBikeRentalDataSourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import java.util.List;
88
import org.junit.jupiter.api.Test;
99
import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace;
10-
import org.opentripplanner.updater.vehicle_rental.datasources.params.RentalPickupType;
1110
import org.opentripplanner.updater.spi.HttpHeaders;
11+
import org.opentripplanner.updater.vehicle_rental.datasources.params.RentalPickupType;
1212

1313
class SmooveBikeRentalDataSourceTest {
1414

application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ public void vehicleParkingGeometryTest() {
110110
var nodeAdapter = newNodeAdapterForTest(config);
111111
var tiles = VectorTileConfig.mapVectorTilesParameters(nodeAdapter, "vectorTiles");
112112
assertEquals(1, tiles.layers().size());
113-
var builder = new VehicleParkingsLayerBuilder(new DefaultVehicleParkingService(repo), tiles.layers().getFirst(), Locale.US);
113+
var builder = new VehicleParkingsLayerBuilder(
114+
new DefaultVehicleParkingService(repo),
115+
tiles.layers().getFirst(),
116+
Locale.US
117+
);
114118

115119
List<Geometry> geometries = builder.getGeometries(new Envelope(0.99, 1.01, 1.99, 2.01));
116120

0 commit comments

Comments
 (0)