Search in sources :

Example 1 with Ss1

use of com.yahoo.vespa.documentgen.test.Book.Ss1 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 Ss1

use of com.yahoo.vespa.documentgen.test.Book.Ss1 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)

Example 3 with Ss1

use of com.yahoo.vespa.documentgen.test.Book.Ss1 in project vespa by vespa-engine.

the class DocumentGenPluginTest method testEquals.

@Test
public void testEquals() {
    Book b1 = getBook();
    Book b2 = getBook();
    Book b3 = null;
    assertTrue(b1.equals(b1));
    assertFalse(b1.equals(b3));
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b1));
    b2.setAuthor("foo");
    assertFalse(b1.equals(b2));
    b1.setAuthor("foo");
    assertTrue(b1.equals(b2));
    b1.getMyarrayint().set(0, 65);
    assertFalse(b1.equals(b2));
    assertFalse(b2.equals(b1));
    b2.getMyarrayint().set(0, 65);
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b1));
    Ss1 arrayedStruct1 = new Ss1().setS1("YEPPETI").setI1(789);
    Ss1 arrayedStruct2 = new Ss1().setS1("JADDA").setI1(456);
    List<Ss1> structArray = new ArrayList<>();
    structArray.add(arrayedStruct1);
    structArray.add(arrayedStruct2);
    b1.setMysinglestructarray(structArray);
    assertFalse(b1.equals(b2));
    assertFalse(b2.equals(b1));
    arrayedStruct1 = new Ss1().setS1("YEPPETI").setI1(789);
    arrayedStruct2 = new Ss1().setS1("JADDA").setI1(456);
    structArray = new ArrayList<>();
    structArray.add(arrayedStruct1);
    structArray.add(arrayedStruct2);
    b2.setMysinglestructarray(structArray);
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b1));
}
Also used : Ss1(com.yahoo.vespa.documentgen.test.Book.Ss1) Test(org.junit.Test)

Example 4 with Ss1

use of com.yahoo.vespa.documentgen.test.Book.Ss1 in project vespa by vespa-engine.

the class DocumentGenPluginTest method getBook.

private Book getBook() {
    Book book = new Book(new DocumentId("doc:book:0"));
    book.setAuthor("Herman Melville");
    book.setTitle("Moby Dick - Or The Whale");
    book.setIsbn("234-33");
    book.setYear(1815).setDescription("A great novel about whaling.");
    Ss1 ss1 = new Book.Ss1();
    Ss0 ss0 = new Book.Ss0();
    ss0.setD0(-238472634.78);
    ss1.setS1("test s1").setI1(999).setD1(56.777).setSs01(ss0);
    book.setMystruct(ss1);
    List<Integer> myArrInt = new ArrayList<>();
    myArrInt.add(10);
    myArrInt.add(20);
    myArrInt.add(30);
    book.setMyarrayint(myArrInt);
    List<Integer> intL = new ArrayList<Integer>() {

        {
            add(1);
            add(2);
            add(3);
        }
    };
    List<Integer> intL2 = new ArrayList<Integer>() {

        {
            add(9);
            add(10);
            add(11);
        }
    };
    List<List<Integer>> doubleIntL = new ArrayList<>();
    doubleIntL.add(intL);
    doubleIntL.add(intL2);
    List<List<List<Integer>>> tripleIntL = new ArrayList<>();
    tripleIntL.add(doubleIntL);
    book.setMytriplearray(tripleIntL);
    Map<String, String> sMap = new HashMap<>();
    sMap.put("Melville", "Moby Dick");
    sMap.put("Bulgakov", "The Master and Margarita");
    sMap.put("Black Debbath", "Tung tung politisk rock");
    book.setStringmap(sMap);
    Map<Integer, Ss1> structMap = new HashMap<>();
    structMap.put(50, ss1);
    structMap.put(60, ss1);
    book.setStructmap(structMap);
    Map<Float, Integer> ws = new HashMap<>();
    ws.put(1.1f, 100);
    ws.put(2.2f, 200);
    ws.put(3.3f, 300);
    book.setMywsfloat(ws);
    Ss1 arrayedStruct1 = new Ss1().setS1("YEPS").setI1(789);
    Ss1 arrayedStruct2 = new Ss1().setS1("JA").setI1(456);
    List<Ss1> structArray = new ArrayList<>();
    structArray.add(arrayedStruct1);
    structArray.add(arrayedStruct2);
    book.setMysinglestructarray(structArray);
    book.setContent(ByteBuffer.allocate(3).put(new byte[] { 3, 4, 5 }));
    book.getContent().position(0);
    return book;
}
Also used : Ss1(com.yahoo.vespa.documentgen.test.Book.Ss1) Ss0(com.yahoo.vespa.documentgen.test.Book.Ss0)

Aggregations

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