9
9
import org .junit .Rule ;
10
10
import org .junit .Test ;
11
11
import org .junit .rules .ExpectedException ;
12
- import org .opensearch .common .Strings ;
12
+ import org .opensearch .core . common .Strings ;
13
13
import org .opensearch .common .io .stream .BytesStreamOutput ;
14
14
import org .opensearch .common .io .stream .StreamInput ;
15
15
import org .opensearch .common .xcontent .XContentFactory ;
@@ -173,21 +173,21 @@ public void columnMetas_Success() {
173
173
}
174
174
175
175
@ Test
176
- public void remove_Exception_InputColumnIndexBiggerThanColumensLength (){
176
+ public void remove_Exception_InputColumnIndexBiggerThanColumensLength () {
177
177
exceptionRule .expect (IllegalArgumentException .class );
178
178
exceptionRule .expectMessage ("columnIndex can't be negative or bigger than columns length:4" );
179
179
defaultDataFrame .remove (4 );
180
180
}
181
181
182
182
@ Test
183
- public void remove_Exception_InputColumnIndexNegtiveColumensLength (){
183
+ public void remove_Exception_InputColumnIndexNegtiveColumensLength () {
184
184
exceptionRule .expect (IllegalArgumentException .class );
185
185
exceptionRule .expectMessage ("columnIndex can't be negative or bigger than columns length:4" );
186
186
defaultDataFrame .remove (-1 );
187
187
}
188
188
189
189
@ Test
190
- public void remove_EmptyColumnMeta (){
190
+ public void remove_EmptyColumnMeta () {
191
191
exceptionRule .expect (IllegalArgumentException .class );
192
192
exceptionRule .expectMessage ("columnIndex can't be negative or bigger than columns length:0" );
193
193
DefaultDataFrame dataFrame = new DefaultDataFrame (new ColumnMeta [0 ]);
@@ -196,31 +196,31 @@ public void remove_EmptyColumnMeta(){
196
196
}
197
197
198
198
@ Test
199
- public void remove_Success (){
199
+ public void remove_Success () {
200
200
DataFrame dataFrame = defaultDataFrame .remove (3 );
201
201
assertEquals (3 , dataFrame .columnMetas ().length );
202
202
assertEquals (3 , dataFrame .getRow (0 ).size ());
203
203
}
204
204
205
205
@ Test
206
- public void select_Success (){
207
- DataFrame dataFrame = defaultDataFrame .select (new int []{ 1 , 3 });
206
+ public void select_Success () {
207
+ DataFrame dataFrame = defaultDataFrame .select (new int [] { 1 , 3 });
208
208
assertEquals (2 , dataFrame .columnMetas ().length );
209
209
assertEquals (2 , dataFrame .getRow (0 ).size ());
210
210
}
211
211
212
212
@ Test
213
- public void select_Exception_EmptyInputColumns (){
213
+ public void select_Exception_EmptyInputColumns () {
214
214
exceptionRule .expect (IllegalArgumentException .class );
215
215
exceptionRule .expectMessage ("columns can't be null or empty" );
216
216
defaultDataFrame .select (new int [0 ]);
217
217
}
218
218
219
219
@ Test
220
- public void select_Exception_InvalidColumn (){
220
+ public void select_Exception_InvalidColumn () {
221
221
exceptionRule .expect (IllegalArgumentException .class );
222
222
exceptionRule .expectMessage ("columnIndex can't be negative or bigger than columns length" );
223
- defaultDataFrame .select (new int []{ 5 });
223
+ defaultDataFrame .select (new int [] { 5 });
224
224
}
225
225
226
226
@ Test
@@ -231,43 +231,44 @@ public void testToXContent() throws IOException {
231
231
builder .endObject ();
232
232
233
233
assertNotNull (builder );
234
- String jsonStr = Strings .toString (builder );
234
+ String jsonStr = org . opensearch . common . Strings .toString (builder );
235
235
assertEquals ("{\" column_metas\" :[" +
236
- "{\" name\" :\" c1\" ,\" column_type\" :\" STRING\" }," +
237
- "{\" name\" :\" c2\" ,\" column_type\" :\" INTEGER\" }," +
238
- "{\" name\" :\" c3\" ,\" column_type\" :\" DOUBLE\" }," +
239
- "{\" name\" :\" c4\" ,\" column_type\" :\" BOOLEAN\" }]," +
240
- "\" rows\" :[" +
241
- "{\" values\" :[" +
242
- "{\" column_type\" :\" STRING\" ,\" value\" :\" string\" }," +
243
- "{\" column_type\" :\" INTEGER\" ,\" value\" :1}," +
244
- "{\" column_type\" :\" DOUBLE\" ,\" value\" :2.0}," +
245
- "{\" column_type\" :\" BOOLEAN\" ,\" value\" :true}]}]}" , jsonStr );
236
+ "{\" name\" :\" c1\" ,\" column_type\" :\" STRING\" }," +
237
+ "{\" name\" :\" c2\" ,\" column_type\" :\" INTEGER\" }," +
238
+ "{\" name\" :\" c3\" ,\" column_type\" :\" DOUBLE\" }," +
239
+ "{\" name\" :\" c4\" ,\" column_type\" :\" BOOLEAN\" }]," +
240
+ "\" rows\" :[" +
241
+ "{\" values\" :[" +
242
+ "{\" column_type\" :\" STRING\" ,\" value\" :\" string\" }," +
243
+ "{\" column_type\" :\" INTEGER\" ,\" value\" :1}," +
244
+ "{\" column_type\" :\" DOUBLE\" ,\" value\" :2.0}," +
245
+ "{\" column_type\" :\" BOOLEAN\" ,\" value\" :true}]}]}" , jsonStr );
246
246
}
247
247
248
248
@ Test
249
249
public void testParse_EmptyDataFrame () throws IOException {
250
- ColumnMeta [] columnMetas = new ColumnMeta [] {new ColumnMeta ("test_int" , ColumnType .INTEGER )};
250
+ ColumnMeta [] columnMetas = new ColumnMeta [] { new ColumnMeta ("test_int" , ColumnType .INTEGER ) };
251
251
DefaultDataFrame dataFrame = new DefaultDataFrame (columnMetas );
252
252
TestHelper .testParse (dataFrame , function , true );
253
253
}
254
254
255
255
@ Test
256
256
public void testParse_DataFrame () throws IOException {
257
- ColumnMeta [] columnMetas = new ColumnMeta [] {new ColumnMeta ("test_int" , ColumnType .INTEGER )};
257
+ ColumnMeta [] columnMetas = new ColumnMeta [] { new ColumnMeta ("test_int" , ColumnType .INTEGER ) };
258
258
DefaultDataFrame dataFrame = new DefaultDataFrame (columnMetas );
259
- dataFrame .appendRow (new Integer []{ 1 });
260
- dataFrame .appendRow (new Integer []{ 2 });
259
+ dataFrame .appendRow (new Integer [] { 1 });
260
+ dataFrame .appendRow (new Integer [] { 2 });
261
261
TestHelper .testParse (dataFrame , function , true );
262
262
}
263
263
264
264
@ Test
265
265
public void testParse_WrongExtraField () throws IOException {
266
- ColumnMeta [] columnMetas = new ColumnMeta [] {new ColumnMeta ("test_int" , ColumnType .INTEGER )};
266
+ ColumnMeta [] columnMetas = new ColumnMeta [] { new ColumnMeta ("test_int" , ColumnType .INTEGER ) };
267
267
DefaultDataFrame dataFrame = new DefaultDataFrame (columnMetas );
268
- dataFrame .appendRow (new Integer []{1 });
269
- dataFrame .appendRow (new Integer []{2 });
270
- String jsonStr = "{\" wrong_field\" :{\" test\" :\" abc\" },\" column_metas\" :[{\" name\" :\" test_int\" ,\" column_type\" :" +
268
+ dataFrame .appendRow (new Integer [] { 1 });
269
+ dataFrame .appendRow (new Integer [] { 2 });
270
+ String jsonStr = "{\" wrong_field\" :{\" test\" :\" abc\" },\" column_metas\" :[{\" name\" :\" test_int\" ,\" column_type\" :"
271
+ +
271
272
"\" INTEGER\" }],\" rows\" :[{\" values\" :[{\" column_type\" :\" INTEGER\" ,\" value\" :1}]},{\" values\" :" +
272
273
"[{\" column_type\" :\" INTEGER\" ,\" value\" :2}]}]}" ;
273
274
TestHelper .testParseFromString (dataFrame , jsonStr , function );
0 commit comments