public static AuthorizationDoc fromDto(IndexType indexType, IndexPermissions dto) {
    AuthorizationDoc res = new AuthorizationDoc(indexType, dto.getEntityUuid());
    if (dto.isAllowAnyone()) {
      return res.setAllowAnyone();
    }
    return res.setRestricted(dto.getGroupUuids(), dto.getUserUuids());
  }
@Test
  public void fromDto_of_allowAnyone_is_false_and_no_user_nor_group() {
    IndexPermissions underTest = new IndexPermissions(randomAlphabetic(3), randomAlphabetic(4));

    AuthorizationDoc doc = AuthorizationDoc.fromDto(IndexType.main(Index.simple("foo"), "bar"), underTest);

    boolean auth_allowAnyone = doc.getField("auth_allowAnyone");
    assertThat(auth_allowAnyone).isFalse();
    List<Integer> userIds = doc.getField("auth_userIds");
    assertThat(userIds).isEmpty();
    List<Integer> groupIds = doc.getField("auth_groupIds");
    assertThat(groupIds).isEmpty();
  }