use of junitparams.Parameters in project geode by apache.
the class MixedObjectIndexDUnitTest method luceneMustIndexFieldsWithMixedObjects.
@Test
@Parameters(method = "getPartitionRegionTypes")
public void luceneMustIndexFieldsWithMixedObjects(RegionTestableType regionTestableType) {
SerializableRunnableIF createIndexOnTextAndDataField = getSerializableRunnableIFCreateIndexOnFieldData();
dataStore1.invoke(() -> initDataStore(createIndexOnTextAndDataField, regionTestableType));
dataStore2.invoke(() -> initDataStore(createIndexOnTextAndDataField, regionTestableType));
accessor.invoke(() -> initDataStore(createIndexOnTextAndDataField, regionTestableType));
accessor.invoke(() -> {
Region region = getCache().getRegion(REGION_NAME);
IntStream.range(0, NUM_BUCKETS).forEach(i -> region.put(i, new TestObject("hello world")));
IntStream.range(NUM_BUCKETS, 2 * NUM_BUCKETS).forEach(i -> region.put(i, new TestObjectWithSameFieldName("hello world")));
IntStream.range(2 * NUM_BUCKETS, 3 * NUM_BUCKETS).forEach(i -> region.put(i, new TestObjectWithNoCommonField("hello world")));
});
waitForFlushBeforeExecuteTextSearch(accessor, 60000);
accessor.invoke(() -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
LuceneQuery luceneQueryForTextField = luceneService.createLuceneQueryFactory().setLimit(100).create(INDEX_NAME, REGION_NAME, "world", "text");
List luceneResults = luceneQueryForTextField.findResults();
validateObjectResultCounts(luceneResults, TestObject.class, NUM_BUCKETS, TestObjectWithSameFieldName.class, NUM_BUCKETS, TestObjectWithNoCommonField.class, 0);
luceneQueryForTextField = luceneService.createLuceneQueryFactory().setLimit(100).create(INDEX_NAME, REGION_NAME, "world", "data");
luceneResults = luceneQueryForTextField.findResults();
validateObjectResultCounts(luceneResults, TestObject.class, 0, TestObjectWithSameFieldName.class, 0, TestObjectWithNoCommonField.class, NUM_BUCKETS);
});
}
use of junitparams.Parameters in project geode by apache.
the class MixedObjectIndexDUnitTest method luceneCanIndexFieldsWithSameNameButInDifferentObjects.
@Test
@Parameters(method = "getPartitionRegionTypes")
public void luceneCanIndexFieldsWithSameNameButInDifferentObjects(RegionTestableType regionTestType) {
SerializableRunnableIF createIndex = getSerializableRunnableIFCreateIndexOnFieldText();
dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
accessor.invoke(() -> initDataStore(createIndex, regionTestType));
accessor.invoke(() -> {
Region region = getCache().getRegion(REGION_NAME);
IntStream.range(0, NUM_BUCKETS).forEach(i -> region.put(i, new TestObject("hello world")));
IntStream.range(NUM_BUCKETS, (2 * NUM_BUCKETS)).forEach(i -> region.put(i, new TestObjectWithSameFieldName("hello world 2")));
});
waitForFlushBeforeExecuteTextSearch(accessor, 60000);
accessor.invoke(() -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
LuceneQuery luceneQuery = luceneService.createLuceneQueryFactory().setLimit(100).create(INDEX_NAME, REGION_NAME, "world", "text");
List resultList = luceneQuery.findResults();
int objectType_1_count = 0;
int objectType_2_count = 0;
for (Object luceneResultStruct : resultList) {
if (((LuceneResultStruct) luceneResultStruct).getValue() instanceof TestObject) {
objectType_1_count++;
} else if (((LuceneResultStruct) luceneResultStruct).getValue() instanceof TestObjectWithSameFieldName) {
objectType_2_count++;
}
}
assertEquals(NUM_BUCKETS, objectType_1_count);
assertEquals(NUM_BUCKETS, objectType_2_count);
});
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCreationDUnitTest method verifyMemberWithoutIndexCreatedFirstFails.
@Test
@Parameters({ "PARTITION" })
public void verifyMemberWithoutIndexCreatedFirstFails(RegionTestableType regionType) {
SerializableRunnableIF createIndex1 = () -> {
/* Do nothing */
};
dataStore1.invoke(() -> initDataStore(createIndex1, regionType));
SerializableRunnableIF createIndex2 = getFieldsIndexWithOneField();
dataStore2.invoke(() -> initDataStore(createIndex2, regionType, CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_INDEXES_3));
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCreationDUnitTest method verifyDifferentFieldAnalyzersFails1.
@Test
@Parameters({ "PARTITION" })
public void verifyDifferentFieldAnalyzersFails1(RegionTestableType regionType) {
SerializableRunnableIF createIndex1 = getAnalyzersIndexWithOneField(StandardAnalyzer.class);
dataStore1.invoke(() -> initDataStore(createIndex1, regionType));
SerializableRunnableIF createIndex2 = getAnalyzersIndexWithOneField(KeywordAnalyzer.class);
dataStore2.invoke(() -> initDataStore(createIndex2, regionType, CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_ANALYZERS_2));
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCreationDUnitTest method verifyThatIndexObjectIsRetrievedWhenPresentInTheSystem.
@Test
@Parameters(method = "parametersForMultipleIndexCreates")
public void verifyThatIndexObjectIsRetrievedWhenPresentInTheSystem(int numberOfIndexes, RegionTestableType regionType) {
SerializableRunnableIF createIndex = getMultipleIndexes(numberOfIndexes);
dataStore1.invoke(() -> initDataStore(createIndex, regionType));
dataStore1.invoke(() -> verifyIndexes(numberOfIndexes));
dataStore2.invoke(() -> initDataStore(createIndex, regionType));
dataStore2.invoke(() -> verifyIndexes(numberOfIndexes));
}
Aggregations