Search in sources :

Example 1 with ValueWrapper

use of org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper in project hibernate-search by hibernate.

the class FieldSearchProjectionTypeCheckingAndConversionIT method multiIndex_withCompatibleIndex_projectionConverterEnabled.

@Test
public void multiIndex_withCompatibleIndex_projectionConverterEnabled() {
    StubMappingScope scope = mainIndex.createScope(compatibleIndex);
    String fieldPath = getFieldWithConverterPath();
    assertThatQuery(scope.query().select(f -> f.field(fieldPath, ValueWrapper.class)).where(f -> f.matchAll()).toQuery()).hasHitsAnyOrder(new ValueWrapper<>(getFieldValue(1)), new ValueWrapper<>(getFieldValue(2)), new ValueWrapper<>(getFieldValue(3)), // Empty document
    new ValueWrapper<>(null), // From the "compatible" index
    new ValueWrapper<>(getFieldValue(1)));
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) SimpleFieldModelsByType(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference) BeforeClass(org.junit.BeforeClass) SimpleFieldModel(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel) Searchable(org.hibernate.search.engine.backend.types.Searchable) RunWith(org.junit.runner.RunWith) FromDocumentValueConvertContext(org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) ObjectStructure(org.hibernate.search.engine.backend.types.ObjectStructure) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) FromDocumentValueConverter(org.hibernate.search.engine.backend.types.converter.FromDocumentValueConverter) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) ValueConvert(org.hibernate.search.engine.search.common.ValueConvert) ClassRule(org.junit.ClassRule) DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) Parameterized(org.junit.runners.Parameterized) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) IndexSchemaObjectField(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) Aggregable(org.hibernate.search.engine.backend.types.Aggregable) StandardIndexFieldTypeOptionsStep(org.hibernate.search.engine.backend.types.dsl.StandardIndexFieldTypeOptionsStep) Projectable(org.hibernate.search.engine.backend.types.Projectable) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) Test(org.junit.Test)

Example 2 with ValueWrapper

use of org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper in project hibernate-search by hibernate.

the class FieldSearchProjectionTypeCheckingAndConversionIT method multiIndex_withMissingFieldIndex_projectionConverterEnabled.

@Test
@TestForIssue(jiraKey = "HSEARCH-4173")
public void multiIndex_withMissingFieldIndex_projectionConverterEnabled() {
    StubMappingScope scope = mainIndex.createScope(missingFieldIndex);
    String fieldPath = getFieldWithConverterPath();
    assertThatQuery(scope.query().select(f -> f.field(fieldPath, ValueWrapper.class)).where(f -> f.matchAll()).toQuery()).hasHitsAnyOrder(new ValueWrapper<F>(getFieldValue(1)), new ValueWrapper<F>(getFieldValue(2)), new ValueWrapper<F>(getFieldValue(3)), // Empty document
    new ValueWrapper<F>(null), // From the "missing field" index
    new ValueWrapper<F>(null));
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) SimpleFieldModelsByType(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference) BeforeClass(org.junit.BeforeClass) SimpleFieldModel(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel) Searchable(org.hibernate.search.engine.backend.types.Searchable) RunWith(org.junit.runner.RunWith) FromDocumentValueConvertContext(org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) ObjectStructure(org.hibernate.search.engine.backend.types.ObjectStructure) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) FromDocumentValueConverter(org.hibernate.search.engine.backend.types.converter.FromDocumentValueConverter) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) ValueConvert(org.hibernate.search.engine.search.common.ValueConvert) ClassRule(org.junit.ClassRule) DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) Parameterized(org.junit.runners.Parameterized) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) IndexSchemaObjectField(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) Aggregable(org.hibernate.search.engine.backend.types.Aggregable) StandardIndexFieldTypeOptionsStep(org.hibernate.search.engine.backend.types.dsl.StandardIndexFieldTypeOptionsStep) Projectable(org.hibernate.search.engine.backend.types.Projectable) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) Test(org.junit.Test) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue)

Example 3 with ValueWrapper

use of org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper in project hibernate-search by hibernate.

the class FieldSortTypeCheckingAndConversionIT method multiIndex_withRawFieldCompatibleIndex_dslConverterEnabled.

