public Map<String, BulkOperationResponse> removeCustomMappingForFields(final List<String> fieldNames,
                                                                           final Set<String> indexSetsIds,
                                                                           final boolean rotateImmediately) {
        Map<String, BulkOperationResponse> result = new HashMap<>();
        for (String indexSetId : indexSetsIds) {
            try {
                indexSetService.get(indexSetId).ifPresentOrElse(
                        indexSetConfig -> result.put(indexSetId, removeMappings(fieldNames, indexSetConfig, rotateImmediately)),
                        () -> result.put(indexSetId, new BulkOperationResponse(List.of("Index set with following ID not present in the database: " + indexSetId)))
                );
            } catch (Exception ex) {
                LOG.error("Failed to remove custom mappings for fields " + fieldNames.toString() + " in index set : " + indexSetId, ex);
                result.put(indexSetId, new BulkOperationResponse(List.of("Exception while removing custom field mappings for index set : " + indexSetId + ": " + ex.getMessage())));
            }
        }
        return result;
    }
@Test
    void testRemovesMappingsForIndexSetEvenIfRemovalForAnotherIndexSetThrowsException() {
        doReturn(Optional.of(existingIndexSet)).when(indexSetService).get("existing_index_set");
        final IndexSetConfig brokenIndexSet = buildSampleIndexSetConfig("broken_index_set");
        lenient().when(mongoIndexSetService.save(argThat(indexSetConfig -> Objects.equals(brokenIndexSet.id(), indexSetConfig.id()))))
                .thenThrow(new RuntimeException("Broken!"));

        final Map<String, BulkOperationResponse> response = toTest.removeCustomMappingForFields(
                List.of("existing_field", "unexisting_field"),
                Set.of("existing_index_set", "broken_index_set"),
                false);

        assertThat(response).isNotNull().hasSize(2);
        assertThat(response).containsOnlyKeys("existing_index_set", "broken_index_set");

        final BulkOperationResponse existingIndexSetResponse = response.get("existing_index_set");
        assertThat(existingIndexSetResponse.successfullyPerformed()).isEqualTo(1);
        assertThat(existingIndexSetResponse.errors()).isEmpty();
        assertThat(existingIndexSetResponse.failures()).hasSize(1);

        final BulkOperationResponse brokenIndexSetResponse = response.get("broken_index_set");
        assertThat(brokenIndexSetResponse.successfullyPerformed()).isEqualTo(0);
        assertThat(brokenIndexSetResponse.errors()).hasSize(1);
        assertThat(brokenIndexSetResponse.failures()).isEmpty();

    }