public PageListResponse<IndexSetFieldType> getIndexSetFieldTypesListPage(
            final String indexSetId,
            final String fieldNameQuery,
            final List<String> filters,
            final int page,
            final int perPage,
            final String sort,
            final Sorting.Direction order) {

        final List<IndexSetFieldType> filteredFields = getFilteredList(indexSetId, fieldNameQuery, filters, sort, order);
        final int total = filteredFields.size();

        final List<IndexSetFieldType> retrievedPage = filteredFields.stream()
                .skip((long) Math.max(0, page - 1) * perPage)
                .limit(perPage)
                .toList();

        return PageListResponse.create("",
                PaginatedList.PaginationInfo.create(
                        total,
                        retrievedPage.size(),
                        page,
                        perPage),
                total,
                sort,
                order.toString().toLowerCase(Locale.ROOT),
                retrievedPage,
                IndexSetFieldType.ATTRIBUTES,
                IndexSetFieldType.ENTITY_DEFAULTS);

    }
@Test
    void testFilteringAndQuerying() {
        IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
        doReturn(Optional.of(indexSetConfig)).when(indexSetService).get("I_am_fine!");
        final CustomFieldMappings customFieldMappings = new CustomFieldMappings(
                List.of(new CustomFieldMapping("field_custom", "long")) //expected to be filtered out by "is_custom:false" filter
        );
        doReturn(customFieldMappings).when(indexSetConfig).customFieldMappings();
        MongoIndexSet indexSet = mock(MongoIndexSet.class);
        doReturn("graylog_0").when(indexSet).getActiveWriteIndex();
        doReturn(indexSet).when(indexSetFactory).create(indexSetConfig);

        ImmutableSet<FieldTypeDTO> deflectorFields = ImmutableSet.of(
                FieldTypeDTO.create("field_1", "long"), //expected in results
                FieldTypeDTO.create("field_2", "long"), //expected in results
                FieldTypeDTO.create("field_3", "ip"), //expected to be filtered out by "type:long" filter
                FieldTypeDTO.create("aaaa", "long"), //expected to be filtered out by "field" fieldNameQuery
                FieldTypeDTO.create("bbb", "long"), //expected to be filtered out by "field" fieldNameQuery
                FieldTypeDTO.create("ccc", "ip") //expected to be filtered out by "field" fieldNameQuery
        );
        IndexFieldTypesDTO deflectorDTO = IndexFieldTypesDTO.create("nvmd", "graylog_0", deflectorFields);
        doReturn(deflectorDTO)
                .when(indexFieldTypesService)
                .findOneByIndexName("graylog_0");

        PageListResponse<IndexSetFieldType> response = toTest.getIndexSetFieldTypesListPage("I_am_fine!", "field", List.of("type:long", "origin:INDEX"), 0, 50, "field_name", Sorting.Direction.ASC);
        assertThat(response.elements())
                .containsExactly(
                        new IndexSetFieldType("field_1", "long", INDEX, false),
                        new IndexSetFieldType("field_2", "long", INDEX, false)
                );

    }