Search in sources :

Example 1 with Date

use of com.yahoo.vespa.documentgen.test.annotation.Date in project vespa by vespa-engine.

the class DocumentGenPluginTest method newBookConcrete.

private Book newBookConcrete(int i) {
    Book book = new Book(new DocumentId("doc:book:" + i));
    book.setAuthor("Melville");
    Date date = new Date().setExacttime(99l);
    book.setTitleSpanTrees(new HashMap<String, SpanTree>());
    SpanTree t = new SpanTree().annotate(date);
    book.titleSpanTrees().put(t.getName(), t);
    book.setTitle("Moby Dick");
    book.setYear(1851);
    // .setAl1(myAs1));
    book.setMystruct(new Ss1().setSs01(new Ss0().setS0("My s0").setD0(99d)).setS1("My s1").setL1(89l));
    Map<Float, Integer> wsFloat = new HashMap<>();
    wsFloat.put(56f, 55);
    wsFloat.put(57f, 54);
    book.setMywsfloat(wsFloat);
    Array<IntegerFieldValue> intArr1 = new Array<>(DataType.getArray(DataType.INT));
    intArr1.add(new IntegerFieldValue(1));
    intArr1.add(new IntegerFieldValue(2));
    intArr1.add(new IntegerFieldValue(3));
    Array intArr1Arr = new Array(DataType.getArray(intArr1.getDataType()));
    intArr1Arr.add(intArr1);
    Array intArr1ArrArr = new Array(DataType.getArray(intArr1Arr.getDataType()));
    intArr1ArrArr.add(intArr1Arr);
    book.setMytriplearray(intArr1ArrArr);
    return book;
}
Also used : Date(com.yahoo.vespa.documentgen.test.annotation.Date) Ss1(com.yahoo.vespa.documentgen.test.Book.Ss1) Ss0(com.yahoo.vespa.documentgen.test.Book.Ss0) SpanTree(com.yahoo.document.annotation.SpanTree)

Example 2 with Date

use of com.yahoo.vespa.documentgen.test.annotation.Date in project vespa by vespa-engine.

the class DocumentGenPluginTest method testFactory.

@Test
public void testFactory() {
    Book b = (Book) ConcreteDocumentFactory.getDocument("book", new DocumentId("doc:book:10"));
    b.setAuthor("Per Ulv");
    final Date d = (Date) ConcreteDocumentFactory.getAnnotation("date");
    d.setExacttime(79l);
    b.setAuthorSpanTrees(new HashMap<String, SpanTree>() {

        {
            put("root", new SpanTree("root").annotate(d));
        }
    });
    StringFieldValue authorCheck = (StringFieldValue) b.getFieldValue("author");
    assertEquals(authorCheck.getWrappedValue(), "Per Ulv");
    SpanTree treeCheck = authorCheck.getSpanTrees().iterator().next();
    Annotation authorAnnCheck = treeCheck.iterator().next();
    assertEquals(((Struct) authorAnnCheck.getFieldValue()).getFieldValue("exacttime").getWrappedValue(), 79l);
    b.setMystruct(((Ss1) ConcreteDocumentFactory.getStruct("ss1")).setS1("Test s1!"));
    assertEquals(((Struct) b.getFieldValue("mystruct")).getFieldValue("s1").getWrappedValue(), "Test s1!");
    Ss1 fss1 = (Ss1) ConcreteDocumentFactory.getStruct("ss1");
    fss1.setD1(678d);
    b.setMystruct(fss1);
    assertEquals(b.getMystruct().getFieldValue("d1").getWrappedValue(), 678d);
    assertEquals(b.getMystruct().getD1(), (Double) 678d);
    assertEquals(ConcreteDocumentFactory.documentTypeObjects.size(), 10);
    assertEquals(ConcreteDocumentFactory.documentTypeObjects.get("music"), Music.type);
    assertEquals(ConcreteDocumentFactory.documentTypeObjects.get("parent"), Parent.type);
    assertEquals(ConcreteDocumentFactory.documentTypeObjects.get("common"), Common.type);
}
Also used : Ss1(com.yahoo.vespa.documentgen.test.Book.Ss1) Date(com.yahoo.vespa.documentgen.test.annotation.Date) Annotation(com.yahoo.document.annotation.Annotation) SpanTree(com.yahoo.document.annotation.SpanTree) Test(org.junit.Test)

Aggregations

SpanTree (com.yahoo.document.annotation.SpanTree)2 Ss1 (com.yahoo.vespa.documentgen.test.Book.Ss1)2 Date (com.yahoo.vespa.documentgen.test.annotation.Date)2 Annotation (com.yahoo.document.annotation.Annotation)1 Ss0 (com.yahoo.vespa.documentgen.test.Book.Ss0)1 Test (org.junit.Test)1