use of org.elasticsearch.action.percolate.PercolateResponse.Match in project apex-malhar by apache.
the class ElasticSearchPercolateTest method checkPercolateResponse.
/**
*/
private void checkPercolateResponse() {
ElasticSearchPercolatorOperator oper = new ElasticSearchPercolatorOperator();
oper.hostName = HOST_NAME;
oper.port = PORT;
oper.indexName = INDEX_NAME;
oper.documentType = DOCUMENT_TYPE;
oper.setup(null);
String[] messages = { "{content:'This will match only with malhar'}", "{content:'This will match only with github'}", "{content:'This will match with both github and malhar'}", "{content:'This will not match with any of them'}" };
String[][] matches = { { MALHAR_TOPIC }, { GITHUB_TOPIC }, { GITHUB_TOPIC, MALHAR_TOPIC }, {} };
CollectorTestSink<PercolateResponse> sink = new CollectorTestSink<PercolateResponse>();
oper.outputPort.setSink((CollectorTestSink) sink);
for (String message : messages) {
oper.inputPort.process(message);
}
int i = 0;
for (PercolateResponse response : sink.collectedTuples) {
List<String> matchIds = new ArrayList<String>();
for (Match match : response.getMatches()) {
matchIds.add(match.getId().toString());
}
Collections.sort(matchIds);
Assert.assertArrayEquals(matchIds.toArray(), matches[i]);
i++;
}
}
Aggregations