From 27832196641359bb58911933ee58c43fcf7d39ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Thu, 30 Sep 2021 11:51:38 +0200 Subject: [PATCH] HSEARCH-4331 Make DocumentIdDefaultBridgeBaseIT#indexing work even when there are multiple values that are equal This can happen with JavaUtilDatePropertyTypeDescriptor in particular: we test different dates representing the same instant (thus equal according to equals()) but with a different type (java.util.Date and java.sql.Date). --- .../definition/DocumentIdDefaultBridgeBaseIT.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java index 9af7e36a14f..1f4d32e6be7 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java @@ -94,17 +94,14 @@ public void setup() { @Test public void indexing() { - try ( SearchSession session = mapping.createSession() ) { - for ( I entityIdentifierValue : typeDescriptor.values().entityModelValues ) { + Iterator documentIdentifierIterator = typeDescriptor.values().documentIdentifierValues.iterator(); + for ( I entityIdentifierValue : typeDescriptor.values().entityModelValues ) { + try ( SearchSession session = mapping.createSession() ) { Object entity = expectations.instantiateTypeWithIdentifierBridge1( entityIdentifierValue ); session.indexingPlan().add( entity ); - } - BackendMock.DocumentWorkCallListContext expectationSetter = backendMock.expectWorks( - DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME - ); - for ( String expectedDocumentIdentifierValue : typeDescriptor.values().documentIdentifierValues ) { - expectationSetter.add( expectedDocumentIdentifierValue, b -> { } ); + backendMock.expectWorks( DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME ) + .add( documentIdentifierIterator.next(), b -> { } ); } } backendMock.verifyExpectationsMet();