forked from opensearch-project/opensearch-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix integer overflow for remaining index stats (opensearch-project#960)
- Loading branch information
Showing
3 changed files
with
72 additions
and
30 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
39 changes: 39 additions & 0 deletions
39
java-client/src/test/java/org/opensearch/client/opensearch/_types/QueryCacheStatsTest.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,39 @@ | ||
package org.opensearch.client.opensearch._types; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import jakarta.json.stream.JsonParser; | ||
import java.io.StringReader; | ||
import org.junit.Test; | ||
import org.opensearch.client.json.jackson.JacksonJsonpMapper; | ||
|
||
public class QueryCacheStatsTest { | ||
|
||
@Test | ||
public void testLongSerialization() { | ||
QueryCacheStats expected = new QueryCacheStats.Builder().cacheCount(2757938871l) | ||
.cacheSize(1757938872l) | ||
.evictions(3757938873l) | ||
.hitCount(4757938874l) | ||
.memorySizeInBytes(5757938875l) | ||
.missCount(6757938876l) | ||
.totalCount(7757938877l) | ||
.build(); | ||
|
||
String jsonString = "{\"cache_count\": 2757938871, \"cache_size\": 1757938872, \"evictions\":" | ||
+ " 3757938873, \"hit_count\": 4757938874, \"memory_size_in_bytes\": 5757938875, \"miss_count\":" | ||
+ " 6757938876, \"total_count\": 7757938877}"; | ||
|
||
StringReader reader = new StringReader(jsonString); | ||
JacksonJsonpMapper mapper = new JacksonJsonpMapper(); | ||
JsonParser parser = mapper.jsonProvider().createParser(reader); | ||
QueryCacheStats actual = QueryCacheStats._DESERIALIZER.deserialize(parser, mapper); | ||
assertEquals(expected.hitCount(), actual.hitCount()); | ||
assertEquals(expected.memorySizeInBytes(), actual.memorySizeInBytes()); | ||
assertEquals(expected.missCount(), actual.missCount()); | ||
assertEquals(expected.cacheCount(), actual.cacheCount()); | ||
assertEquals(expected.totalCount(), actual.totalCount()); | ||
assertEquals(expected.cacheSize(), actual.cacheSize()); | ||
assertEquals(expected.evictions(), actual.evictions()); | ||
} | ||
} |