@POST
    @ApiOperation(value = "Retrieve the field list of a given set of streams")
    @NoAuditEvent("This is not changing any data")
    public Set<MappedFieldTypeDTO> byStreams(@ApiParam(name = "JSON body", required = true)
                                             @Valid @NotNull FieldTypesForStreamsRequest request,
                                             @Context SearchUser searchUser) {
        final ImmutableSet<String> streams = searchUser.streams().readableOrAllIfEmpty(request.streams());
        return mappedFieldTypesService.fieldTypesByStreamIds(streams, request.timerange().orElse(RelativeRange.allTime()));
    }
@Test
    public void passesRequestedTimeRangeToMappedFieldTypesService() throws Exception {
        final SearchUser searchUser = TestSearchUser.builder()
                .allowStream("2323")
                .allowStream("4242")
                .build();

        final FieldTypesForStreamsRequest request = FieldTypesForStreamsRequest.Builder.builder()
                .streams(ImmutableSet.of("2323", "4242"))
                .timerange(RelativeRange.create(250))
                .build();

        final MappedFieldTypesService mappedFieldTypesService = (streamIds, timeRange) -> {
            if (timeRange.equals(RelativeRange.create(250))) {
                final FieldTypes.Type fieldType = FieldTypes.Type.createType("long", ImmutableSet.of("numeric", "enumerable"));
                final MappedFieldTypeDTO field = MappedFieldTypeDTO.create("foobar", fieldType);
                return Collections.singleton(field);
            } else {
                throw new AssertionError("Expected relative range of 250");
            }
        };

        final FieldTypesResource resource = new FieldTypesResource(mappedFieldTypesService, mock(IndexFieldTypePollerPeriodical.class));
        final Set<MappedFieldTypeDTO> result = resource.byStreams(request, searchUser);

        assertThat(result)
                .hasSize(1)
                .hasOnlyOneElementSatisfying(type -> assertThat(type.name()).isEqualTo("foobar"));
    }