@@ -118,61 +118,94 @@ public void testValidateRemoteInputWithTitanMultiModalRemoteSchema() throws IOEx
118
118
119
119
@ Test
120
120
public void testProcessRemoteInferenceInputDataSetParametersValueNoParameters () throws IOException {
121
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {}}" ;
121
122
String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true}" ;
122
- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
123
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
123
124
assertEquals (json , processedJson );
124
125
}
125
126
126
127
@ Test
127
128
public void testProcessRemoteInferenceInputDataSetInvalidJson () {
129
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {}}" ;
128
130
String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" a\" }}" ;
129
- assertThrows (JsonParseException .class , () -> MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json ));
131
+ assertThrows (JsonParseException .class , () -> MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema ));
130
132
}
131
133
132
134
@ Test
133
135
public void testProcessRemoteInferenceInputDataSetEmptyParameters () throws IOException {
136
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" }}}" ;
134
137
String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{}}" ;
135
- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
138
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
136
139
assertEquals (json , processedJson );
137
140
}
138
141
139
142
@ Test
140
143
public void testProcessRemoteInferenceInputDataSetParametersValueParametersWrongType () throws IOException {
144
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" array\" }}}" ;
141
145
String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :[\" Hello\" ,\" world\" ]}" ;
142
- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
146
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
143
147
assertEquals (json , processedJson );
144
148
}
145
149
146
150
@ Test
147
151
public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersProcessArray () throws IOException {
152
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" ,\" properties\" : {"
153
+ + "\" texts\" : {\" type\" : \" array\" ,\" items\" : {\" type\" : \" string\" }}"
154
+ + "}}}}" ;
148
155
String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" texts\" :\" [\\ \" Hello\\ \" ,\\ \" world\\ \" ]\" }}" ;
149
156
String expectedJson = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" texts\" :[\" Hello\" ,\" world\" ]}}" ;
150
- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
157
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
151
158
assertEquals (expectedJson , processedJson );
152
159
}
153
160
154
161
@ Test
155
162
public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersProcessObject () throws IOException {
163
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" ,\" properties\" : {"
164
+ + "\" messages\" : {\" type\" : \" object\" }"
165
+ + "}}}}" ;
156
166
String json =
157
- "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" messages\" :\" {\\ \" role\\ \" :\\ \" system\\ \" ,\\ \" foo\\ \" :\\ \" {\\ \\ \\ \" a\\ \\ \\ \" : \\ \\ \\ \" b\\ \\ \\ \" }\\ \" ,\\ \" content\\ \" :{\\ \" a\\ \" :\\ \" b\\ \" }}\" }}} " ;
167
+ "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" messages\" :\" {\\ \" role\\ \" :\\ \" system\\ \" ,\\ \" foo\\ \" :\\ \" {\\ \\ \\ \" a\\ \\ \\ \" : \\ \\ \\ \" b\\ \\ \\ \" }\\ \" ,\\ \" content\\ \" :{\\ \" a\\ \" :\\ \" b\\ \" }}\" }}" ;
158
168
String expectedJson =
159
169
"{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" messages\" :{\" role\" :\" system\" ,\" foo\" :\" {\\ \" a\\ \" : \\ \" b\\ \" }\" ,\" content\" :{\" a\" :\" b\" }}}}" ;
160
- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
170
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
161
171
assertEquals (expectedJson , processedJson );
162
172
}
163
173
174
+ @ Test
175
+ public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersQuotedNumber () throws IOException {
176
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" ,\" properties\" : {"
177
+ + "\" key1\" : {\" type\" : \" string\" },"
178
+ + "\" key2\" : {\" type\" : \" integer\" },"
179
+ + "\" key3\" : {\" type\" : \" boolean\" }"
180
+ + "}}}}" ;
181
+ String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" key1\" :\" 123\" ,\" key2\" :123,\" key3\" :true}}" ;
182
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
183
+ assertEquals (json , processedJson );
184
+ }
185
+
164
186
@ Test
165
187
public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersNoProcess () throws IOException {
188
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" ,\" properties\" : {"
189
+ + "\" key1\" : {\" type\" : \" string\" },"
190
+ + "\" key2\" : {\" type\" : \" integer\" },"
191
+ + "\" key3\" : {\" type\" : \" boolean\" }"
192
+ + "}}}}" ;
166
193
String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true}}" ;
167
- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
194
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
168
195
assertEquals (json , processedJson );
169
196
}
170
197
171
198
@ Test
172
199
public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersInvalidJson () throws IOException {
200
+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" ,\" properties\" : {"
201
+ + "\" key1\" : {\" type\" : \" string\" },"
202
+ + "\" key2\" : {\" type\" : \" integer\" },"
203
+ + "\" key3\" : {\" type\" : \" boolean\" },"
204
+ + "\" texts\" : {\" type\" : \" array\" }"
205
+ + "}}}}" ;
173
206
String json =
174
207
"{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" texts\" :\" [\\ \" Hello\\ \" ,\\ \" world\\ \" \" }}" ;
175
- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
208
+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
176
209
assertEquals (json , processedJson );
177
210
}
178
211
}
0 commit comments