@@ -118,61 +118,94 @@ public void testValidateRemoteInputWithTitanMultiModalRemoteSchema() throws IOEx
118118
119119 @ Test
120120 public void testProcessRemoteInferenceInputDataSetParametersValueNoParameters () throws IOException {
121+ String schema = "{\" type\" : \" object\" ,\" properties\" : {}}" ;
121122 String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true}" ;
122- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
123+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
123124 assertEquals (json , processedJson );
124125 }
125126
126127 @ Test
127128 public void testProcessRemoteInferenceInputDataSetInvalidJson () {
129+ String schema = "{\" type\" : \" object\" ,\" properties\" : {}}" ;
128130 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 ));
130132 }
131133
132134 @ Test
133135 public void testProcessRemoteInferenceInputDataSetEmptyParameters () throws IOException {
136+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" }}}" ;
134137 String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{}}" ;
135- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
138+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
136139 assertEquals (json , processedJson );
137140 }
138141
139142 @ Test
140143 public void testProcessRemoteInferenceInputDataSetParametersValueParametersWrongType () throws IOException {
144+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" array\" }}}" ;
141145 String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :[\" Hello\" ,\" world\" ]}" ;
142- String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json );
146+ String processedJson = MLNodeUtils .processRemoteInferenceInputDataSetParametersValue (json , schema );
143147 assertEquals (json , processedJson );
144148 }
145149
146150 @ Test
147151 public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersProcessArray () throws IOException {
152+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" ,\" properties\" : {"
153+ + "\" texts\" : {\" type\" : \" array\" ,\" items\" : {\" type\" : \" string\" }}"
154+ + "}}}}" ;
148155 String json = "{\" key1\" :\" foo\" ,\" key2\" :123,\" key3\" :true,\" parameters\" :{\" texts\" :\" [\\ \" Hello\\ \" ,\\ \" world\\ \" ]\" }}" ;
149156 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 );
151158 assertEquals (expectedJson , processedJson );
152159 }
153160
154161 @ Test
155162 public void testProcessRemoteInferenceInputDataSetParametersValueWithParametersProcessObject () throws IOException {
163+ String schema = "{\" type\" : \" object\" ,\" properties\" : {\" parameters\" : {\" type\" : \" object\" ,\" properties\" : {"
164+ + "\" messages\" : {\" type\" : \" object\" }"
165+ + "}}}}" ;
156166 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\\ \" }}\" }}" ;
158168 String expectedJson =
159169 "{\" 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 );
161171 assertEquals (expectedJson , processedJson );
162172 }
163173
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+
164186 @ Test
165187 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+ + "}}}}" ;
166193 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 );
168195 assertEquals (json , processedJson );
169196 }
170197
171198 @ Test
172199 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+ + "}}}}" ;
173206 String json =
174207 "{\" 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 );
176209 assertEquals (json , processedJson );
177210 }
178211}
0 commit comments