Skip to content

Commit

Permalink
Merge pull request #1850 from UNC-Libraries/bxc-4793
Browse files Browse the repository at this point in the history
BXC-4793 - Fix flapping QueryFilterFactoryTest
  • Loading branch information
sharonluong authored Dec 4, 2024
2 parents 30f0034 + e5722bf commit 8bd7d00
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author lfarrell
Expand All @@ -28,7 +30,12 @@ public void multipleDirectlyOwnedDatastreamsFilterTest() {
datastreamTypes.add(DatastreamType.FULLTEXT_EXTRACTION);
var filter = QueryFilterFactory.createDirectlyOwnedFilter(SearchFieldKey.DATASTREAM, datastreamTypes);
assertInstanceOf(MultipleDirectlyOwnedDatastreamsFilter.class, filter);
assertEquals("(datastream:jp2|*|| OR datastream:fulltext|*||)", filter.toFilterString());

var filterString = filter.toFilterString();
filterString = filterString.substring(1, filterString.length() - 1); // Trim off parens
var parts = Arrays.asList(filterString.split(" OR ")); // Match regardless of order
assertTrue(parts.contains("datastream:jp2|*||"));
assertTrue(parts.contains("datastream:fulltext|*||"));
}

@Test
Expand All @@ -38,7 +45,11 @@ public void datastreamsFilterTest() {
datastreamTypes.add(DatastreamType.FULLTEXT_EXTRACTION);
var filter = QueryFilterFactory.createFilter(SearchFieldKey.DATASTREAM, datastreamTypes);
assertInstanceOf(MultipleDirectlyOwnedDatastreamsFilter.class, filter);
assertEquals("(datastream:jp2|* OR datastream:fulltext|*)", filter.toFilterString());
var filterString = filter.toFilterString();
filterString = filterString.substring(1, filterString.length() - 1); // Trim off parens
var parts = Arrays.asList(filterString.split(" OR ")); // Match regardless of order
assertTrue(parts.contains("datastream:jp2|*"));
assertTrue(parts.contains("datastream:fulltext|*"));
}

@Test
Expand Down

0 comments on commit 8bd7d00

Please sign in to comment.