Search in sources :

Example 1 with TestEntity

use of org.codelibs.fess.crawler.entity.TestEntity in project fess-crawler by codelibs.

the class XmlTransformerTest method test_getData_dataMap_entity.

public void test_getData_dataMap_entity() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list><item>リスト1</item><item>リスト2</item><item>リスト3</item></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xmlEntityTransformer");
    final Object obj = xmlEntityTransformer.getData(accessResultDataImpl);
    assertTrue(obj instanceof TestEntity);
    final TestEntity entity = (TestEntity) obj;
    assertEquals("タイトル", entity.getTitle());
    assertEquals("第一章 第一節 ほげほげふがふが LINK 第2章 第2節", entity.getBody());
    final List<String> list = new ArrayList<String>();
    list.add("リスト1");
    list.add("リスト2");
    list.add("リスト3");
    assertEquals(list, entity.getList());
}
Also used : TestEntity(org.codelibs.fess.crawler.entity.TestEntity) ArrayList(java.util.ArrayList) AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Example 2 with TestEntity

use of org.codelibs.fess.crawler.entity.TestEntity in project fess-crawler by codelibs.

the class XmlTransformerTest method test_getData_dataMap_entity_emptyList.

public void test_getData_dataMap_entity_emptyList() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xmlEntityTransformer");
    final Object obj = xmlEntityTransformer.getData(accessResultDataImpl);
    assertTrue(obj instanceof TestEntity);
    final TestEntity entity = (TestEntity) obj;
    assertEquals("タイトル", entity.getTitle());
    assertEquals("第一章 第一節 ほげほげふがふが LINK 第2章 第2節", entity.getBody());
    final List<String> list = new ArrayList<String>();
    assertEquals(list, entity.getList());
}
Also used : TestEntity(org.codelibs.fess.crawler.entity.TestEntity) ArrayList(java.util.ArrayList) AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Example 3 with TestEntity

use of org.codelibs.fess.crawler.entity.TestEntity in project fess-crawler by codelibs.

the class XpathTransformerTest method test_getData_dataMap_entity_emptyList.

public void test_getData_dataMap_entity_emptyList() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xpathEntityTransformer");
    final Object obj = xpathEntityTransformer.getData(accessResultDataImpl);
    assertTrue(obj instanceof TestEntity);
    final TestEntity entity = (TestEntity) obj;
    assertEquals("タイトル", entity.getTitle());
    assertEquals("第一章 第一節 ほげほげふがふが LINK 第2章 第2節", entity.getBody());
    final List<String> list = new ArrayList<String>();
    assertEquals(list, entity.getList());
}
Also used : TestEntity(org.codelibs.fess.crawler.entity.TestEntity) ArrayList(java.util.ArrayList) AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Example 4 with TestEntity

use of org.codelibs.fess.crawler.entity.TestEntity in project fess-crawler by codelibs.

the class XpathTransformerTest method test_getData_dataMap_entity.

public void test_getData_dataMap_entity() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list><item>リスト1</item><item>リスト2</item><item>リスト3</item></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xpathEntityTransformer");
    final Object obj = xpathEntityTransformer.getData(accessResultDataImpl);
    assertTrue(obj instanceof TestEntity);
    final TestEntity entity = (TestEntity) obj;
    assertEquals("タイトル", entity.getTitle());
    assertEquals("第一章 第一節 ほげほげふがふが LINK 第2章 第2節", entity.getBody());
    final List<String> list = new ArrayList<String>();
    list.add("リスト1");
    list.add("リスト2");
    list.add("リスト3");
    assertEquals(list, entity.getList());
}
Also used : TestEntity(org.codelibs.fess.crawler.entity.TestEntity) ArrayList(java.util.ArrayList) AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Aggregations

ArrayList (java.util.ArrayList)4 AccessResultDataImpl (org.codelibs.fess.crawler.entity.AccessResultDataImpl)4 TestEntity (org.codelibs.fess.crawler.entity.TestEntity)4