-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(reindex-upload): Fix hex IDs ranges generation for Subject, Class…
…ification and Contribution in Reindex Upload (#710) * fix(reindex): Fix hex IDs ranges generation for subject, classification and contributors to cover values starting from 'f' Closes: MSEARCH-907
- Loading branch information
1 parent
afc034a
commit 5d20850
Showing
4 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/test/java/org/folio/search/service/reindex/RangeGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.folio.search.service.reindex; | ||
|
||
import static org.apache.commons.lang3.StringUtils.repeat; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.tuple; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.folio.spring.testing.type.UnitTest; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
@UnitTest | ||
class RangeGeneratorTest { | ||
|
||
@CsvSource({ | ||
"2,000001d8825cc3beb7e2cee2223565e17b26fac8", | ||
"3,000001d8825cc3beb7e2cee2223565e17b26fac8", | ||
"4,000001d8825cc3beb7e2cee2223565e17b26fac8", | ||
"2,51703becc548d684616abd8ef7286917b7f7922d", | ||
"3,51703becc548d684616abd8ef7286917b7f7922d", | ||
"4,51703becc548d684616abd8ef7286917b7f7922d", | ||
"2,ab7d50afb15f9474bd499cc2e9688c412ae11d48", | ||
"3,ab7d50afb15f9474bd499cc2e9688c412ae11d48", | ||
"4,ab7d50afb15f9474bd499cc2e9688c412ae11d48", | ||
"2,e175fc5b818e1092be59370632c95fe590980f3d", | ||
"3,e175fc5b818e1092be59370632c95fe590980f3d", | ||
"4,e175fc5b818e1092be59370632c95fe590980f3d", | ||
"2,fffffd04267fd060893a57167a54e2ad97432c04", | ||
"3,fffffd04267fd060893a57167a54e2ad97432c04", | ||
"4,fffffd04267fd060893a57167a54e2ad97432c04" | ||
}) | ||
@ParameterizedTest(name = "generate hex ranges for length: {0}, hexValue: {1}") | ||
void shouldGenerateHexRanges(int length, String hexValue) { | ||
var ranges = RangeGenerator.createHexRanges(length); | ||
|
||
assertThat(ranges) | ||
.satisfies(hexRanges -> | ||
assertTrue( | ||
hexRanges.stream() | ||
.anyMatch(range -> hexValue.compareTo(range.lowerBound()) > 0 && hexValue.compareTo(range.upperBound()) < 0) | ||
) | ||
) | ||
.extracting(RangeGenerator.Range::lowerBound, RangeGenerator.Range::upperBound) | ||
.startsWith(tuple(repeat("0", length), repeat("0", length - 1) + "1")) | ||
.endsWith(tuple(repeat("f", length), repeat("x", length))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters