@Override
    public CheckResult runCheck() {
        String filter = buildQueryFilter(stream.getId(), query);
        String query = field + ":\"" + value + "\"";
        Integer backlogSize = getBacklog();
        boolean backlogEnabled = false;
        int searchLimit = 1;

        if(backlogSize != null && backlogSize > 0) {
            backlogEnabled = true;
            searchLimit = backlogSize;
        }

        try {
            SearchResult result = searches.search(
                query,
                filter,
                RelativeRange.create(configuration.getAlertCheckInterval()),
                searchLimit,
                0,
                new Sorting(Message.FIELD_TIMESTAMP, Sorting.Direction.DESC)
            );

            final List<MessageSummary> summaries;
            if (backlogEnabled) {
                summaries = Lists.newArrayListWithCapacity(result.getResults().size());
                for (ResultMessage resultMessage : result.getResults()) {
                    final Message msg = resultMessage.getMessage();
                    summaries.add(new MessageSummary(resultMessage.getIndex(), msg));
                }
            } else {
                summaries = Collections.emptyList();
            }

            final long count = result.getTotalResults();

            final String resultDescription = "Stream received messages matching <" + query + "> "
                + "(Current grace time: " + grace + " minutes)";

            if (count > 0) {
                LOG.debug("Alert check <{}> found [{}] messages.", id, count);
                return new CheckResult(true, this, resultDescription, Tools.nowUTC(), summaries);
            } else {
                LOG.debug("Alert check <{}> returned no results.", id);
                return new NegativeCheckResult();
            }
        } catch (InvalidRangeParametersException e) {
            // cannot happen lol
            LOG.error("Invalid timerange.", e);
            return null;
        }
    }
@Test
    public void testCorrectUsageOfRelativeRange() throws Exception {
        final Stream stream = mock(Stream.class);
        final Searches searches = mock(Searches.class);
        final Configuration configuration = mock(Configuration.class);
        final SearchResult searchResult = mock(SearchResult.class);
        final int alertCheckInterval = 42;
        final RelativeRange relativeRange = RelativeRange.create(alertCheckInterval);

        when(stream.getId()).thenReturn("stream-id");
        when(configuration.getAlertCheckInterval()).thenReturn(alertCheckInterval);

        when(searches.search(anyString(),
            anyString(),
            eq(relativeRange),
            anyInt(),
            anyInt(),
            any(Sorting.class))).thenReturn(searchResult);

        final FieldContentValueAlertCondition alertCondition = new FieldContentValueAlertCondition(searches, configuration, stream,
            null, DateTime.now(DateTimeZone.UTC), "mockuser", ImmutableMap.<String,Object>of("field", "test", "value", "test"), "Field Content Value Test COndition");

        final AbstractAlertCondition.CheckResult result = alertCondition.runCheck();
    }