コード例 #1
0
  public void testGroupingByName2UrnsNameComesLate() {
    model
        .getGroupedSearchResults()
        .addListEventListener(new GroupingListEventListener(new SimilarResultsFileNameDetector()));

    TestSearchResult testResult1 = new TestSearchResult("1", "file name");
    TestSearchResult testResult2 = new TestSearchResult("2", "other file");
    TestSearchResult testResult3 = new TestSearchResult("1", "file name");
    // other file for urn1 is coming in late
    TestSearchResult testResult4 = new TestSearchResult("1", "other file");

    model.addSearchResult(testResult1);
    model.addSearchResult(testResult2);
    model.addSearchResult(testResult3);
    model.addSearchResult(testResult4);

    List<VisualSearchResult> results = model.getGroupedSearchResults();
    Assert.assertEquals(2, results.size());
    VisualSearchResult group0 = results.get(0);
    List<VisualSearchResult> similarResults0 = group0.getSimilarResults();
    Assert.assertEquals(0, similarResults0.size());
    List<SearchResult> coreResults0 = group0.getCoreSearchResults();
    Assert.assertEquals(3, coreResults0.size());

    VisualSearchResult group1 = results.get(1);
    List<VisualSearchResult> similarResults1 = group1.getSimilarResults();
    Assert.assertEquals(1, similarResults1.size());
    List<SearchResult> coreResults1 = group1.getCoreSearchResults();
    Assert.assertEquals(1, coreResults1.size());

    Assert.assertNull(group1.getSimilarityParent());
    Assert.assertEquals(group1, group0.getSimilarityParent());
  }
コード例 #2
0
  /** Tests method to retrieve sorted and filtered search results. */
  public void testGetSortedSearchResults() {
    // Create test search results.
    TestSearchResult testResult1 = new TestSearchResult("1", "xray");
    TestSearchResult testResult2 = new TestSearchResult("2", "zulu");
    TestSearchResult testResult3 = new TestSearchResult("3", "whiskey");
    TestSearchResult testResult4 = new TestSearchResult("4", "yankee");

    model.addSearchResult(testResult1);
    model.addSearchResult(testResult2);
    model.addSearchResult(testResult3);
    model.addSearchResult(testResult4);

    // Get sorted search results.
    model.setSelectedCategory(SearchCategory.ALL);
    List<VisualSearchResult> sortedList = model.getSortedSearchResults();

    // Verify unsorted order.
    String expectedReturn = "xray";
    String actualReturn = sortedList.get(0).getHeading();
    assertEquals("unsorted list", expectedReturn, actualReturn);

    // Apply sort option.
    model.setSortOption(SortOption.NAME);

    // Verify sorted order.
    expectedReturn = "whiskey";
    actualReturn = sortedList.get(0).getHeading();
    assertEquals("sorted list", expectedReturn, actualReturn);
  }
コード例 #3
0
  /** Tests method to set filter editor with filter text. */
  public void testSetFilterEditor() {
    // Create test search results.
    TestSearchResult testResult1 = new TestSearchResult("1", "xray");
    TestSearchResult testResult2 = new TestSearchResult("2", "zulu");
    TestSearchResult testResult3 = new TestSearchResult("3", "whiskey");
    TestSearchResult testResult4 = new TestSearchResult("4", "yankee");

    model.addSearchResult(testResult1);
    model.addSearchResult(testResult2);
    model.addSearchResult(testResult3);
    model.addSearchResult(testResult4);

    // Get all search results.
    List<VisualSearchResult> filteredList = model.getCategorySearchResults(SearchCategory.ALL);

    // Verify unfiltered list.
    int expectedSize = 4;
    int actualSize = filteredList.size();
    assertEquals("unfiltered list size", expectedSize, actualSize);

    // Apply filter editor.
    TextMatcherEditor<VisualSearchResult> editor =
        new TextMatcherEditor<VisualSearchResult>(new VisualSearchResultTextFilterator());
    editor.setFilterText(new String[] {"z"});
    model.setFilterEditor(editor);

    // Verify filtered list.
    expectedSize = 1;
    actualSize = filteredList.size();
    assertEquals("filtered list size", expectedSize, actualSize);
  }
