Skip to content

Commit e111eb0

Browse files
authored
Fix expected string for get model response tests (#2062) (#2064)
Signed-off-by: Ryan Bogan <[email protected]> (cherry picked from commit 7bf52ac)
1 parent 1d2eb47 commit e111eb0

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/test/java/org/opensearch/knn/plugin/transport/GetModelResponseTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ public void testXContent() throws IOException {
7575
byte[] testModelBlob = "hello".getBytes();
7676
Model model = new Model(getModelMetadata(ModelState.CREATED), testModelBlob, modelId);
7777
GetModelResponse getModelResponse = new GetModelResponse(model);
78-
String expectedResponseString =
79-
"{\"model_id\":\"test-model\",\"model_blob\":\"aGVsbG8=\",\"state\":\"created\",\"timestamp\":\"2021-03-27 10:15:30 AM +05:30\",\"description\":\"test model\",\"error\":\"\",\"space_type\":\"l2\",\"dimension\":4,\"engine\":\"nmslib\",\"training_node_assignment\":\"\",\"model_definition\":{\"name\":\"\",\"parameters\":{}},\"data_type\":\"float\",\"model_version\":\"3.0.0\"}";
78+
String expectedResponseString = String.format(
79+
"{\"model_id\":\"test-model\",\"model_blob\":\"aGVsbG8=\",\"state\":\"created\",\"timestamp\":\"2021-03-27 10:15:30 AM +05:30\",\"description\":\"test model\",\"error\":\"\",\"space_type\":\"l2\",\"dimension\":4,\"engine\":\"nmslib\",\"training_node_assignment\":\"\",\"model_definition\":{\"name\":\"\",\"parameters\":{}},\"data_type\":\"float\",\"model_version\":\"%s\"}",
80+
Version.CURRENT.toString()
81+
);
8082
XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON);
8183
getModelResponse.toXContent(xContentBuilder, null);
8284
assertEquals(expectedResponseString, xContentBuilder.toString());
@@ -91,8 +93,10 @@ public void testXContentWithNoModelBlob() throws IOException {
9193
String modelId = "test-model";
9294
Model model = new Model(getModelMetadata(ModelState.FAILED), null, modelId);
9395
GetModelResponse getModelResponse = new GetModelResponse(model);
94-
String expectedResponseString =
95-
"{\"model_id\":\"test-model\",\"model_blob\":\"\",\"state\":\"failed\",\"timestamp\":\"2021-03-27 10:15:30 AM +05:30\",\"description\":\"test model\",\"error\":\"\",\"space_type\":\"l2\",\"dimension\":4,\"engine\":\"nmslib\",\"training_node_assignment\":\"\",\"model_definition\":{\"name\":\"\",\"parameters\":{}},\"data_type\":\"float\",\"model_version\":\"3.0.0\"}";
96+
String expectedResponseString = String.format(
97+
"{\"model_id\":\"test-model\",\"model_blob\":\"\",\"state\":\"failed\",\"timestamp\":\"2021-03-27 10:15:30 AM +05:30\",\"description\":\"test model\",\"error\":\"\",\"space_type\":\"l2\",\"dimension\":4,\"engine\":\"nmslib\",\"training_node_assignment\":\"\",\"model_definition\":{\"name\":\"\",\"parameters\":{}},\"data_type\":\"float\",\"model_version\":\"%s\"}",
98+
Version.CURRENT.toString()
99+
);
96100
XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON);
97101
getModelResponse.toXContent(xContentBuilder, null);
98102
assertEquals(expectedResponseString, xContentBuilder.toString());

0 commit comments

Comments
 (0)