Skip to content

Commit

Permalink
Fix expected string for get model response tests (opensearch-project#…
Browse files Browse the repository at this point in the history
…2062)

Signed-off-by: Ryan Bogan <rbogan@amazon.com>
  • Loading branch information
ryanbogan authored Sep 6, 2024
1 parent 71532c2 commit 7bf52ac
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ public void testXContent() throws IOException {
byte[] testModelBlob = "hello".getBytes();
Model model = new Model(getModelMetadata(ModelState.CREATED), testModelBlob, modelId);
GetModelResponse getModelResponse = new GetModelResponse(model);
String expectedResponseString =
"{\"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\"}";
String expectedResponseString = String.format(
"{\"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\"}",
Version.CURRENT.toString()
);
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder();
getModelResponse.toXContent(xContentBuilder, null);
assertEquals(expectedResponseString, xContentBuilder.toString());
Expand All @@ -90,8 +92,10 @@ public void testXContentWithNoModelBlob() throws IOException {
String modelId = "test-model";
Model model = new Model(getModelMetadata(ModelState.FAILED), null, modelId);
GetModelResponse getModelResponse = new GetModelResponse(model);
String expectedResponseString =
"{\"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\"}";
String expectedResponseString = String.format(
"{\"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\"}",
Version.CURRENT.toString()
);
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder();
getModelResponse.toXContent(xContentBuilder, null);
assertEquals(expectedResponseString, xContentBuilder.toString());
Expand Down

0 comments on commit 7bf52ac

Please sign in to comment.