// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;

import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.documentmodel.SummaryTransform;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class SummaryConsistencyTestCase {

    @Test
    public void attribute_combiner_transform_is_set_when_source_is_array_of_struct_with_only_struct_field_attributes() throws ParseException {
        String sd = "search structmemorysummary {\n" +
                "  document structmemorysummary {\n" +
                "      struct elem {\n" +
                "        field name type string {}\n" +
                "        field weight type int {}\n" +
                "      }\n" +
                "      field elem_array type array<elem> {\n" +
                "          indexing: summary\n" +
                "          struct-field name {\n" +
                "              indexing: attribute\n" +
                "          }\n" +
                "          struct-field weight {\n" +
                "              indexing: attribute\n" +
                "          }\n" +
                "      }\n" +
                "  }\n" +
                "  document-summary unfiltered {\n" +
                "      summary elem_array_unfiltered type array<elem> {\n" +
                "          source: elem_array\n" +
                "      }\n" +
                "  }\n" +
                "\n" +
                "}";
        Search search = SearchBuilder.createFromString(sd).getSearch();
        assertEquals(SummaryTransform.ATTRIBUTECOMBINER, search.getSummaryField("elem_array_unfiltered").getTransform());
    }
}

@@ -381,16 +381,78 @@
 .Test;%0A%0A
+import static com.yahoo.config.model.test.TestUtil.joinLines;%0A
 import s
@@ -488,16 +488,16 @@
 Equals;%0A
-
 %0Apublic 
@@ -704,16 +704,43 @@
 ing sd =
+ joinLines(%0A               
  %22search
@@ -753,37 +753,34 @@
 tmemorysummary %7B
-%5Cn%22 +
+%22,
 %0A               
@@ -813,21 +813,18 @@
 ummary %7B
-%5Cn%22 +
+%22,
 %0A       
@@ -852,21 +852,18 @@
 t elem %7B
-%5Cn%22 +
+%22,
 %0A       
@@ -905,21 +905,18 @@
 tring %7B%7D
-%5Cn%22 +
+%22,
 %0A       
@@ -956,26 +956,25 @@
 pe int %7B%7D%5Cn%22
- +
+,
 %0A           
@@ -978,37 +978,34 @@
         %22      %7D
-%5Cn%22 +
+%22,
 %0A               
@@ -1039,37 +1039,34 @@
 pe array%3Celem%3E %7B
-%5Cn%22 +
+%22,
 %0A               
@@ -1094,21 +1094,18 @@
  summary
-%5Cn%22 +
+%22,
 %0A       
@@ -1143,21 +1143,18 @@
 d name %7B
-%5Cn%22 +
+%22,
 %0A       
@@ -1188,37 +1188,34 @@
 exing: attribute
-%5Cn%22 +
+%22,
 %0A               
@@ -1219,37 +1219,34 @@
     %22          %7D
-%5Cn%22 +
+%22,
 %0A               
@@ -1278,21 +1278,18 @@
 weight %7B
-%5Cn%22 +
+%22,
 %0A       
@@ -1331,21 +1331,18 @@
 ttribute
-%5Cn%22 +
+%22,
 %0A       
@@ -1358,29 +1358,26 @@
 %22          %7D
-%5Cn%22 +
+%22,
 %0A           
@@ -1381,37 +1381,34 @@
         %22      %7D
-%5Cn%22 +
+%22,
 %0A               
@@ -1404,37 +1404,34 @@
             %22  %7D
-%5Cn%22 +
+%22,
 %0A               
@@ -1463,21 +1463,18 @@
 ltered %7B
-%5Cn%22 +
+%22,
 %0A       
@@ -1537,21 +1537,18 @@
 %3Celem%3E %7B
-%5Cn%22 +
+%22,
 %0A       
@@ -1585,21 +1585,18 @@
 em_array
-%5Cn%22 +
+%22,
 %0A       
@@ -1612,21 +1612,18 @@
 %22      %7D
-%5Cn%22 +
+%22,
 %0A       
@@ -1635,21 +1635,18 @@
     %22  %7D
-%5Cn%22 +
+%22,
 %0A       
@@ -1659,13 +1659,10 @@
    %22
-%5Cn%22 +
+%22,
 %0A   
@@ -1677,16 +1677,26 @@
      %22%7D%22
+%0A        )
 ;%0A      

Use TestUtil.joinLines to simplify generation of multi-line string.