Skip to content

Commit

Permalink
test: Expanded testing of JsonOperationsHttpService
Browse files Browse the repository at this point in the history
  • Loading branch information
rhwood committed Mar 22, 2020
1 parent 27454c0 commit 2826099
Show file tree
Hide file tree
Showing 2 changed files with 402 additions and 254 deletions.
20 changes: 10 additions & 10 deletions java/src/jmri/server/json/operations/JsonOperationsHttpService.java
Expand Up @@ -300,12 +300,8 @@ public void doDelete(String type, String name, JsonNode data, JsonRequest reques
locationManager().getList().stream().filter(l -> l.acceptsTypeName(name)).forEach(locations::add);
if ((!cars.isEmpty() || !locations.isEmpty()) && !acceptForceDeleteToken(type, name, token)) {
ArrayNode conflicts = mapper.createArrayNode();
for (Car car : cars) {
conflicts.add(message(CAR, utilities.getCar(car, locale), 0));
}
for (Location location : locations) {
conflicts.add(message(LOCATION, utilities.getLocation(location, locale), 0));
}
cars.forEach(car -> conflicts.add(message(CAR, utilities.getCar(car, locale), 0)));
locations.forEach(location -> conflicts.add(message(LOCATION, utilities.getLocation(location, locale), 0)));
throwDeleteConflictException(type, name, conflicts, request);
}
InstanceManager.getDefault(CarTypes.class).deleteName(name);
Expand Down Expand Up @@ -662,7 +658,8 @@ public void deleteTrack(@Nonnull String name, @Nonnull JsonNode data, @Nonnull L
track.getLocation().deleteTrack(track);
}

protected @Nonnull Car getCarByName(@Nonnull String name, @Nonnull Locale locale, int id) throws JsonException {
@Nonnull
protected Car getCarByName(@Nonnull String name, @Nonnull Locale locale, int id) throws JsonException {
Car car = carManager().getById(name);
if (car == null) {
throw new JsonException(HttpServletResponse.SC_NOT_FOUND,
Expand All @@ -671,7 +668,8 @@ public void deleteTrack(@Nonnull String name, @Nonnull JsonNode data, @Nonnull L
return car;
}

protected @Nonnull Engine getEngineByName(@Nonnull String name, @Nonnull Locale locale, int id)
@Nonnull
protected Engine getEngineByName(@Nonnull String name, @Nonnull Locale locale, int id)
throws JsonException {
Engine engine = engineManager().getById(name);
if (engine == null) {
Expand All @@ -681,7 +679,8 @@ public void deleteTrack(@Nonnull String name, @Nonnull JsonNode data, @Nonnull L
return engine;
}

protected @Nonnull Location getLocationByName(@Nonnull String name, @Nonnull Locale locale, int id)
@Nonnull
protected Location getLocationByName(@Nonnull String name, @Nonnull Locale locale, int id)
throws JsonException {
Location location = locationManager().getLocationById(name);
if (location == null) {
Expand All @@ -691,7 +690,8 @@ public void deleteTrack(@Nonnull String name, @Nonnull JsonNode data, @Nonnull L
return location;
}

protected @Nonnull Track getTrackByName(@Nonnull String name, @Nonnull JsonNode data, @Nonnull Locale locale,
@Nonnull
protected Track getTrackByName(@Nonnull String name, @Nonnull JsonNode data, @Nonnull Locale locale,
int id) throws JsonException {
if (data.path(LOCATION).isMissingNode()) {
throw new JsonException(HttpServletResponse.SC_BAD_REQUEST,
Expand Down

0 comments on commit 2826099

Please sign in to comment.