package de.tblsoft.solr.pipeline.test;

import de.tblsoft.solr.pipeline.bean.Document;
import de.tblsoft.solr.pipeline.bean.DocumentBuilder;
import de.tblsoft.solr.pipeline.bean.Filter;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by tblsoft on 29.04.16.
 */
public class BeanTest {

    @Test
    public void testFilterBean() {
        testBean(new Filter());
    }

    @Test
    public void testDocumentBean() {
        testBean(DocumentBuilder.document().create());
    }


    @Test
    public void testDeleteFieldInDocument() {
        Document document = DocumentBuilder.document().field("foo","bar").field("john", "doe").create();
        document.deleteField("foo");
        Assert.assertNull(document.getField("foo"));
        Assert.assertEquals("doe", document.getFieldValue("john"));
        Assert.assertEquals(1, document.getFields().size());

    }

    void testBean(Object bean) {
        Assert.assertFalse(bean.toString().contains("@"));
    }
}

@@ -130,24 +130,68 @@
 entBuilder;%0A
+import de.tblsoft.solr.pipeline.bean.Field;%0A
 import de.tb
@@ -420,24 +420,264 @@
 ());%0A    %7D%0A%0A
+    @Test%0A    public void testFieldBean() %7B%0A        testBean(new Field(%22foo%22, %22bar%22));%0A    %7D%0A%0A    @Test%0A    public void testFieldBeanWithNoValue() %7B%0A        Field f = new Field(%22foo%22, null);%0A        Assert.assertNull(f.getValue());%0A    %7D%0A%0A%0A
     @Test%0A  

add bean test for field bean