metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmiklavc <...@git.apache.org>
Subject [GitHub] metron pull request #909: METRON-1429: SearchIntegrationTest refactor
Date Thu, 25 Jan 2018 02:48:17 GMT
Github user mmiklavc commented on a diff in the pull request:

    https://github.com/apache/metron/pull/909#discussion_r163737939
  
    --- Diff: metron-platform/metron-indexing/src/test/java/org/apache/metron/indexing/dao/SearchIntegrationTest.java
---
    @@ -724,6 +503,52 @@ public void sort_query_sorts_results_ascending() throws Exception
{
         }
       }
     
    +  @Test
    +  public void sort_ascending_with_missing_fields() throws Exception {
    +    SearchRequest request = JSONUtils.INSTANCE.load(sortAscendingWithMissingFields, SearchRequest.class);
    +    SearchResponse response = dao.search(request);
    +    Assert.assertEquals(10, response.getTotal());
    +    List<SearchResult> results = response.getResults();
    +    Assert.assertEquals(10, results.size());
    +
    +    // the remaining are missing the 'threat:triage:score' and should be sorted last
    +    Assert.assertFalse(results.get(0).getSource().containsKey("threat:triage:score"));
    +    Assert.assertFalse(results.get(1).getSource().containsKey("threat:triage:score"));
    +    Assert.assertFalse(results.get(2).getSource().containsKey("threat:triage:score"));
    +    Assert.assertFalse(results.get(3).getSource().containsKey("threat:triage:score"));
    +    Assert.assertFalse(results.get(4).getSource().containsKey("threat:triage:score"));
    +    Assert.assertFalse(results.get(5).getSource().containsKey("threat:triage:score"));
    +    Assert.assertFalse(results.get(6).getSource().containsKey("threat:triage:score"));
    +    Assert.assertFalse(results.get(7).getSource().containsKey("threat:triage:score"));
    +
    +    // validate sorted order - there are only 2 with a 'threat:triage:score'
    +    Assert.assertEquals("10", results.get(8).getSource().get("threat:triage:score"));
    +    Assert.assertEquals("20", results.get(9).getSource().get("threat:triage:score"));
    +  }
    +
    +  @Test
    +  public void sort_descending_with_missing_fields() throws Exception {
    +    SearchRequest request = JSONUtils.INSTANCE.load(sortDescendingWithMissingFields,
SearchRequest.class);
    +    SearchResponse response = dao.search(request);
    +    Assert.assertEquals(10, response.getTotal());
    +    List<SearchResult> results = response.getResults();
    +    Assert.assertEquals(10, results.size());
    +
    +    // validate sorted order - there are only 2 with a 'threat:triage:score'
    +    Assert.assertEquals("20", results.get(0).getSource().get("threat:triage:score"));
    +    Assert.assertEquals("10", results.get(1).getSource().get("threat:triage:score"));
    +
    +    // the remaining are missing the 'threat:triage:score' and should be sorted last
    +    Assert.assertFalse(results.get(2).getSource().containsKey("threat:triage:score"));
    --- End diff --
    
    Same as above - Maybe put this in a simple loop?


---

Mime
View raw message