Skip to content

Commit

Permalink
Modify import * in RestMLExecuteActionTests, remove root object wrapp…
Browse files Browse the repository at this point in the history
…er in AnomalyLocalizationOutputTests and LocalSampleCalculatorOutputTest.

Signed-off-by: Nathalie Jonathan <nathhjo@amazon.com>
  • Loading branch information
nathaliellenaa committed Jan 27, 2025
1 parent 750633e commit c2167a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public void testWriteable() throws Exception {
@Test
public void testXContent() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
builder = output.toXContent(builder, null);
builder.endObject();
String json = builder.toString();
XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, null, json);
AnomalyLocalizationOutput newOutput = AnomalyLocalizationOutput.parse(parser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public void setUp() {
@Test
public void toXContent() throws IOException {
XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON);
builder.startObject();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
String jsonStr = builder.toString();
assertEquals("{\"result\":1.0}", jsonStr);
}
Expand All @@ -41,9 +39,7 @@ public void toXContent() throws IOException {
public void toXContent_EmptyOutput() throws IOException {
LocalSampleCalculatorOutput output = LocalSampleCalculatorOutput.builder().build();
XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON);
builder.startObject();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
String jsonStr = builder.toString();
assertEquals("{}", jsonStr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
import static org.opensearch.ml.utils.TestHelper.getMetricsCorrelationRestRequest;

import java.io.IOException;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.mockito.ArgumentCaptor;
Expand Down

0 comments on commit c2167a3

Please sign in to comment.