@Override
  public void define(Context context) {
    NewController controller = context.createController("api/sources")
      .setSince("4.2")
      .setDescription("Get details on source files. See also api/tests.");
    for (SourcesWsAction action : actions) {
      action.define(controller);
    }
    controller.done();
  }
@Test
  public void define_ws() {
    SourcesWsAction[] actions = IntStream.range(0, 1 + new Random().nextInt(10))
      .mapToObj(i -> {
        SourcesWsAction wsAction = mock(SourcesWsAction.class);
        doAnswer(invocation -> {
          WebService.NewController controller = invocation.getArgument(0);
          controller.createAction("action_" + i)
            .setHandler(wsAction);
          return null;
        }).when(wsAction).define(any(WebService.NewController.class));
        return wsAction;
      })
      .toArray(SourcesWsAction[]::new);

    SourcesWs underTest = new SourcesWs(actions);
    WebService.Context context = new WebService.Context();

    underTest.define(context);

    WebService.Controller controller = context.controller("api/sources");
    assertThat(controller).isNotNull();
    assertThat(controller.since()).isEqualTo("4.2");
    assertThat(controller.description()).isNotEmpty();
    assertThat(controller.actions()).hasSize(actions.length);
  }