Skip to content

Commit

Permalink
fix: test cases with bwc
Browse files Browse the repository at this point in the history
Signed-off-by: Pavan Yekbote <[email protected]>
  • Loading branch information
pyek-bot committed Oct 30, 2024
1 parent 3fe76f3 commit 84f808c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class GenerativeQAParameters implements Writeable, ToXContentObject {

public static final int SIZE_NULL_VALUE = -1;

private static final Version MINIMAL_SUPPORTED_VERSION_FOR_PROMPT_AND_INSTRUCTIONS = CommonValue.VERSION_2_13_0;
public static final Version MINIMAL_SUPPORTED_VERSION_FOR_PROMPT_AND_INSTRUCTIONS = CommonValue.VERSION_2_13_0;

@Setter
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.opensearch.core.xcontent.ToXContent.EMPTY_PARAMS;
import static org.opensearch.ml.common.CommonValue.VERSION_2_16_0;

import java.io.EOFException;
import java.io.IOException;
import java.util.Collections;

import org.junit.Assert;
import org.opensearch.Version;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.XContentType;
Expand Down Expand Up @@ -105,10 +109,17 @@ public void testMiscMethods() throws IOException {
assertNotEquals(builder1, builder2);
assertNotEquals(builder1.hashCode(), builder2.hashCode());

StreamOutput so = mock(StreamOutput.class);
builder1.writeTo(so);
verify(so, times(5)).writeOptionalString(any());
verify(so, times(1)).writeString(any());
StreamOutput so1 = mock(StreamOutput.class);
when(so1.getVersion()).thenReturn(GenerativeQAParameters.MINIMAL_SUPPORTED_VERSION_FOR_PROMPT_AND_INSTRUCTIONS);
builder1.writeTo(so1);
verify(so1, times(5)).writeOptionalString(any());
verify(so1, times(1)).writeString(any());

StreamOutput so2 = mock(StreamOutput.class);
when(so2.getVersion()).thenReturn(Version.V_2_12_0);
builder1.writeTo(so2);
verify(so2, times(2)).writeOptionalString(any());
verify(so1, times(1)).writeString(any());
}

public void testParse() throws IOException {
Expand Down

0 comments on commit 84f808c

Please sign in to comment.