コード例 #4
0
  public void testSameNameHyphenNameHyphenName() {

    Map<FilePropertyKey, Object> properties1 = new HashMap<FilePropertyKey, Object>();
    properties1.put(FilePropertyKey.NAME, "test-foo-bar");
    SearchResult searchResult1 = new TestSearchResult("1", "test-foo-bar.mp3", properties1);
    Map<FilePropertyKey, Object> properties2 = new HashMap<FilePropertyKey, Object>();
    properties2.put(FilePropertyKey.NAME, "test-foo-bar");
    SearchResult searchResult2 = new TestSearchResult("2", "test-foo-bar.mp3", properties2);

    model
        .getGroupedSearchResults()
        .addListEventListener(
            new GroupingListEventListener(new AudioMetaDataSimilarResultsDetector()));

    model.addSearchResult(searchResult1);
    model.addSearchResult(searchResult2);

    List<VisualSearchResult> results = model.getGroupedSearchResults();
    Assert.assertEquals(2, results.size());

    VisualSearchResult group0 = results.get(0);
    List<VisualSearchResult> similarResults0 = group0.getSimilarResults();
    Assert.assertEquals(1, similarResults0.size());
    List<SearchResult> coreResults0 = group0.getCoreSearchResults();
    Assert.assertEquals(1, coreResults0.size());

    VisualSearchResult group1 = results.get(1);
    List<VisualSearchResult> similarResults1 = group1.getSimilarResults();
    Assert.assertEquals(0, similarResults1.size());
    List<SearchResult> coreResults1 = group1.getCoreSearchResults();
    Assert.assertEquals(1, coreResults1.size());

    Assert.assertNull(group0.getSimilarityParent());
    Assert.assertEquals(group0, group1.getSimilarityParent());
  }
コード例 #5
0
  public void testGroupByName4Urns() {
    model
        .getGroupedSearchResults()
        .addListEventListener(new GroupingListEventListener(new SimilarResultsFileNameDetector()));

    TestSearchResult testResult1 = new TestSearchResult("1", "other file");
    TestSearchResult testResult2 = new TestSearchResult("2", "other file");
    TestSearchResult testResult3 = new TestSearchResult("3", "other file");
    TestSearchResult testResult4 = new TestSearchResult("4", "other file");

    model.addSearchResult(testResult1);
    model.addSearchResult(testResult2);
    model.addSearchResult(testResult3);
    model.addSearchResult(testResult4);

    List<VisualSearchResult> results = model.getGroupedSearchResults();
    Assert.assertEquals(4, results.size());
    VisualSearchResult group0 = results.get(0);
    List<VisualSearchResult> similarResults0 = group0.getSimilarResults();
    Assert.assertEquals(3, similarResults0.size());
    List<SearchResult> coreResults0 = group0.getCoreSearchResults();
    Assert.assertEquals(1, coreResults0.size());

    VisualSearchResult group1 = results.get(1);
    List<VisualSearchResult> similarResults1 = group1.getSimilarResults();
    Assert.assertEquals(0, similarResults1.size());
    List<SearchResult> coreResults1 = group1.getCoreSearchResults();
    Assert.assertEquals(1, coreResults1.size());

    VisualSearchResult group2 = results.get(2);
    List<VisualSearchResult> similarResults2 = group2.getSimilarResults();
    Assert.assertEquals(0, similarResults2.size());
    List<SearchResult> coreResults2 = group2.getCoreSearchResults();
    Assert.assertEquals(1, coreResults2.size());

    VisualSearchResult group3 = results.get(3);
    List<VisualSearchResult> similarResults3 = group3.getSimilarResults();
    Assert.assertEquals(0, similarResults3.size());
    List<SearchResult> coreResults3 = group1.getCoreSearchResults();
    Assert.assertEquals(1, coreResults3.size());

    Assert.assertEquals(group0, group1.getSimilarityParent());
    Assert.assertNull(group0.getSimilarityParent());
    Assert.assertEquals(group0, group2.getSimilarityParent());
    Assert.assertEquals(group0, group3.getSimilarityParent());
  }
