@@ -0,0 +1,2702 @@
+package com.yahoo.searchdefinition.processing;%0A%0Aimport com.yahoo.config.model.test.MockApplicationPackage;%0Aimport com.yahoo.document.DataType;%0Aimport com.yahoo.document.Field;%0Aimport com.yahoo.searchdefinition.DocumentReference;%0Aimport com.yahoo.searchdefinition.Search;%0Aimport com.yahoo.searchdefinition.document.ImportedField;%0Aimport com.yahoo.searchdefinition.document.ImportedFields;%0Aimport com.yahoo.searchdefinition.document.SDDocumentType;%0Aimport com.yahoo.searchdefinition.document.SDField;%0Aimport com.yahoo.vespa.documentmodel.DocumentSummary;%0Aimport com.yahoo.vespa.documentmodel.SummaryField;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0A%0Aimport java.util.Collections;%0A%0A/**%0A * @author bjorncs%0A */%0Apublic class ValidateFieldTypesTest %7B%0A%0A    private static final String IMPORTED_FIELD_NAME = %22imported_myfield%22;%0A    private static final String DOCUMENT_NAME = %22mydoc%22;%0A%0A    @Rule%0A    public final ExpectedException exceptionRule = ExpectedException.none();%0A%0A    @Test%0A    public void throws_exception_if_type_of_document_field_does_not_match_summary_field() %7B%0A        Search search = createDocumentWithImportedFieldInDocumentSummary();%0A        ValidateFieldTypes validator = new ValidateFieldTypes(search, null, null, null);%0A        exceptionRule.expect(IllegalArgumentException.class);%0A        exceptionRule.expectMessage(%0A                %22For search '%22 + DOCUMENT_NAME + %22', field '%22 + IMPORTED_FIELD_NAME + %22': Incompatible types. %22 +%0A                %22Expected int for summary field '%22 + IMPORTED_FIELD_NAME + %22', got string.%22);%0A        validator.process();%0A    %7D%0A%0A    private static Search createDocumentWithImportedFieldInDocumentSummary() %7B%0A        // Create search with a single imported field%0A        Search search = new Search(DOCUMENT_NAME, MockApplicationPackage.createEmpty());%0A        SDDocumentType document = new SDDocumentType(%22mydoc%22, search);%0A        search.addDocument(document);%0A        Search targetDocument = new Search(%22otherdoc%22, MockApplicationPackage.createEmpty());%0A        SDField targetField = new SDField(%22myfield%22, DataType.INT);%0A        DocumentReference documentReference = new DocumentReference(new Field(%22reference_field%22), targetDocument);%0A        ImportedField importedField = new ImportedField(IMPORTED_FIELD_NAME, documentReference, targetField);%0A        search.setImportedFields(new ImportedFields(Collections.singletonMap(IMPORTED_FIELD_NAME, importedField)));%0A%0A        // Create document summary%0A        DocumentSummary summary = new DocumentSummary(%22mysummary%22);%0A        summary.add(new SummaryField(IMPORTED_FIELD_NAME, DataType.STRING));%0A        search.addSummary(summary);%0A        return search;%0A    %7D%0A%7D%0A

Verify validation of types in summary fields