@Override
  public String getManagedUsersSqlFilter(boolean filterByManaged) {
    return findManagedInstanceService()
      .map(managedInstanceService -> managedInstanceService.getManagedUsersSqlFilter(filterByManaged))
      .orElseThrow(() -> NOT_MANAGED_INSTANCE_EXCEPTION);
  }
@Test
  public void getManagedUsersSqlFilter_delegatesToRightService_andPropagateAnswer() {
    AlwaysManagedInstanceService alwaysManagedInstanceService = new AlwaysManagedInstanceService();
    DelegatingManagedServices managedInstanceService = new DelegatingManagedServices(Set.of(new NeverManagedInstanceService(), alwaysManagedInstanceService));

    assertThat(managedInstanceService.getManagedUsersSqlFilter(true)).isNotNull().isEqualTo(alwaysManagedInstanceService.getManagedUsersSqlFilter(
      true));
  }