use Junit5 instead of TestNG

We want to be able to use @SpringBootTest tests that fully initialize
the Spring application. This is much easier done with Junit than TestNG.
Gradle does not support (at least not easily) to run Junit and TestNG
tests. Therefore we switch to Junit with all tests.
The original reason for using TestNG was that Junit didn't support
data providers. But that finally changed in Junit5 with
ParameterizedTest.
This commit is contained in:
2019-12-13 14:33:20 +01:00
parent 394e16ad27
commit 07ad62ddd9
26 changed files with 660 additions and 837 deletions

View File

@@ -7,22 +7,27 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.lucares.pdb.api.DateTimeRange;
import org.lucares.pdb.api.Query;
import org.lucares.pdb.api.QueryWithCaretMarker;
@@ -31,27 +36,22 @@ import org.lucares.pdb.api.Tags;
import org.lucares.pdb.blockstorage.BSFile;
import org.lucares.pdb.datastore.Doc;
import org.lucares.pdb.datastore.Proposal;
import org.junit.jupiter.api.Assertions;
import org.lucares.utils.CollectionUtils;
import org.lucares.utils.DateUtils;
import org.lucares.utils.file.FileUtils;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@Test
public class DataStoreTest {
private Path dataDirectory;
private DataStore dataStore;
private Map<Tags, Long> tagsToBlockStorageRootBlockNumber;
@BeforeMethod
@BeforeEach
public void beforeMethod() throws IOException {
dataDirectory = Files.createTempDirectory("pdb");
}
@AfterMethod
@AfterEach
public void afterMethod() throws IOException {
FileUtils.delete(dataDirectory);
dataStore = null;
@@ -59,6 +59,7 @@ public class DataStoreTest {
Tags.STRING_COMPRESSOR = null;
}
@Test
public void testQuery() throws Exception {
dataStore = new DataStore(dataDirectory);
@@ -109,6 +110,7 @@ public class DataStoreTest {
}
@Test
public void testGetByTags() throws IOException {
dataStore = new DataStore(dataDirectory);
@@ -121,61 +123,58 @@ public class DataStoreTest {
tagsToBlockStorageRootBlockNumber.put(flamingoJennifer, dataStore.createNewFile(partitionId, flamingoJennifer));
final Optional<Doc> docsFlamingoJennifer = dataStore.getByTags(partitionId, flamingoJennifer);
Assert.assertTrue(docsFlamingoJennifer.isPresent(), "doc for docsFlamingoJennifer");
Assertions.assertTrue(docsFlamingoJennifer.isPresent(), "doc for docsFlamingoJennifer");
}
@Test
public void testBlockAlignment() throws IOException {
dataStore = new DataStore(dataDirectory);
final Tags eagleTim = Tags.createAndAddToDictionary("bird", "eagle", "name", "Tim");
final long eagleTimBlockOffset = dataStore.createNewFile(new ParititionId("partitionA"), eagleTim);
Assert.assertEquals(eagleTimBlockOffset % BSFile.BLOCK_SIZE, 0);
Assertions.assertEquals(0, eagleTimBlockOffset % BSFile.BLOCK_SIZE);
}
@DataProvider(name = "providerProposals")
public Iterator<Object[]> providerProposals() {
public static Stream<Arguments> providerProposals() {
final List<Object[]> result = new ArrayList<>();
return Stream.of(
result.add(new Object[] { "type=bird and subtype=eagle and name=|", "name", Arrays.asList("Tim") });
Arguments.of("type=bird and subtype=eagle and name=|", "name", Arrays.asList("Tim")),
// returns Tim, because it is the only dog's name starting with 'Ti'
result.add(new Object[] { "!name=Ti| and type=dog", "name", Arrays.asList("Tim") });
// returns Tim, because it is the only dog's name starting with 'Ti'
Arguments.of("!name=Ti| and type=dog", "name", Arrays.asList("Tim")),
// all cats
result.add(new Object[] { "type=cat and !name=|", "name",
Arrays.asList("Jane", "John", "Paul", "Sam", "Timothy") });
// all cats
Arguments.of("type=cat and !name=|", "name", Arrays.asList("Jane", "John", "Paul", "Sam", "Timothy")),
// finds nothing, because there are not dogs names neither Jenny, nor Ti*
result.add(new Object[] { "!name=Ti| and type=dog and !name=Jenny", "name", Arrays.asList() });
// finds nothing, because there are not dogs names neither Jenny, nor Ti*
Arguments.of("!name=Ti| and type=dog and !name=Jenny", "name", Arrays.asList()),
result.add(new Object[] { "(type=bird and age=three or type=dog and age=three) and name=|", "name",
Arrays.asList("Jenny", "Tim") });
Arguments.of("(type=bird and age=three or type=dog and age=three) and name=|", "name",
Arrays.asList("Jenny", "Tim")),
// all but Jennifer
result.add(new Object[] { "!(type=bird) and name=|", "name",
Arrays.asList("Jane", "Jenny", "John", "Paul", "Sam", "Tim", "Timothy") });
// all but Jennifer
Arguments.of("!(type=bird) and name=|", "name",
Arrays.asList("Jane", "Jenny", "John", "Paul", "Sam", "Tim", "Timothy")),
result.add(new Object[] { "type=bird and !subtype=eagle and name=|", "name", Arrays.asList("Jennifer") });
Arguments.of("type=bird and !subtype=eagle and name=|", "name", Arrays.asList("Jennifer")),
// DeMorgan
// TODO should only match "Jenny", because Jenny is the only non-bird name
// starting with 'Jen'
result.add(new Object[] { "!(type=bird and name=Jen|)", "name", Arrays.asList("Jennifer", "Jenny") });
// DeMorgan
// TODO should only match "Jenny", because Jenny is the only non-bird name
// starting with 'Jen'
Arguments.of("!(type=bird and name=Jen|)", "name", Arrays.asList("Jennifer", "Jenny")),
result.add(new Object[] { "!(type=dog and name=|) and !type=cat", "name",
Arrays.asList("Jennifer", "Jenny", "Tim") });
Arguments.of("!(type=dog and name=|) and !type=cat", "name", Arrays.asList("Jennifer", "Jenny", "Tim")),
// not existing field
result.add(new Object[] { "name=| and XYZ=Tim", "name", Arrays.asList() });
// not existing field
Arguments.of("name=| and XYZ=Tim", "name", Arrays.asList()),
// not existing value
result.add(new Object[] { "name=| and type=XYZ", "name", Arrays.asList() });
return result.iterator();
// not existing value
Arguments.of("name=| and type=XYZ", "name", Arrays.asList()));
}
@Test(dataProvider = "providerProposals")
@ParameterizedTest
@MethodSource("providerProposals")
public void testProposals(final String queryWithCaret, final String field,
final List<String> expectedProposedValues) throws Exception {
@@ -202,6 +201,7 @@ public class DataStoreTest {
assertProposals(dateRange, queryWithCaret, field, expectedProposedValues);
}
@Test
public void testIdenticalDatesGoIntoSameFile() throws Exception {
try (final DataStore dataStore = new DataStore(dataDirectory)) {
@@ -213,7 +213,7 @@ public class DataStoreTest {
dataStore.write(timestamp, tags, 1);
dataStore.write(timestamp, tags, 2);
Assert.assertEquals(dataStore.sizeWriterCache(), 1, "size of the writer cache");
Assertions.assertEquals(1, dataStore.sizeWriterCache(), "size of the writer cache");
}
}
@@ -313,12 +313,12 @@ public class DataStoreTest {
final List<String> proposedValues = CollectionUtils.map(proposals, Proposal::getProposedTag);
Collections.sort(proposedValues);
Collections.sort(expectedProposedValues);
Assert.assertEquals(proposedValues.toString(), expectedProposedValues.toString(), "proposed values:");
Assertions.assertEquals(expectedProposedValues.toString(), proposedValues.toString(), "proposed values:");
}
private void assertQueryFindsResults(final DateTimeRange dateRange, final String query) {
final List<Doc> result = dataStore.search(new Query(query, dateRange));
Assert.assertFalse(result.isEmpty(), "The query '" + query + "' must return a result, but didn't.");
Assertions.assertFalse(result.isEmpty(), "The query '" + query + "' must return a result, but didn't.");
}
private void assertSearch(final DateTimeRange dateRange, final String queryString, final Tags... tags) {
@@ -328,7 +328,7 @@ public class DataStoreTest {
final List<Long> expectedPaths = CollectionUtils.map(tags, tagsToBlockStorageRootBlockNumber::get);
Assert.assertEquals(actual, expectedPaths, "Query: " + queryString + " Found: " + actual);
Assertions.assertEquals(expectedPaths, actual, "Query: " + queryString + " Found: " + actual);
}
}

View File

@@ -7,53 +7,56 @@ import java.util.Arrays;
import java.util.DoubleSummaryStatistics;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.lucares.pdb.api.DateTimeRange;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Assertions;
@Test
public class DateIndexExtensionTest {
@DataProvider
public Object[][] provider() {
public static Stream<Arguments> provider() {
final List<Object[]> result = new ArrayList<>();
final List<Arguments> result = new ArrayList<>();
{
final OffsetDateTime start = OffsetDateTime.of(2018, 1, 31, 0, 0, 0, 0, ZoneOffset.UTC);
final OffsetDateTime end = OffsetDateTime.of(2018, 1, 31, 0, 0, 0, 0, ZoneOffset.UTC);
final Set<String> expected = Set.of("201801");
result.add(new Object[] { start, end, expected });
result.add(Arguments.of(start, end, expected));
}
{
final OffsetDateTime start = OffsetDateTime.of(2017, 11, 1, 0, 0, 0, 0, ZoneOffset.UTC);
final OffsetDateTime end = OffsetDateTime.of(2018, 02, 1, 0, 0, 0, 0, ZoneOffset.UTC);
final Set<String> expected = Set.of("201711", "201712", "201801", "201802");
result.add(new Object[] { start, end, expected });
result.add(Arguments.of(start, end, expected));
}
{
// check that adding one month to Jan 31 does not skip the February
final OffsetDateTime start = OffsetDateTime.of(2018, 1, 31, 0, 0, 0, 0, ZoneOffset.UTC);
final OffsetDateTime end = OffsetDateTime.of(2018, 3, 31, 0, 0, 0, 0, ZoneOffset.UTC);
final Set<String> expected = Set.of("201801", "201802", "201803");
result.add(new Object[] { start, end, expected });
result.add(Arguments.of(start, end, expected));
}
return result.toArray(new Object[0][]);
return result.stream();
}
@Test(dataProvider = "provider")
@ParameterizedTest
@MethodSource("provider")
public void test(final OffsetDateTime start, final OffsetDateTime end, final Set<String> expected) {
final DateTimeRange dateRange = new DateTimeRange(start, end);
final Set<String> actual = DateIndexExtension.toDateIndexPrefix(dateRange);
Assert.assertEquals(actual, expected);
Assertions.assertEquals(expected, actual);
}
@Test
public void testDateToDateIndexPrefix() {
final long mid_201711 = OffsetDateTime.of(2017, 11, 23, 2, 2, 2, 0, ZoneOffset.UTC).toInstant().toEpochMilli();
@@ -62,12 +65,13 @@ public class DateIndexExtensionTest {
final long max_201801 = OffsetDateTime.of(2018, 1, 31, 23, 59, 59, 999_999_999, ZoneOffset.UTC).toInstant()
.toEpochMilli();
Assert.assertEquals(DateIndexExtension.toDateIndexPrefix(mid_201712), "201712");
Assert.assertEquals(DateIndexExtension.toDateIndexPrefix(min_201801), "201801");
Assert.assertEquals(DateIndexExtension.toDateIndexPrefix(max_201801), "201801");
Assert.assertEquals(DateIndexExtension.toDateIndexPrefix(mid_201711), "201711");
Assertions.assertEquals("201712", DateIndexExtension.toDateIndexPrefix(mid_201712));
Assertions.assertEquals("201801", DateIndexExtension.toDateIndexPrefix(min_201801));
Assertions.assertEquals("201801", DateIndexExtension.toDateIndexPrefix(max_201801));
Assertions.assertEquals("201711", DateIndexExtension.toDateIndexPrefix(mid_201711));
}
@Test
public void testDateRanges() {
final OffsetDateTime mid_201712 = OffsetDateTime.of(2017, 12, 7, 1, 1, 1, 0, ZoneOffset.UTC)
.withOffsetSameInstant(ZoneOffset.ofHours(-2));
@@ -82,18 +86,19 @@ public class DateIndexExtensionTest {
final List<ParititionId> dateIndexPrefixesWithEmptyCache = DateIndexExtension
.toPartitionIds(range_201712_201802);
Assert.assertEquals(dateIndexPrefixesWithEmptyCache,
Arrays.asList(new ParititionId("201712"), new ParititionId("201801"), new ParititionId("201802")));
Assertions.assertEquals(Arrays.asList(new ParititionId("201712"), new ParititionId("201801"), new ParititionId("201802")),
dateIndexPrefixesWithEmptyCache);
final List<ParititionId> dateIndexPrefixesWithFilledCache = DateIndexExtension
.toPartitionIds(range_201712_201801);
Assert.assertEquals(dateIndexPrefixesWithFilledCache,
Arrays.asList(new ParititionId("201712"), new ParititionId("201801")));
Assertions.assertEquals(Arrays.asList(new ParititionId("201712"), new ParititionId("201801")),
dateIndexPrefixesWithFilledCache);
final List<ParititionId> dateIndexPrefixesOneMonth = DateIndexExtension.toPartitionIds(range_201712_201712);
Assert.assertEquals(dateIndexPrefixesOneMonth, Arrays.asList(new ParititionId("201712")));
Assertions.assertEquals(Arrays.asList(new ParititionId("201712")), dateIndexPrefixesOneMonth);
}
@Test
public void testDateRangeToEpochMilli() {
final OffsetDateTime mid_201712 = OffsetDateTime.of(2017, 12, 7, 1, 1, 1, 0, ZoneOffset.ofHours(3));
final OffsetDateTime min_201802 = OffsetDateTime.of(2018, 2, 15, 0, 0, 0, 0, ZoneOffset.ofHours(7));
@@ -104,9 +109,10 @@ public class DateIndexExtensionTest {
final List<Long> dateIndexEpochMillis = DateIndexExtension
.toDateIndexEpochMillis(new DateTimeRange(mid_201712, min_201802));
Assert.assertEquals(dateIndexEpochMillis, Arrays.asList(exp_201712, exp_201801, exp_201802));
Assertions.assertEquals(Arrays.asList(exp_201712, exp_201801, exp_201802), dateIndexEpochMillis);
}
@Test
public void testPerformance() {
final long min = OffsetDateTime.of(2010, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).toInstant().toEpochMilli();

View File

@@ -7,40 +7,39 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.lucares.pdb.api.DateTimeRange;
import org.lucares.pdb.api.QueryWithCaretMarker;
import org.lucares.pdb.api.QueryWithCaretMarker.ResultMode;
import org.lucares.pdb.api.Tags;
import org.lucares.pdb.datastore.Proposal;
import org.junit.jupiter.api.Assertions;
import org.lucares.utils.CollectionUtils;
import org.lucares.utils.file.FileUtils;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test
public class ProposerTest {
private Path dataDirectory;
private DataStore dataStore;
private DateTimeRange dateRange;
private static Path dataDirectory;
private static DataStore dataStore;
private static DateTimeRange dateRange;
@BeforeClass
public void beforeClass() throws Exception {
@BeforeAll
public static void beforeClass() throws Exception {
dataDirectory = Files.createTempDirectory("pdb");
initDatabase();
}
@AfterClass
public void afterClass() throws IOException {
@AfterAll
public static void afterClass() throws IOException {
FileUtils.delete(dataDirectory);
dataStore.close();
dataStore = null;
Tags.STRING_COMPRESSOR = null;
}
private void initDatabase() throws Exception {
private static void initDatabase() throws Exception {
dataStore = new DataStore(dataDirectory);
dateRange = DateTimeRange.now();
final ParititionId now = DateIndexExtension.toPartitionIds(dateRange).get(0);
@@ -71,6 +70,7 @@ public class ProposerTest {
dataStore.createNewFile(now, methodD);
}
@Test
public void testEmptyQuery() throws Exception {
assertProposals("|", ResultMode.FULL_VALUES, //
@@ -90,6 +90,7 @@ public class ProposerTest {
);
}
@Test
public void testPrefixOfKey() throws Exception {
assertProposals("bi|", ResultMode.FULL_VALUES, //
new Proposal("bird", "bird=* ", true, "bird=", 5) //
@@ -110,6 +111,7 @@ public class ProposerTest {
);
}
@Test
public void testPrefixOfValue() throws Exception {
assertProposals("name =Tim|", ResultMode.FULL_VALUES, //
new Proposal("Tim", "name =Tim", true, "name =Tim", 9),
@@ -135,7 +137,7 @@ public class ProposerTest {
*/
}
@Test(enabled = true)
@Test
public void testInExpressions() throws Exception {
assertProposals("name = (Timothy,|)", ResultMode.FULL_VALUES, //
new Proposal("Jennifer", "name = (Timothy,Jennifer)", true, "name = (Timothy,Jennifer)", 24), //
@@ -156,6 +158,7 @@ public class ProposerTest {
*/
}
@Test
public void testProposalOnEmptyValuePrefix() throws Exception {
assertProposals("name=|", ResultMode.FULL_VALUES, //
new Proposal("Jennifer", "name=Jennifer", true, "name=Jennifer", 13), //
@@ -182,6 +185,7 @@ public class ProposerTest {
);
}
@Test
public void testProposalOnValueSmartExpression() throws Exception {
assertProposals("method=Foo.|", ResultMode.CUT_AT_DOT, //
new Proposal("FooController.doImportantStuff", "method=FooController.doImportantStuff", true,
@@ -215,6 +219,7 @@ public class ProposerTest {
);
}
@Test
public void testProposalOnEmptyKeyPrefix() throws Exception {
assertProposals("name=* and |", ResultMode.FULL_VALUES, //
proposal("name", "name=* and name=* ", "name=* and name=|"), //
@@ -228,6 +233,7 @@ public class ProposerTest {
);
}
@Test
public void testProposalWithWildcards() throws Exception {
assertProposals("name=*im|", ResultMode.FULL_VALUES, //
@@ -245,6 +251,7 @@ public class ProposerTest {
);
}
@Test
public void testProposalWithAndExpression() throws Exception {
assertProposals("name=*im| and bird=eagle", ResultMode.FULL_VALUES, //
proposal("Tim", "name=Tim and bird=eagle", "name=Tim| and bird=eagle"), //
@@ -257,6 +264,7 @@ public class ProposerTest {
);
}
@Test
public void testProposalWithAndNotExpression() throws Exception {
assertProposals("name=Tim and ! dog=labrador and bird=|", ResultMode.FULL_VALUES, //
proposal("eagle", "name=Tim and ! dog=labrador and bird=eagle",
@@ -292,6 +300,6 @@ public class ProposerTest {
System.out.println("\n\n--- " + query + " ---");
System.out.println("actual : " + String.join("\n", CollectionUtils.map(actual, Proposal::toString)));
System.out.println("expected: " + String.join("\n", CollectionUtils.map(expectedList, Proposal::toString)));
Assert.assertEquals(actual, expectedList);
Assertions.assertEquals(expectedList, actual);
}
}

View File

@@ -5,34 +5,36 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.lucares.pdb.api.DateTimeRange;
import org.lucares.pdb.api.StringCompressor;
import org.lucares.pdb.api.Tag;
import org.lucares.pdb.api.Tags;
import org.lucares.pdb.api.UniqueStringIntegerPairs;
import org.junit.jupiter.api.Assertions;
import org.lucares.utils.file.FileUtils;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test
public class QueryCompletionIndexTest {
private Path dataDirectory;
@BeforeMethod
@BeforeEach
public void beforeMethod() throws IOException {
dataDirectory = Files.createTempDirectory("pdb");
}
@AfterMethod
@AfterEach
public void afterMethod() throws IOException {
FileUtils.delete(dataDirectory);
}
@Test
public void test() throws Exception {
Tags.STRING_COMPRESSOR = new StringCompressor(new UniqueStringIntegerPairs());
@@ -54,20 +56,20 @@ public class QueryCompletionIndexTest {
// tags A and B match
final SortedSet<String> firstnamesWithLastnameDoe = index.find(dateRange, new Tag("lastname", "Doe"),
"firstname");
Assert.assertEquals(firstnamesWithLastnameDoe, Arrays.asList("Jane", "John"));
Assertions.assertEquals(new TreeSet<>(Set.of("Jane", "John")), firstnamesWithLastnameDoe);
// no duplicates are returned:
// tags A and C match firstname=John, but both have country=Atlantis
final SortedSet<String> countryWithFirstnameJohn = index.find(dateRange, new Tag("firstname", "John"),
"country");
Assert.assertEquals(countryWithFirstnameJohn, Arrays.asList("Atlantis"));
Assertions.assertEquals(new TreeSet<>(Arrays.asList("Atlantis")), countryWithFirstnameJohn);
// findAllValuesForField sorts alphabetically
final SortedSet<String> firstnames = index.findAllValuesForField(dateRange, "firstname");
Assert.assertEquals(firstnames, Arrays.asList("Jane", "John"), "found: " + firstnames);
Assertions.assertEquals(new TreeSet<>(Arrays.asList("Jane", "John")), firstnames, "found: " + firstnames);
final SortedSet<String> countries = index.findAllValuesForField(dateRange, "country");
Assert.assertEquals(countries, Arrays.asList("Atlantis", "ElDorado"));
Assertions.assertEquals(new TreeSet<>(Arrays.asList("Atlantis", "ElDorado")), countries);
}
}
}

View File

@@ -1,58 +1,55 @@
package org.lucares.pdb.datastore.lang;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.stream.Stream;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.api.Assertions;
@Test
public class CandidateGrouperTest {
@DataProvider
public Object[][] providerGroup() {
final List<Object[]> result = new ArrayList<>();
public static Stream<Arguments> providerGroup() {
return Stream.of(
result.add(new Object[] { //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = |", //
Set.of("aa.") });
result.add(new Object[] { //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = a|", //
Set.of("aa.") });
result.add(new Object[] { //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa|", //
Set.of("aa.") });
result.add(new Object[] { //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa.|", //
Set.of("aa.xx.", "aa.yy.") });
result.add(new Object[] { //
Set.of("aa.xx.AA.XX", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa.x|", //
Set.of("aa.xx.") });
result.add(new Object[] { //
Set.of("aa.xx.AA.XX", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa.xx.|", //
Set.of("aa.xx.AA.", "aa.xx.BB") });
result.add(new Object[] { //
Set.of("aa.xx.AA.XX", "aa.xx.AA.YY"), //
"name = aa.xx.AA.|", //
Set.of("aa.xx.AA.XX", "aa.xx.AA.YY") });
result.add(new Object[] { //
Set.of("XX.YY.ZZ", "XX.YY"), //
"name = XX.Y|", //
Set.of("XX.YY.", "XX.YY") });
return result.toArray(new Object[0][]);
Arguments.of( //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = |", //
Set.of("aa.")),
Arguments.of( //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = a|", //
Set.of("aa.")),
Arguments.of( //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa|", //
Set.of("aa.")),
Arguments.of( //
Set.of("aa.xx.AA.XX", "aa.yy.BB", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa.|", //
Set.of("aa.xx.", "aa.yy.")),
Arguments.of( //
Set.of("aa.xx.AA.XX", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa.x|", //
Set.of("aa.xx.")),
Arguments.of( //
Set.of("aa.xx.AA.XX", "aa.xx.BB", "aa.xx.AA.YY"), //
"name = aa.xx.|", //
Set.of("aa.xx.AA.", "aa.xx.BB")),
Arguments.of( //
Set.of("aa.xx.AA.XX", "aa.xx.AA.YY"), //
"name = aa.xx.AA.|", //
Set.of("aa.xx.AA.XX", "aa.xx.AA.YY")),
Arguments.of( //
Set.of("XX.YY.ZZ", "XX.YY"), //
"name = XX.Y|", //
Set.of("XX.YY.", "XX.YY")));
}
@Test(dataProvider = "providerGroup")
@ParameterizedTest
@MethodSource("providerGroup")
public void testGroup(final Set<String> values, final String queryWithCaretMarker, final Set<String> expected) {
final CandidateGrouper grouper = new CandidateGrouper();
@@ -60,6 +57,6 @@ public class CandidateGrouperTest {
final SortedSet<String> actual = grouper.group(values, query);
Assert.assertEquals(actual, expected);
Assertions.assertEquals(expected, actual);
}
}