@Override
  public String getManagedUsersSqlFilter(boolean filterByManaged) {
    return findManagedInstanceService()
      .map(managedInstanceService -> managedInstanceService.getManagedUsersSqlFilter(filterByManaged))
      .orElseThrow(() -> NOT_MANAGED_INSTANCE_EXCEPTION);
  }
@Test
  public void getManagedUsersSqlFilter_whenNoDelegates_throws() {
    Set<ManagedInstanceService> managedInstanceServices = emptySet();
    DelegatingManagedServices delegatingManagedServices = new DelegatingManagedServices(managedInstanceServices);
    assertThatIllegalStateException()
      .isThrownBy(() -> delegatingManagedServices.getManagedUsersSqlFilter(true))
      .withMessage("This instance is not managed.");
  }