Search in sources :

Example 11 with Header

use of jp.ossc.nimbus.beans.dataset.Header in project nimbus by nimbus-org.

the class DataSetXpathConverterTest method testConvertToObject.

public void testConvertToObject() {
    DataSet inputDataSet = new DataSetXPathConverterTestDataSet();
    // 初期データ設定
    Header inputHeader = inputDataSet.getHeader();
    inputHeader.setProperty(DataSetXPathConverterTestDataSet.PROPERTY0, "PROP0");
    inputHeader.setParseProperty(DataSetXPathConverterTestDataSet.PROPERTY1, "PROP1");
    BindingStreamConverter converter = new DataSetXpathConverter();
    DataSetXPathConverterTestDataSet dataSet = (DataSetXPathConverterTestDataSet) converter.convertToObject(createTestData(), inputDataSet);
    Header header = dataSet.getHeader();
    RecordList recordList = dataSet.getRecordList();
    // 初期データ取得
    Assert.assertEquals("PROP0", header.get(DataSetXPathConverterTestDataSet.PROPERTY0));
    // 属性取得
    Assert.assertEquals("ATTR", header.get(DataSetXPathConverterTestDataSet.PROPERTY1));
    // 属性値による指定ノード取得
    Assert.assertEquals("テキスト2-3", header.get(DataSetXPathConverterTestDataSet.PROPERTY2));
    // ノードインデックスによる指定ノード取得
    Assert.assertEquals("ATTR1", header.get(DataSetXPathConverterTestDataSet.PROPERTY3));
    // 子ノード取得
    for (int i = 0; i < recordList.size(); i++) {
        Record record = (Record) recordList.get(i);
        Assert.assertEquals("テキスト" + (i + 1) + "-1", record.get(DataSetXPathConverterTestDataSet.PROPERTY4));
        Assert.assertEquals("テキスト" + (i + 1) + "-2", record.get(DataSetXPathConverterTestDataSet.PROPERTY5));
        Assert.assertEquals("テキスト" + (i + 1) + "-3", record.get(DataSetXPathConverterTestDataSet.PROPERTY6));
    }
}
Also used : Header(jp.ossc.nimbus.beans.dataset.Header) RecordList(jp.ossc.nimbus.beans.dataset.RecordList) DataSet(jp.ossc.nimbus.beans.dataset.DataSet) Record(jp.ossc.nimbus.beans.dataset.Record)

Aggregations

Header (jp.ossc.nimbus.beans.dataset.Header)11 HttpClientImpl (jp.ossc.nimbus.service.http.httpclient.HttpClientFactoryService.HttpClientImpl)6 DataSet (jp.ossc.nimbus.beans.dataset.DataSet)5 RecordList (jp.ossc.nimbus.beans.dataset.RecordList)3 PropertySchemaDefineException (jp.ossc.nimbus.beans.dataset.PropertySchemaDefineException)2 Record (jp.ossc.nimbus.beans.dataset.Record)2 HttpClientFactory (jp.ossc.nimbus.service.http.HttpClientFactory)2 HttpRequest (jp.ossc.nimbus.service.http.HttpRequest)2 ConvertException (jp.ossc.nimbus.util.converter.ConvertException)2 Iterator (java.util.Iterator)1 Document (org.w3c.dom.Document)1