Skip to content

Commit 304a4b7

Browse files
committed
refactor(model): bind isIndexing via accessor method to prevent duplicate Jackson property
1 parent 6ace6fc commit 304a4b7

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

‎src/main/java/com/meilisearch/sdk/model/IndexStats.java‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,14 @@
1414
@Getter
1515
@Setter
1616
public class IndexStats {
17-
@JsonProperty("numberOfDocuments")
1817
protected long numberOfDocuments;
19-
20-
@JsonProperty("isIndexing")
2118
protected boolean isIndexing;
22-
23-
@JsonProperty("fieldDistribution")
2419
protected Map<String, Integer> fieldDistribution;
25-
26-
@JsonProperty("rawDocumentDbSize")
2720
protected long rawDocumentDbSize;
28-
29-
@JsonProperty("avgDocumentSize")
3021
protected long avgDocumentSize;
31-
32-
@JsonProperty("numberOfEmbeddedDocuments")
3322
protected long numberOfEmbeddedDocuments;
34-
35-
@JsonProperty("numberOfEmbeddings")
3623
protected long numberOfEmbeddings;
37-
38-
@JsonProperty("indexSize")
3924
protected long indexSize;
40-
41-
@JsonProperty("usedIndexSize")
4225
protected long usedIndexSize;
4326

4427
public IndexStats() {}
@@ -83,4 +66,9 @@ public IndexStats(
8366
this.indexSize = indexSize;
8467
this.usedIndexSize = usedIndexSize;
8568
}
69+
70+
@JsonProperty("isIndexing")
71+
public boolean isIndexing() {
72+
return isIndexing;
73+
}
8674
}

‎src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,18 @@ void decodeIndexStatsWithIndexSizeAndUsedIndexSize() throws Exception {
192192
assertThat(indexStats.getIndexSize(), is(equalTo(2048L)));
193193
assertThat(indexStats.getUsedIndexSize(), is(equalTo(1500L)));
194194
}
195+
196+
@Test
197+
void serializeIndexStats() throws Exception {
198+
com.meilisearch.sdk.model.IndexStats indexStats =
199+
new com.meilisearch.sdk.model.IndexStats(
200+
10, false, new java.util.HashMap<>(), 1024, 102, 0, 0, 2048, 1500);
201+
202+
String json = classToTest.encode(indexStats);
203+
204+
assertThat(json, org.hamcrest.Matchers.containsString("\"isIndexing\":false"));
205+
assertThat(
206+
json,
207+
org.hamcrest.Matchers.not(org.hamcrest.Matchers.containsString("\"indexing\"")));
208+
}
195209
}

0 commit comments

Comments
 (0)