コード例 #6
0
  public void testGroupingByName3UrnsNameMatchViaTransitiveProperty() {
    model
        .getGroupedSearchResults()
        .addListEventListener(new GroupingListEventListener(new SimilarResultsFileNameDetector()));

    TestSearchResult testResult1 = new TestSearchResult("1", "blah1 file");
    TestSearchResult testResult2 = new TestSearchResult("1", "blah1 file");
    TestSearchResult testResult3 = new TestSearchResult("2", "blah2 file");
    TestSearchResult testResult4 = new TestSearchResult("2", "blah2 file");
    TestSearchResult testResult5 = new TestSearchResult("3", "blah1 file");
    TestSearchResult testResult6 = new TestSearchResult("3", "blah2 file");

    model.addSearchResult(testResult1);
    model.addSearchResult(testResult2);
    model.addSearchResult(testResult3);
    model.addSearchResult(testResult4);
    model.addSearchResult(testResult5);
    model.addSearchResult(testResult6);

    List<VisualSearchResult> results = model.getGroupedSearchResults();
    Assert.assertEquals(3, results.size());
    VisualSearchResult group0 = results.get(0);
    List<VisualSearchResult> similarResults0 = group0.getSimilarResults();
    Assert.assertEquals(0, similarResults0.size());
    List<SearchResult> coreResults0 = group0.getCoreSearchResults();
    Assert.assertEquals(2, coreResults0.size());

    VisualSearchResult group1 = results.get(1);
    List<VisualSearchResult> similarResults1 = group1.getSimilarResults();
    Assert.assertEquals(2, similarResults1.size());
    List<SearchResult> coreResults1 = group1.getCoreSearchResults();
    Assert.assertEquals(2, coreResults1.size());

    VisualSearchResult group2 = results.get(2);
    List<VisualSearchResult> similarResults2 = group2.getSimilarResults();
    Assert.assertEquals(0, similarResults2.size());
    List<SearchResult> coreResults2 = group2.getCoreSearchResults();
    Assert.assertEquals(2, coreResults2.size());

    Assert.assertNull(group1.getSimilarityParent());
    Assert.assertEquals(group1, group0.getSimilarityParent());
    Assert.assertEquals(group1, group2.getSimilarityParent());
  }
コード例 #7
0
  /** Tests method to retrieve filtered search results by category. */
  public void testGetCategorySearchResults() {
    // Create test search results.
    TestSearchResult testResult1 = new TestSearchResult("1", "xray");
    TestSearchResult testResult2 = new TestSearchResult("2", "zulu");
    TestSearchResult testResult3 = new TestSearchResult("3", "whiskey");
    TestSearchResult testResult4 = new TestSearchResult("4", "yankee");
    testResult3.setCategory(Category.VIDEO);
    testResult4.setCategory(Category.IMAGE);

    model.addSearchResult(testResult1);
    model.addSearchResult(testResult2);
    model.addSearchResult(testResult3);
    model.addSearchResult(testResult4);

    // Get category search results.
    List<VisualSearchResult> categoryList = model.getCategorySearchResults(SearchCategory.VIDEO);

    // Verify category list.
    int expectedSize = 1;
    int actualSize = categoryList.size();
    assertEquals("category list size", expectedSize, actualSize);
  }