@Test
public void multiIndex_withRawFieldCompatibleIndex_dslConverterEnabled() {
    StubMappingScope scope = mainIndex.createScope(rawFieldCompatibleIndex);
    String fieldPath = getFieldPath();
    assertThatThrownBy(() -> {
        matchAllQuery(f -> f.field(fieldPath).asc().missing().use(new ValueWrapper<>(getSingleValueForMissingUse(BEFORE_DOCUMENT_1_ORDINAL))), scope);
    }).isInstanceOf(SearchException.class).hasMessageContainingAll("Inconsistent configuration for field '" + fieldPath + "' in a search query across multiple indexes", "Attribute 'dslConverter' differs", " vs. ").satisfies(FailureReportUtils.hasContext(EventContexts.fromIndexNames(mainIndex.name(), rawFieldCompatibleIndex.name())));
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) SimpleFieldModelsByType(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference) BeforeClass(org.junit.BeforeClass) SimpleFieldModel(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel) Searchable(org.hibernate.search.engine.backend.types.Searchable) RunWith(org.junit.runner.RunWith) SortFinalStep(org.hibernate.search.engine.search.sort.dsl.SortFinalStep) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) SearchSortFactory(org.hibernate.search.engine.search.sort.dsl.SearchSortFactory) Function(java.util.function.Function) ObjectStructure(org.hibernate.search.engine.backend.types.ObjectStructure) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) Locale(java.util.Locale) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) ValueConvert(org.hibernate.search.engine.search.common.ValueConvert) FailureReportUtils(org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils) ClassRule(org.junit.ClassRule) DocumentReference(org.hibernate.search.engine.backend.common.DocumentReference) DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) Parameterized(org.junit.runners.Parameterized) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) EventContexts(org.hibernate.search.engine.reporting.spi.EventContexts) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) IndexSchemaObjectField(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField) InvalidType(org.hibernate.search.integrationtest.backend.tck.testsupport.util.InvalidType) NormalizedStringFieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor) Consumer(java.util.function.Consumer) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) Aggregable(org.hibernate.search.engine.backend.types.Aggregable) StandardIndexFieldTypeOptionsStep(org.hibernate.search.engine.backend.types.dsl.StandardIndexFieldTypeOptionsStep) SearchQuery(org.hibernate.search.engine.search.query.SearchQuery) Assume.assumeTrue(org.junit.Assume.assumeTrue) Projectable(org.hibernate.search.engine.backend.types.Projectable) TckConfiguration(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) Test(org.junit.Test)

Example 4 with ValueWrapper

use of org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper in project hibernate-search by hibernate.

the class FieldProjectionTypeCheckingAndConversionIT method multiIndex_withMissingFieldIndex_projectionConverterEnabled.

@Test
@TestForIssue(jiraKey = "HSEARCH-4173")
public void multiIndex_withMissingFieldIndex_projectionConverterEnabled() {
    StubMappingScope scope = mainIndex.createScope(missingFieldIndex);
    String fieldPath = getFieldWithConverterPath();
    assertThatQuery(scope.query().select(f -> f.field(fieldPath, ValueWrapper.class)).where(f -> f.matchAll()).toQuery()).hasHitsAnyOrder(new ValueWrapper<F>(getFieldValue(1)), new ValueWrapper<F>(getFieldValue(2)), new ValueWrapper<F>(getFieldValue(3)), // Empty document
    new ValueWrapper<F>(null), // From the "missing field" index
    new ValueWrapper<F>(null));
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) SimpleFieldModelsByType(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference) BeforeClass(org.junit.BeforeClass) SimpleFieldModel(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel) Assume.assumeFalse(org.junit.Assume.assumeFalse) Searchable(org.hibernate.search.engine.backend.types.Searchable) RunWith(org.junit.runner.RunWith) FromDocumentValueConvertContext(org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) ObjectStructure(org.hibernate.search.engine.backend.types.ObjectStructure) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) FromDocumentValueConverter(org.hibernate.search.engine.backend.types.converter.FromDocumentValueConverter) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) ValueConvert(org.hibernate.search.engine.search.common.ValueConvert) ClassRule(org.junit.ClassRule) DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) Parameterized(org.junit.runners.Parameterized) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) IndexSchemaObjectField(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) Aggregable(org.hibernate.search.engine.backend.types.Aggregable) StandardIndexFieldTypeOptionsStep(org.hibernate.search.engine.backend.types.dsl.StandardIndexFieldTypeOptionsStep) Projectable(org.hibernate.search.engine.backend.types.Projectable) TckConfiguration(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) Test(org.junit.Test) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue)

