diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextChunkingProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/TextChunkingProcessorTests.java index b55136ba4..30a443c6c 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextChunkingProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextChunkingProcessorTests.java @@ -103,10 +103,10 @@ private List> createSourceDataListNestedMap() { return List.of(documents, documents); } - private Map createFixedTokenLengthParametersWithMaxChunk(int maxChunkNum) { + private Map createFixedTokenLengthParametersWithMaxChunkLimit(int maxChunkLimit) { Map parameters = new HashMap<>(); parameters.put(FixedTokenLengthChunker.TOKEN_LIMIT_FIELD, 10); - parameters.put(MAX_CHUNK_LIMIT_FIELD, maxChunkNum); + parameters.put(MAX_CHUNK_LIMIT_FIELD, maxChunkLimit); return parameters; } @@ -150,10 +150,10 @@ private TextChunkingProcessor createFixedTokenLengthInstance(Map } @SneakyThrows - private TextChunkingProcessor createFixedTokenLengthInstanceWithMaxChunkNum(Map fieldMap, int maxChunkNum) { + private TextChunkingProcessor createFixedTokenLengthInstanceWithMaxChunkLimit(Map fieldMap, int maxChunkLimit) { Map config = new HashMap<>(); Map algorithmMap = new HashMap<>(); - algorithmMap.put(FixedTokenLengthChunker.ALGORITHM_NAME, createFixedTokenLengthParametersWithMaxChunk(maxChunkNum)); + algorithmMap.put(FixedTokenLengthChunker.ALGORITHM_NAME, createFixedTokenLengthParametersWithMaxChunkLimit(maxChunkLimit)); config.put(FIELD_MAP_FIELD, fieldMap); config.put(ALGORITHM_FIELD, algorithmMap); Map registry = new HashMap<>(); @@ -189,13 +189,13 @@ public void testCreate_whenAlgorithmFieldMissing_thenFail() { } @SneakyThrows - public void testCreate_whenMaxChunkNumInvalidValue_thenFail() { + public void testCreate_whenMaxChunkLimitInvalidValue_thenFail() { Map registry = new HashMap<>(); Map config = new HashMap<>(); Map fieldMap = new HashMap<>(); Map algorithmMap = new HashMap<>(); fieldMap.put(INPUT_FIELD, OUTPUT_FIELD); - algorithmMap.put(FixedTokenLengthChunker.ALGORITHM_NAME, createFixedTokenLengthParametersWithMaxChunk(-2)); + algorithmMap.put(FixedTokenLengthChunker.ALGORITHM_NAME, createFixedTokenLengthParametersWithMaxChunkLimit(-2)); config.put(FIELD_MAP_FIELD, fieldMap); config.put(ALGORITHM_FIELD, algorithmMap); IllegalArgumentException illegalArgumentException = assertThrows( @@ -207,13 +207,13 @@ public void testCreate_whenMaxChunkNumInvalidValue_thenFail() { } @SneakyThrows - public void testCreate_whenMaxChunkNumDisabledValue_thenSucceed() { + public void testCreate_whenMaxChunkLimitDisabledValue_thenSucceed() { Map registry = new HashMap<>(); Map config = new HashMap<>(); Map fieldMap = new HashMap<>(); Map algorithmMap = new HashMap<>(); fieldMap.put(INPUT_FIELD, OUTPUT_FIELD); - algorithmMap.put(FixedTokenLengthChunker.ALGORITHM_NAME, createFixedTokenLengthParametersWithMaxChunk(-1)); + algorithmMap.put(FixedTokenLengthChunker.ALGORITHM_NAME, createFixedTokenLengthParametersWithMaxChunkLimit(-1)); config.put(FIELD_MAP_FIELD, fieldMap); config.put(ALGORITHM_FIELD, algorithmMap); textChunkingProcessorFactory.create(registry, PROCESSOR_TAG, DESCRIPTION, config); @@ -369,8 +369,8 @@ private IngestDocument createIngestDocumentWithSourceData(Object sourceData) { } @SneakyThrows - public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkNum_thenSucceed() { - TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkNum(createStringFieldMap(), 5); + public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkLimit_thenSucceed() { + TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkLimit(createStringFieldMap(), 5); IngestDocument ingestDocument = createIngestDocumentWithSourceData(createSourceDataString()); IngestDocument document = processor.execute(ingestDocument); assert document.getSourceAndMetadata().containsKey(OUTPUT_FIELD); @@ -384,8 +384,8 @@ public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkNum_ } @SneakyThrows - public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkNumTwice_thenSucceed() { - TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkNum(createStringFieldMap(), 5); + public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkLimitTwice_thenSucceed() { + TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkLimit(createStringFieldMap(), 5); for (int i = 0; i < 2; i++) { IngestDocument ingestDocument = createIngestDocumentWithSourceData(createSourceDataString()); IngestDocument document = processor.execute(ingestDocument); @@ -401,8 +401,8 @@ public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkNumT } @SneakyThrows - public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkNumDisabled_thenSucceed() { - TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkNum(createStringFieldMap(), -1); + public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkLimitDisabled_thenSucceed() { + TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkLimit(createStringFieldMap(), -1); IngestDocument ingestDocument = createIngestDocumentWithSourceData(createSourceDataString()); IngestDocument document = processor.execute(ingestDocument); assert document.getSourceAndMetadata().containsKey(OUTPUT_FIELD); @@ -418,7 +418,7 @@ public void testExecute_withFixedTokenLength_andSourceDataStringWithMaxChunkNumD @SneakyThrows public void testExecute_withFixedTokenLength_andSourceDataStringExceedMaxChunkLimit_thenFail() { int maxChunkLimit = 1; - TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkNum(createStringFieldMap(), maxChunkLimit); + TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkLimit(createStringFieldMap(), maxChunkLimit); IngestDocument ingestDocument = createIngestDocumentWithSourceData(createSourceDataString()); IllegalStateException illegalStateException = assertThrows(IllegalStateException.class, () -> processor.execute(ingestDocument)); assert (illegalStateException.getMessage() @@ -433,9 +433,9 @@ public void testExecute_withFixedTokenLength_andSourceDataStringExceedMaxChunkLi } @SneakyThrows - public void testExecute_withFixedTokenLength_andSourceDataListWithMaxChunkLimitExceed_thenFail() { + public void testExecute_withFixedTokenLength_andSourceDataListExceedMaxChunkLimit_thenFail() { int maxChunkLimit = 5; - TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkNum(createStringFieldMap(), maxChunkLimit); + TextChunkingProcessor processor = createFixedTokenLengthInstanceWithMaxChunkLimit(createStringFieldMap(), maxChunkLimit); IngestDocument ingestDocument = createIngestDocumentWithSourceData(createSourceDataListStrings()); IllegalStateException illegalStateException = assertThrows(IllegalStateException.class, () -> processor.execute(ingestDocument)); assert (illegalStateException.getMessage()