3434import static org .hamcrest .Matchers .equalTo ;
3535import static org .hamcrest .Matchers .instanceOf ;
3636import static org .hamcrest .Matchers .not ;
37+ import static org .hamcrest .Matchers .nullValue ;
3738import static org .hamcrest .Matchers .sameInstance ;
3839
3940public class AppendProcessorTests extends ESTestCase {
@@ -84,7 +85,7 @@ public void testAppendValuesToNonExistingList() throws Exception {
8485 values .add (value );
8586 appendProcessor = createAppendProcessor (field , value , null , true , false );
8687 } else {
87- int valuesSize = randomIntBetween (0 , 10 );
88+ int valuesSize = randomIntBetween (1 , 10 );
8889 for (int i = 0 ; i < valuesSize ; i ++) {
8990 values .add (scalar .randomValue ());
9091 }
@@ -108,7 +109,7 @@ public void testConvertScalarToList() throws Exception {
108109 values .add (value );
109110 appendProcessor = createAppendProcessor (field , value , null , true , false );
110111 } else {
111- int valuesSize = randomIntBetween (0 , 10 );
112+ int valuesSize = randomIntBetween (1 , 10 );
112113 for (int i = 0 ; i < valuesSize ; i ++) {
113114 values .add (scalar .randomValue ());
114115 }
@@ -295,9 +296,13 @@ public void testAppendingToNonExistingListEmptyStringAndEmptyValuesDisallowed()
295296 appendProcessor = createAppendProcessor (field , allValues , null , true , true );
296297 }
297298 appendProcessor .execute (ingestDocument );
298- List <?> list = ingestDocument .getFieldValue (field , List .class );
299+ List <?> list = ingestDocument .getFieldValue (field , List .class , true );
299300 assertThat (list , not (sameInstance (values )));
300- assertThat (list , equalTo (values ));
301+ if (values .isEmpty ()) {
302+ assertThat (list , nullValue ());
303+ } else {
304+ assertThat (list , equalTo (values ));
305+ }
301306 }
302307
303308 public void testCopyFromOtherFieldSimple () throws Exception {
0 commit comments