@Test void convert() throws Exception { final ServiceRequestContext ctx = mock(ServiceRequestContext.class); final String queryString = "path=/foo.json" + '&' + "pa%22th=/foo1.json" + '&' + "optional_path=/foo2.json" + '&' + "path=/foo3.json" + '&' + "jsonpath=$.a" + '&' + "revision=9999"; when(ctx.query()).thenReturn(queryString); @SuppressWarnings("unchecked") final MergeQuery<JsonNode> mergeQuery = (MergeQuery<JsonNode>) converter.convertRequest( ctx, mock(AggregatedHttpRequest.class), null, null); assertThat(mergeQuery).isEqualTo( MergeQuery.ofJsonPath( ImmutableList.of(MergeSource.ofRequired("/foo.json"), MergeSource.ofOptional("/foo2.json"), MergeSource.ofRequired("/foo3.json")), ImmutableList.of("$.a"))); }
@Override public MergeQuery<?> convertRequest( ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType) throws Exception { final String queryString = ctx.query(); if (queryString != null) { final String decodedString = QueryStringDecoder.decodeComponent(queryString); final Iterable<String> queries = querySplitter.split(decodedString); final Builder<MergeSource> mergeSourceBuilder = ImmutableList.builder(); final Builder<String> jsonPathsBuilder = ImmutableList.builder(); for (String query : queries) { final int index = query.indexOf('='); if (index < 0) { continue; } final String key = query.substring(0, index); final String value = query.substring(index + 1); switch (key) { case "path": mergeSourceBuilder.add(MergeSource.ofRequired(value)); break; case "optional_path": mergeSourceBuilder.add(MergeSource.ofOptional(value)); break; case "jsonpath": jsonPathsBuilder.add(value); break; } } return MergeQuery.ofJsonPath(mergeSourceBuilder.build(), jsonPathsBuilder.build()); } return RequestConverterFunction.fallthrough(); }
MergeQueryRequestConverter implements RequestConverterFunction { @Override public MergeQuery<?> convertRequest( ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType) throws Exception { final String queryString = ctx.query(); if (queryString != null) { final String decodedString = QueryStringDecoder.decodeComponent(queryString); final Iterable<String> queries = querySplitter.split(decodedString); final Builder<MergeSource> mergeSourceBuilder = ImmutableList.builder(); final Builder<String> jsonPathsBuilder = ImmutableList.builder(); for (String query : queries) { final int index = query.indexOf('='); if (index < 0) { continue; } final String key = query.substring(0, index); final String value = query.substring(index + 1); switch (key) { case "path": mergeSourceBuilder.add(MergeSource.ofRequired(value)); break; case "optional_path": mergeSourceBuilder.add(MergeSource.ofOptional(value)); break; case "jsonpath": jsonPathsBuilder.add(value); break; } } return MergeQuery.ofJsonPath(mergeSourceBuilder.build(), jsonPathsBuilder.build()); } return RequestConverterFunction.fallthrough(); } }
MergeQueryRequestConverter implements RequestConverterFunction { @Override public MergeQuery<?> convertRequest( ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType) throws Exception { final String queryString = ctx.query(); if (queryString != null) { final String decodedString = QueryStringDecoder.decodeComponent(queryString); final Iterable<String> queries = querySplitter.split(decodedString); final Builder<MergeSource> mergeSourceBuilder = ImmutableList.builder(); final Builder<String> jsonPathsBuilder = ImmutableList.builder(); for (String query : queries) { final int index = query.indexOf('='); if (index < 0) { continue; } final String key = query.substring(0, index); final String value = query.substring(index + 1); switch (key) { case "path": mergeSourceBuilder.add(MergeSource.ofRequired(value)); break; case "optional_path": mergeSourceBuilder.add(MergeSource.ofOptional(value)); break; case "jsonpath": jsonPathsBuilder.add(value); break; } } return MergeQuery.ofJsonPath(mergeSourceBuilder.build(), jsonPathsBuilder.build()); } return RequestConverterFunction.fallthrough(); }  }
MergeQueryRequestConverter implements RequestConverterFunction { @Override public MergeQuery<?> convertRequest( ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType) throws Exception { final String queryString = ctx.query(); if (queryString != null) { final String decodedString = QueryStringDecoder.decodeComponent(queryString); final Iterable<String> queries = querySplitter.split(decodedString); final Builder<MergeSource> mergeSourceBuilder = ImmutableList.builder(); final Builder<String> jsonPathsBuilder = ImmutableList.builder(); for (String query : queries) { final int index = query.indexOf('='); if (index < 0) { continue; } final String key = query.substring(0, index); final String value = query.substring(index + 1); switch (key) { case "path": mergeSourceBuilder.add(MergeSource.ofRequired(value)); break; case "optional_path": mergeSourceBuilder.add(MergeSource.ofOptional(value)); break; case "jsonpath": jsonPathsBuilder.add(value); break; } } return MergeQuery.ofJsonPath(mergeSourceBuilder.build(), jsonPathsBuilder.build()); } return RequestConverterFunction.fallthrough(); }  @Override MergeQuery<?> convertRequest(
            ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType,
            @Nullable ParameterizedType expectedParameterizedResultType); }
MergeQueryRequestConverter implements RequestConverterFunction { @Override public MergeQuery<?> convertRequest( ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType) throws Exception { final String queryString = ctx.query(); if (queryString != null) { final String decodedString = QueryStringDecoder.decodeComponent(queryString); final Iterable<String> queries = querySplitter.split(decodedString); final Builder<MergeSource> mergeSourceBuilder = ImmutableList.builder(); final Builder<String> jsonPathsBuilder = ImmutableList.builder(); for (String query : queries) { final int index = query.indexOf('='); if (index < 0) { continue; } final String key = query.substring(0, index); final String value = query.substring(index + 1); switch (key) { case "path": mergeSourceBuilder.add(MergeSource.ofRequired(value)); break; case "optional_path": mergeSourceBuilder.add(MergeSource.ofOptional(value)); break; case "jsonpath": jsonPathsBuilder.add(value); break; } } return MergeQuery.ofJsonPath(mergeSourceBuilder.build(), jsonPathsBuilder.build()); } return RequestConverterFunction.fallthrough(); }  @Override MergeQuery<?> convertRequest(
            ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType,
            @Nullable ParameterizedType expectedParameterizedResultType);  }