DegradedRouterQueryBuilder extends AbstractRouterQueryBuilder<DegradedCondition, DegradedRouterQueryBuilder> { @VisibleForTesting void condition(ConditionDefinition def, DegradedConditionType type, String bucket, Double percentile, int value, QueryBuilder query) { condition(new DegradedCondition(def, type, bucket, percentile, value, query)); } DegradedRouterQueryBuilder();  DegradedRouterQueryBuilder(StreamInput in, SystemLoad systemLoad); @Override String getWriteableName(); static DegradedRouterQueryBuilder fromXContent(
            XContentParser parser, SystemLoad systemLoad
    ); @Override QueryBuilder doRewrite(QueryRewriteContext context); static final ParseField NAME; }
@Test public void testParseExample() throws IOException { String json = "{\"degraded_router\": {\n" + " \"conditions\" : [\n" + " {\n" + " \"lt\": 70,\n" + " \"type\": \"cpu\"," + " \"query\": {\n" + " \"match_phrase\": {\n" + " \"text\": \"input query\"\n" + " }\n" + " }\n" + " }\n" + " ],\n" + " \"fallback\": {\n" + " \"match_none\": {}\n" + " }\n" + "}}"; QueryBuilder builder = QueryBuilderTestUtils.FULLY_FEATURED.parseQuery(json); assertThat(builder, instanceOf(DegradedRouterQueryBuilder.class)); DegradedRouterQueryBuilder qb = (DegradedRouterQueryBuilder) builder; assertNotNull(qb.systemLoad()); assertEquals(1, qb.conditionStream().count()); DegradedRouterQueryBuilder.DegradedCondition cond = qb.conditionStream().findFirst().get(); assertEquals(DegradedConditionType.cpu, cond.type()); assertThat(cond.query(), instanceOf(MatchPhraseQueryBuilder.class)); assertEquals(ConditionDefinition.lt, cond.definition()); assertEquals(70, cond.value()); assertThat(qb.fallback(), instanceOf(MatchNoneQueryBuilder.class)); DegradedRouterQueryBuilder expected = new DegradedRouterQueryBuilder(); expected.condition(ConditionDefinition.lt, DegradedConditionType.cpu, null, null, 70, new MatchPhraseQueryBuilder("text", "input query")); expected.fallback(new MatchNoneQueryBuilder()); assertEquals(expected, qb); }