@Test
@SuppressWarnings("unchecked")
public void shouldHaveCorrectNumberOfMiddlewares() {

  when(route.withMiddleware(any(Middleware.class))).thenReturn(route);
  final List<Route<AsyncHandler<Response<ByteString>>>> originalRoutes = List.of(route);
  final List<Route<AsyncHandler<Response<ByteString>>>> routes =
      Api.withCommonMiddleware(originalRoutes.stream(), requestAuthenticator, "test").collect(toList());
  verify(route, times(5)).withMiddleware(any(Middleware.class));
  assertThat(routes, is(originalRoutes));
}