コード例 #8
0
  public void testVisibility() {
    model
        .getGroupedSearchResults()
        .addListEventListener(new GroupingListEventListener(new SimilarResultsFileNameDetector()));

    TestSearchResult testResult1 = new TestSearchResult("1", "blah1 file");
    TestSearchResult testResult2 = new TestSearchResult("1", "blah1 file");
    TestSearchResult testResult3 = new TestSearchResult("2", "blah1 file");
    TestSearchResult testResult4 = new TestSearchResult("2", "blah2 file");
    TestSearchResult testResult5 = new TestSearchResult("3", "blah1 file");
    TestSearchResult testResult6 = new TestSearchResult("3", "blah2 file");

    model.addSearchResult(testResult1);
    List<VisualSearchResult> results = model.getGroupedSearchResults();
    Assert.assertEquals(1, results.size());
    VisualSearchResult result0 = results.get(0);
    Assert.assertTrue(result0.isVisible());
    Assert.assertFalse(result0.isChildrenVisible());
    result0.setChildrenVisible(true);
    Assert.assertTrue(result0.isVisible());
    Assert.assertTrue(result0.isChildrenVisible());

    model.addSearchResult(testResult2);
    Assert.assertTrue(result0.isVisible());
    Assert.assertTrue(result0.isChildrenVisible());

    model.addSearchResult(testResult3);

    Assert.assertTrue(result0.isVisible());
    Assert.assertTrue(result0.isChildrenVisible());
    List<VisualSearchResult> children = result0.getSimilarResults();
    Assert.assertEquals(1, children.size());
    VisualSearchResult child = children.get(0);
    Assert.assertTrue(child.isVisible());

    result0.setChildrenVisible(false);
    Assert.assertTrue(result0.isVisible());
    Assert.assertFalse(result0.isChildrenVisible());
    Assert.assertFalse(child.isVisible());
    result0.setChildrenVisible(true);

    model.addSearchResult(testResult4);
    model.addSearchResult(testResult5);

    children = result0.getSimilarResults();
    Assert.assertEquals(2, children.size());
    VisualSearchResult child0 = children.get(0);
    VisualSearchResult child1 = children.get(1);
    Assert.assertTrue(child0.isVisible());
    Assert.assertTrue(child1.isVisible());
    result0.setChildrenVisible(false);

    model.addSearchResult(testResult6);

    children = result0.getSimilarResults();
    Assert.assertEquals(2, children.size());
    child0 = children.get(0);
    child1 = children.get(1);
    Assert.assertFalse(child0.isVisible());
    Assert.assertFalse(child1.isVisible());
    result0.setChildrenVisible(true);
    Assert.assertTrue(child0.isVisible());
    Assert.assertTrue(child1.isVisible());

    results = model.getGroupedSearchResults();
    Assert.assertEquals(3, results.size());
    VisualSearchResult group0 = results.get(0);
    List<VisualSearchResult> similarResults0 = group0.getSimilarResults();
    Assert.assertEquals(2, similarResults0.size());
    List<SearchResult> coreResults0 = group0.getCoreSearchResults();
    Assert.assertEquals(2, coreResults0.size());

    VisualSearchResult group1 = results.get(1);
    List<VisualSearchResult> similarResults1 = group1.getSimilarResults();
    Assert.assertEquals(0, similarResults1.size());
    List<SearchResult> coreResults1 = group1.getCoreSearchResults();
    Assert.assertEquals(2, coreResults1.size());

    VisualSearchResult group2 = results.get(2);
    List<VisualSearchResult> similarResults2 = group2.getSimilarResults();
    Assert.assertEquals(0, similarResults2.size());
    List<SearchResult> coreResults2 = group2.getCoreSearchResults();
    Assert.assertEquals(2, coreResults2.size());

    Assert.assertNull(group0.getSimilarityParent());
    Assert.assertEquals(group0, group2.getSimilarityParent());
    Assert.assertEquals(group0, group1.getSimilarityParent());
  }