Skip to content

Commit

Permalink
Add UT for fromActionResponse
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Dec 26, 2023
1 parent b7a7a88 commit 1fdf2e7
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.opensearch.ad.model.ADTaskProfile;
import org.opensearch.cluster.ClusterName;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.core.common.io.stream.StreamInput;

import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -53,4 +54,19 @@ public void testSerializeResponse() throws IOException {
assertEquals(1, response2.getNodes().size());
assertEquals(taskId, response2.getNodes().get(0).getAdTaskProfile().getTaskId());
}

public void testFromActionResponse() throws IOException {
String taskId = randomAlphaOfLength(5);
ADTaskProfile adTaskProfile = new ADTaskProfile();
adTaskProfile.setTaskId(taskId);
Version remoteAdVersion = Version.CURRENT;
ADTaskProfileNodeResponse nodeResponse = new ADTaskProfileNodeResponse(randomDiscoveryNode(), adTaskProfile, remoteAdVersion);

List<ADTaskProfileNodeResponse> nodeResponses = ImmutableList.of(nodeResponse);
ADTaskProfileResponse response = new ADTaskProfileResponse(new ClusterName("test"), nodeResponses, ImmutableList.of());

ADTaskProfileResponse reserializedResponse = ADTaskProfileResponse.fromActionResponse((ActionResponse) response);
assertEquals(1, reserializedResponse.getNodes().size());
assertEquals(taskId, reserializedResponse.getNodes().get(0).getAdTaskProfile().getTaskId());
}
}

0 comments on commit 1fdf2e7

Please sign in to comment.