15
15
import java .util .HashSet ;
16
16
import java .util .Set ;
17
17
18
- import com .fasterxml .jackson .core .JsonParseException ;
19
18
import org .junit .Assert ;
20
19
import org .junit .Test ;
21
20
import org .opensearch .Version ;
30
29
import org .opensearch .ml .common .MLTask ;
31
30
import org .opensearch .test .OpenSearchTestCase ;
32
31
32
+ import com .fasterxml .jackson .core .JsonParseException ;
33
+
33
34
public class MLNodeUtilsForTestingTests extends OpenSearchTestCase {
34
35
35
36
public void testIsMLNode () {
@@ -107,11 +108,11 @@ public void testValidateEmbeddingInputWithTitanMultiModalRemoteSchema() throws I
107
108
public void testValidateRemoteInputWithTitanMultiModalRemoteSchema () throws IOException {
108
109
String schema = BEDROCK_TITAN_EMBED_MULTI_MODAL_V1_MODEL_INTERFACE .get ("input" );
109
110
String json = "{\n "
110
- + " \" parameters\" : {\n "
111
- + " \" inputText\" : \" Say this is a test\" ,\n "
112
- + " \" inputImage\" : \" /9jk=\" \n "
113
- + " }\n "
114
- + "}" ;
111
+ + " \" parameters\" : {\n "
112
+ + " \" inputText\" : \" Say this is a test\" ,\n "
113
+ + " \" inputImage\" : \" /9jk=\" \n "
114
+ + " }\n "
115
+ + "}" ;
115
116
MLNodeUtilsForTesting .validateSchema (schema , json );
116
117
}
117
118
@@ -153,9 +154,9 @@ public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersP
153
154
@ Test
154
155
public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersProcessObject () throws IOException {
155
156
String json =
156
- "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" messages\" :\" {\\ \" role\\ \" :\\ \" system\\ \" ,\\ \" foo\\ \" :\\ \" {\\ \\ \\ \" a\\ \\ \\ \" : \\ \\ \\ \" b\\ \\ \\ \" }\\ \" ,\\ \" content\\ \" :{\\ \" a\\ \" :\\ \" b\\ \" }}\" }}}" ;
157
+ "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" messages\" :\" {\\ \" role\\ \" :\\ \" system\\ \" ,\\ \" foo\\ \" :\\ \" {\\ \\ \\ \" a\\ \\ \\ \" : \\ \\ \\ \" b\\ \\ \\ \" }\\ \" ,\\ \" content\\ \" :{\\ \" a\\ \" :\\ \" b\\ \" }}\" }}}" ;
157
158
String expectedJson =
158
- "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" messages\" :{\" role\" :\" system\" ,\" foo\" :\" {\\ \" a\\ \" : \\ \" b\\ \" }\" ,\" content\" :{\" a\" :\" b\" }}}}" ;
159
+ "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" messages\" :{\" role\" :\" system\" ,\" foo\" :\" {\\ \" a\\ \" : \\ \" b\\ \" }\" ,\" content\" :{\" a\" :\" b\" }}}}" ;
159
160
String processedJson = MLNodeUtilsForTesting .processRemoteInferenceInputDataSetParametersValue (json );
160
161
assertEquals (expectedJson , processedJson );
161
162
}
@@ -170,7 +171,7 @@ public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersN
170
171
@ Test
171
172
public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersInvalidJson () throws IOException {
172
173
String json =
173
- "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" texts\" :\" [\\ \" Hello\\ \" ,\\ \" world\\ \" \" }}" ;
174
+ "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" texts\" :\" [\\ \" Hello\\ \" ,\\ \" world\\ \" \" }}" ;
174
175
String processedJson = MLNodeUtilsForTesting .processRemoteInferenceInputDataSetParametersValue (json );
175
176
assertEquals (json , processedJson );
176
177
}
0 commit comments