Example 5 with ValueWrapper

use of org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper in project hibernate-search by hibernate.

the class FieldSearchSortTypeCheckingAndConversionIT method multiIndex_withRawFieldCompatibleIndex_dslConverterEnabled.

@Test
public void multiIndex_withRawFieldCompatibleIndex_dslConverterEnabled() {
    StubMappingScope scope = mainIndex.createScope(rawFieldCompatibleIndex);
    String fieldPath = getFieldPath();
    assertThatThrownBy(() -> {
        matchAllQuery(f -> f.field(fieldPath).asc().missing().use(new ValueWrapper<>(getSingleValueForMissingUse(BEFORE_DOCUMENT_1_ORDINAL))), scope);
    }).isInstanceOf(SearchException.class).hasMessageContainingAll("Inconsistent configuration for field '" + fieldPath + "' in a search query across multiple indexes", "Attribute 'dslConverter' differs", " vs. ").satisfies(FailureReportUtils.hasContext(EventContexts.fromIndexNames(mainIndex.name(), rawFieldCompatibleIndex.name())));
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) SimpleFieldModelsByType(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference) BeforeClass(org.junit.BeforeClass) SimpleFieldModel(org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel) Searchable(org.hibernate.search.engine.backend.types.Searchable) RunWith(org.junit.runner.RunWith) SortFinalStep(org.hibernate.search.engine.search.sort.dsl.SortFinalStep) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) SearchSortFactory(org.hibernate.search.engine.search.sort.dsl.SearchSortFactory) Function(java.util.function.Function) ObjectStructure(org.hibernate.search.engine.backend.types.ObjectStructure) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) Locale(java.util.Locale) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) ValueConvert(org.hibernate.search.engine.search.common.ValueConvert) FailureReportUtils(org.hibernate.search.util.impl.integrationtest.common.FailureReportUtils) ClassRule(org.junit.ClassRule) DocumentReference(org.hibernate.search.engine.backend.common.DocumentReference) DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) Parameterized(org.junit.runners.Parameterized) ValueWrapper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) EventContexts(org.hibernate.search.engine.reporting.spi.EventContexts) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) IndexSchemaObjectField(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField) InvalidType(org.hibernate.search.integrationtest.backend.tck.testsupport.util.InvalidType) NormalizedStringFieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor) Consumer(java.util.function.Consumer) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) Aggregable(org.hibernate.search.engine.backend.types.Aggregable) StandardIndexFieldTypeOptionsStep(org.hibernate.search.engine.backend.types.dsl.StandardIndexFieldTypeOptionsStep) SearchQuery(org.hibernate.search.engine.search.query.SearchQuery) Assume.assumeTrue(org.junit.Assume.assumeTrue) Projectable(org.hibernate.search.engine.backend.types.Projectable) TckConfiguration(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)11 List (java.util.List)11 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)11 DocumentElement (org.hibernate.search.engine.backend.document.DocumentElement)11 IndexObjectFieldReference (org.hibernate.search.engine.backend.document.IndexObjectFieldReference)11 IndexSchemaElement (org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement)11 IndexSchemaObjectField (org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField)11 Aggregable (org.hibernate.search.engine.backend.types.Aggregable)11 ObjectStructure (org.hibernate.search.engine.backend.types.ObjectStructure)11 Projectable (org.hibernate.search.engine.backend.types.Projectable)11 Sortable (org.hibernate.search.engine.backend.types.Sortable)11 ValueConvert (org.hibernate.search.engine.search.common.ValueConvert)11 ValueWrapper (org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper)11 SearchSetupHelper (org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper)11 SearchException (org.hibernate.search.util.common.SearchException)11 SearchResultAssert.assertThatQuery (org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery)11 SimpleMappedIndex (org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex)11 StubMappingScope (org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope)11 TestForIssue (org.hibernate.search.util.impl.test.annotation.TestForIssue)11 Test (org.junit.Test)11