我尝试从文件中创建响应来测试elasticsearch服务
def "FounderHint"() {
setup:
URL url = getClass().getClassLoader().getResource("elastic_response/elastic-founders-hint-response.json")
SearchResponse response = new SearchResponse().readFrom(url.openStream()) // this is a 40 line error
when: "we ask for hint"
elasticClient.search(any()) >> response
metrics.measureHintSearchTime(_) >> response
then: "we get list of ObjectHint"
List<ObjectHint> result = advancedSearchFilter.founderHint("але").collect(Collectors.toList())
result[0].inn == "323500905646"
result[0].name == "Алешина Екатерина Леонидовна"
但我犯了个错误-
No signature of method: org.elasticsearch.action.search.SearchResponse.readFrom() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@19f135ca]
Possible solutions: readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput)
groovy.lang.MissingMethodException: No signature of method: org.elasticsearch.action.search.SearchResponse.readFrom() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@19f135ca]
Possible solutions: readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput)
at ru.esphere.informator.refbook.retriever.hint.SearchExternalHintServiceTest.test external hint method for receive correct result(SearchExternalHintServiceTest.groovy:40)
searchresponse是一个类elasticsearch,它没有setter,是否有其他方法来创建响应或者我在哪里犯了错误?
1条答案
按热度按时间06odsfpq1#
第一行的bufferedinputstream在传递给readfrom之前被转换为streaminput