public string Visit_WithValidBoolQuery_ReturnsSuccess() { var luceneNetBoolQuery = new Lucene.Net.Search.BooleanQuery(); luceneNetBoolQuery.Clauses.Add( new Lucene.Net.Search.BooleanClause( new Lucene.Net.Search.WildcardQuery( new Lucene.Net.Index.Term("*", "Lo*d?n")), Lucene.Net.Search.Occur.MUST_NOT)); var boolQuery = new LuceneBoolQuery { LuceneQuery = luceneNetBoolQuery, }; var luceneVisitor = new LuceneVisitor(); luceneVisitor.Visit(boolQuery); var es = boolQuery.ESQuery; Assert.NotNull(es); var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever()); visitor.Visit((BoolQuery)es); return(((BoolQuery)es).KustoQL); }
public void Visit_WithNullBoolQuery_ThrowsException() { var visitor = new LuceneVisitor(); Assert.That( () => visitor.Visit((LuceneBoolQuery)null), Throws.TypeOf <ArgumentNullException>()); }
public void Visit_WithInvalidBoolQuery_ThrowsException() { var boolQuery = new LuceneBoolQuery { LuceneQuery = null, }; var visitor = new LuceneVisitor(); Assert.That( () => visitor.Visit(boolQuery), Throws.TypeOf <IllegalClauseException>()); }
public string Visit_WithValidWildcardQuery_ReturnsValidReponse() { var prefixQuery = new LucenePrefixQuery { LuceneQuery = new Lucene.Net.Search.PrefixQuery( new Lucene.Net.Index.Term("*", "Kfar-Sa*")), }; var luceneVisitor = new LuceneVisitor(); luceneVisitor.Visit(prefixQuery); var es = prefixQuery.ESQuery; Assert.NotNull(es); var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever()); visitor.Visit((QueryStringClause)es); return(((QueryStringClause)es).KustoQL); }
public string Visit_WithValidEscapedWildcardQuery_ReturnsValidResponse() { var wildcardQuery = new LuceneWildcardQuery { LuceneQuery = new Lucene.Net.Search.WildcardQuery( new Lucene.Net.Index.Term("*", "L\\o*d?n")), }; var luceneVisitor = new LuceneVisitor(); luceneVisitor.Visit(wildcardQuery); var es = wildcardQuery.ESQuery; Assert.NotNull(es); var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever()); visitor.Visit((QueryStringClause)es); return(((QueryStringClause)es).KustoQL); }
public string Visit_WithValidWildcardTermQuery_ReturnsValidResponse() { var termQuery = new LuceneTermQuery { LuceneQuery = new Lucene.Net.Search.TermQuery( new Lucene.Net.Index.Term("*", "Kfar-Saba")), }; var luceneVisitor = new LuceneVisitor(); luceneVisitor.Visit(termQuery); var es = termQuery.ESQuery; Assert.NotNull(es); var visitor = VisitorTestsUtils.CreateAndVisitRootVisitor(); visitor.Visit((QueryStringClause)es); return(((QueryStringClause)es).KustoQL); }