Skip to content

Commit

Permalink
Remove our own API client
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Aug 10, 2023
1 parent 6071055 commit 3952618
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 174 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@
<dependency>
<groupId>org.opentripplanner</groupId>
<artifactId>otp-client</artifactId>
<version>0.0.5</version>
<version>0.0.7</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
22 changes: 12 additions & 10 deletions src/test/java/org/opentripplanner/smoketest/SeattleSmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.client.model.RequestMode;
import org.opentripplanner.smoketest.util.GraphQLClient;
import org.opentripplanner.client.model.Route;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

@Tag("smoke-test")
Expand Down Expand Up @@ -50,14 +49,17 @@ public void flexAndTransit() {

@Test
public void monorailRoute() {
var modes = GraphQLClient
.routes()
.stream()
.map(GraphQLClient.Route::mode)
.map(Objects::toString)
.collect(Collectors.toSet());

assertEquals(Set.of("MONORAIL", "TRAM", "FERRY", "BUS"), modes);
try {
Set<Object> modes = SmokeTest.API_CLIENT
.routes()
.stream()
.map(Route::mode)
.map(Objects::toString)
.collect(Collectors.toSet());
assertEquals(Set.of("MONORAIL", "TRAM", "FERRY", "BUS"), modes);
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}

@Test
Expand Down
39 changes: 22 additions & 17 deletions src/test/java/org/opentripplanner/smoketest/SmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.opentripplanner.client.OtpApiClient;
import org.opentripplanner.client.model.TripPlan;
import org.opentripplanner.client.model.TripPlan.Itinerary;
import org.opentripplanner.client.model.VehicleRentalStation;
import org.opentripplanner.model.fare.ItineraryFares;
import org.opentripplanner.smoketest.util.GraphQLClient;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

/**
Expand All @@ -38,6 +38,10 @@
public class SmokeTest {

public static final ObjectMapper mapper;
public static final OtpApiClient API_CLIENT = new OtpApiClient(
ZoneId.of("America/New_York"),
"http://localhost:8080"
);

static {
var provider = new JSONObjectMapperProvider();
Expand Down Expand Up @@ -67,8 +71,12 @@ public static LocalDate nextMonday() {
}

public static void assertThatThereAreVehicleRentalStations() {
var stations = GraphQLClient.vehicleRentalStations();
assertFalse(stations.isEmpty(), "Found no vehicle rental stations.");
try {
List<VehicleRentalStation> stations = API_CLIENT.vehicleRentalStations();
assertFalse(stations.isEmpty(), "Found no vehicle rental stations.");
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}

/**
Expand All @@ -92,9 +100,7 @@ static void assertThatItineraryHasModes(List<Itinerary> itineraries, List<String

static TripPlan basicRouteTest(SmokeTestRequest req, List<String> expectedModes) {
try {
var client = new OtpApiClient(ZoneId.of("America/New_York"), "localhost:8080");

TripPlan plan = client.plan(
TripPlan plan = API_CLIENT.plan(
req.from(),
req.to(),
SmokeTest.nextMonday().atTime(LocalTime.of(12, 0)),
Expand All @@ -112,18 +118,17 @@ static TripPlan basicRouteTest(SmokeTestRequest req, List<String> expectedModes)
}

static void assertThereArePatternsWithVehiclePositions() {
GraphQLClient.VehiclePositionResponse positions = GraphQLClient.patternWithVehiclePositionsQuery();

var vehiclePositions = positions
.patterns()
.stream()
.flatMap(p -> p.vehiclePositions().stream())
.toList();
try {
var patterns = API_CLIENT.patterns();
var vehiclePositions = patterns.stream().flatMap(p -> p.vehiclePositions().stream()).toList();

assertFalse(
vehiclePositions.isEmpty(),
"Found no patterns that have realtime vehicle positions."
);
assertFalse(
vehiclePositions.isEmpty(),
"Found no patterns that have realtime vehicle positions."
);
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}

/**
Expand Down
146 changes: 0 additions & 146 deletions src/test/java/org/opentripplanner/smoketest/util/GraphQLClient.java

This file was deleted.

0 comments on commit 3952618

Please sign in to comment.