summaryrefslogtreecommitdiffstats
path: root/document/src/test/java/com/yahoo/document/serialization/XmlDocumentWriterTestCase.java
blob: 4e8e73dc6af611170ec4e45ec2e33179b1ce6d56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.serialization;

import com.yahoo.document.DataType;
import com.yahoo.document.Document;
import com.yahoo.document.DocumentType;
import com.yahoo.document.Field;
import com.yahoo.document.datatypes.PredicateFieldValue;
import org.junit.Test;
import org.mockito.Mockito;

/**
 * @author Simon Thoresen Hult
 */
public class XmlDocumentWriterTestCase {

    @Test
    public void requireThatPredicateFieldValuesAreSerializedAsString() {
        DocumentType docType = new DocumentType("my_type");
        Field field = new Field("my_predicate", DataType.PREDICATE);
        docType.addField(field);
        Document doc = new Document(docType, "id:ns:my_type::");
        PredicateFieldValue predicate = Mockito.mock(PredicateFieldValue.class);
        doc.setFieldValue("my_predicate", predicate);

        new XmlDocumentWriter().write(doc);
        Mockito.verify(predicate, Mockito.times(1)).printXml(Mockito.any(XmlStream.class));
    }
}