Skip to content

Commit

Permalink
fix missed test
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
  • Loading branch information
nknize committed Jul 31, 2023
1 parent c2efd62 commit b71ac11
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
package org.opensearch.ingest.common;

import org.opensearch.OpenSearchException;
import org.opensearch.OpenSearchParseException;
import org.opensearch.common.unit.ByteSizeUnit;
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.ingest.IngestDocument;
import org.opensearch.ingest.Processor;
import org.opensearch.ingest.RandomDocumentPicks;
import org.hamcrest.CoreMatchers;

import static org.hamcrest.Matchers.equalTo;

public class BytesProcessorTests extends AbstractStringProcessorTestCase<Long> {

private String modifiedInput;
Expand Down Expand Up @@ -101,14 +100,16 @@ public void testMissingUnits() {
assertThat(exception.getMessage(), CoreMatchers.containsString("unit is missing or unrecognized"));
}

public void testFractional() throws Exception {
public void testFractional() {
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, "1.1kb");
Processor processor = newProcessor(fieldName, randomBoolean(), fieldName);
processor.execute(ingestDocument);
assertThat(ingestDocument.getFieldValue(fieldName, expectedResultType()), equalTo(1126L));
assertWarnings(
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [1.1kb] found for setting " + "[Ingest Field]"
OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> processor.execute(ingestDocument));
assertThat(
e.getMessage(),
CoreMatchers.containsString(
"Fractional bytes values have been deprecated since Legacy 6.2. " + "Use non-fractional bytes values instead:"
)
);
}
}

0 comments on commit b71ac11

Please sign in to comment.