Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Sep 30, 2024
1 parent a7f036d commit 5e99b6f
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,22 @@ public void testRegisterAsDeprecatedHandler() {
String path = "/_" + randomAlphaOfLengthBetween(1, 6);
RestHandler handler = (request, channel, client) -> {};
String deprecationMessage = randomAlphaOfLengthBetween(1, 10);
RestApiVersion deprecatedInVersion = RestApiVersion.current();

Route route = Route.builder(method, path).deprecatedForRemoval(deprecationMessage, deprecatedInVersion).build();
List<RestApiVersion> replacedInVersions = List.of(RestApiVersion.current(), RestApiVersion.minimumSupported());
for (RestApiVersion replacedInVersion : replacedInVersions) {
Level level = replacedInVersion == RestApiVersion.current() ? Level.WARN : DeprecationLogger.CRITICAL;
clearInvocations(controller);
Route route = Route.builder(method, path).deprecatedForRemoval(deprecationMessage, replacedInVersion).build();

// don't want to test everything -- just that it actually wraps the handler
doCallRealMethod().when(controller).registerHandler(route, handler);
doCallRealMethod().when(controller)
.registerAsDeprecatedHandler(method, path, deprecatedInVersion, handler, deprecationMessage, DeprecationLogger.CRITICAL);
// don't want to test everything -- just that it actually wraps the handler
doCallRealMethod().when(controller).registerHandler(route, handler);
doCallRealMethod().when(controller)
.registerAsDeprecatedHandler(method, path, replacedInVersion, handler, deprecationMessage, level);

controller.registerHandler(route, handler);
controller.registerHandler(route, handler);

verify(controller).registerHandler(eq(method), eq(path), eq(deprecatedInVersion), any(DeprecationRestHandler.class));
verify(controller).registerHandler(eq(method), eq(path), eq(replacedInVersion), any(DeprecationRestHandler.class));
}
}

public void testRegisterAsReplacedHandler() {
Expand Down

0 comments on commit 5e99b6f

Please sign in to comment.