当前位置: 首页>>代码示例>>Java>>正文


Java IDataSetProducer.produce方法代码示例

本文整理汇总了Java中org.dbunit.dataset.stream.IDataSetProducer.produce方法的典型用法代码示例。如果您正苦于以下问题:Java IDataSetProducer.produce方法的具体用法?Java IDataSetProducer.produce怎么用?Java IDataSetProducer.produce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dbunit.dataset.stream.IDataSetProducer的用法示例。


在下文中一共展示了IDataSetProducer.produce方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProduceDataSetUsingNotJsonStream

import org.dbunit.dataset.stream.IDataSetProducer; //导入方法依赖的package包/类
@Test
public void testProduceDataSetUsingNotJsonStream() throws DataSetException {
    // GIVEN
    final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
    final IDataSetProducer producer = new JsonDataSetProducer(yamlStream);
    producer.setConsumer(consumer);

    // WHEN
    try {
        producer.produce();
        fail("DataSetException expected");
    } catch (final DataSetException e) {
        // THEN
        assertThat(e.getCause(), instanceOf(JsonSyntaxException.class));
    }
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:17,代码来源:JsonDataSetProducerTest.java

示例2: testProduceDataSetFromEmptyFile

import org.dbunit.dataset.stream.IDataSetProducer; //导入方法依赖的package包/类
@Test
public void testProduceDataSetFromEmptyFile() throws DataSetException {
    // GIVEN
    final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
    final IDataSetProducer producer = new YamlDataSetProducer(emptyStream);
    producer.setConsumer(consumer);

    // WHEN
    producer.produce();

    // THEN
    verify(consumer).startDataSet();

    verify(consumer, times(0)).startTable(any(ITableMetaData.class));
    verify(consumer, times(0)).row(any(Object[].class));
    verify(consumer, times(0)).endTable();

    verify(consumer).endDataSet();
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:20,代码来源:YamlDataSetProducerTest.java

示例3: testProduceDataSetUsingNotYamlStream

import org.dbunit.dataset.stream.IDataSetProducer; //导入方法依赖的package包/类
@Test
public void testProduceDataSetUsingNotYamlStream() throws DataSetException {
    // GIVEN
    final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
    final IDataSetProducer producer = new YamlDataSetProducer(jsonStream);
    producer.setConsumer(consumer);

    // WHEN
    try {
        producer.produce();
        fail("DataSetException expected");
    } catch (final DataSetException e) {
        // THEN
        assertThat(e.getCause(), instanceOf(ScannerException.class));
    }
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:17,代码来源:YamlDataSetProducerTest.java

示例4: testProduceDataSetUsingValidStream

import org.dbunit.dataset.stream.IDataSetProducer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testProduceDataSetUsingValidStream() throws DataSetException {
    // GIVEN
    final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
    final IDataSetProducer producer = new JsonDataSetProducer(jsonStream);
    producer.setConsumer(consumer);

    // WHEN
    producer.produce();

    // THEN
    verify(consumer).startDataSet();

    final ArgumentCaptor<ITableMetaData> tmdCaptor = ArgumentCaptor.forClass(ITableMetaData.class);
    verify(consumer, times(2)).startTable(tmdCaptor.capture());

    final List<ITableMetaData> tmdList = tmdCaptor.getAllValues();
    final ITableMetaData tmd1 = tmdList.get(0);
    final List<Column> table1Columns = Arrays.asList(tmd1.getColumns());
    final ITableMetaData tmd2 = tmdList.get(1);
    final List<Column> table2Columns = Arrays.asList(tmd2.getColumns());

    assertThat(tmd1.getTableName(), equalTo("JSON_TABLE_1"));
    assertThat(table1Columns.size(), equalTo(7));
    assertThat(table1Columns, hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_1"),
            columnWithName("value_2"), columnWithName("value_3"), columnWithName("value_4"), columnWithName("value_5")));

    assertThat(tmd2.getTableName(), equalTo("JSON_TABLE_2"));
    assertThat(table2Columns.size(), equalTo(4));
    assertThat(table2Columns,
            hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_6"), columnWithName("value_7")));

    final ArgumentCaptor<Object[]> rowCaptor = ArgumentCaptor.forClass(Object[].class);
    verify(consumer, times(4)).row(rowCaptor.capture());

    final List<Object[]> allRows = rowCaptor.getAllValues();

    final Map<String, String> record1 = rebuildRecord(table1Columns, allRows.get(0));
    assertThat(record1.size(), equalTo(7));
    assertThat(record1.get("id"), equalTo("1"));
    assertThat(record1.get("version"), equalTo("Record 1 version"));
    assertThat(record1.get("value_1"), equalTo("Record 1 Value 1"));
    assertThat(record1.get("value_2"), equalTo("Record 1 Value 2"));
    assertThat(record1.get("value_3"), nullValue());
    assertThat(record1.get("value_4"), equalTo("Record 1 Value 4"));
    assertThat(record1.get("value_5"), nullValue());

    final Map<String, String> record2 = rebuildRecord(table1Columns, allRows.get(1));
    assertThat(record2.size(), equalTo(7));
    assertThat(record2.get("id"), equalTo("2"));
    assertThat(record2.get("version"), equalTo("Record 2 version"));
    assertThat(record2.get("value_1"), equalTo("Record 2 Value 1"));
    assertThat(record2.get("value_2"), equalTo("Record 2 Value 2"));
    assertThat(record2.get("value_3"), equalTo("Record 2 Value 3"));
    assertThat(record2.get("value_4"), nullValue());
    assertThat(record2.get("value_5"), nullValue());

    final Map<String, String> record3 = rebuildRecord(table1Columns, allRows.get(2));
    assertThat(record3.size(), equalTo(7));
    assertThat(record3.get("id"), equalTo("3"));
    assertThat(record3.get("version"), equalTo("Record 3 version"));
    assertThat(record3.get("value_1"), nullValue());
    assertThat(record3.get("value_2"), nullValue());
    assertThat(record3.get("value_3"), nullValue());
    assertThat(record3.get("value_4"), nullValue());
    assertThat(record3.get("value_5"), equalTo("Record 3 Value 5"));

    final Map<String, String> record4 = rebuildRecord(table2Columns, allRows.get(3));
    assertThat(record4.size(), equalTo(4));
    assertThat(record4.get("id"), equalTo("4"));
    assertThat(record4.get("version"), equalTo("Record 4 version"));
    assertThat(record4.get("value_6"), equalTo("Record 4 Value 6"));
    assertThat(record4.get("value_7"), equalTo("Record 4 Value 7"));

    verify(consumer, times(2)).endTable();

    verify(consumer).endDataSet();
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:80,代码来源:JsonDataSetProducerTest.java

示例5: testProduceDataSetUsingValidStream

import org.dbunit.dataset.stream.IDataSetProducer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testProduceDataSetUsingValidStream() throws DataSetException {
    // GIVEN
    final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
    final IDataSetProducer producer = new YamlDataSetProducer(yamlStream);
    producer.setConsumer(consumer);

    // WHEN
    producer.produce();

    // THEN
    verify(consumer).startDataSet();

    final ArgumentCaptor<ITableMetaData> tmdCaptor = ArgumentCaptor.forClass(ITableMetaData.class);
    verify(consumer, times(2)).startTable(tmdCaptor.capture());

    final List<ITableMetaData> tmdList = tmdCaptor.getAllValues();
    final ITableMetaData tmd1 = tmdList.get(0);
    final List<Column> table1Columns = Arrays.asList(tmd1.getColumns());
    final ITableMetaData tmd2 = tmdList.get(1);
    final List<Column> table2Columns = Arrays.asList(tmd2.getColumns());

    assertThat(tmd1.getTableName(), equalTo("YAML_TABLE_1"));
    assertThat(table1Columns.size(), equalTo(7));
    assertThat(table1Columns, hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_1"),
            columnWithName("value_2"), columnWithName("value_3"), columnWithName("value_4"), columnWithName("value_5")));

    assertThat(tmd2.getTableName(), equalTo("YAML_TABLE_2"));
    assertThat(table2Columns.size(), equalTo(4));
    assertThat(table2Columns,
            hasItems(columnWithName("id"), columnWithName("version"), columnWithName("value_6"), columnWithName("value_7")));

    final ArgumentCaptor<Object[]> rowCaptor = ArgumentCaptor.forClass(Object[].class);
    verify(consumer, times(4)).row(rowCaptor.capture());

    final List<Object[]> allRows = rowCaptor.getAllValues();

    final Map<String, String> record1 = rebuildRecord(table1Columns, allRows.get(0));
    assertThat(record1.size(), equalTo(7));
    assertThat(record1.get("id"), equalTo("1"));
    assertThat(record1.get("version"), equalTo("Record 1 version"));
    assertThat(record1.get("value_1"), equalTo("Record 1 Value 1"));
    assertThat(record1.get("value_2"), equalTo("Record 1 Value 2"));
    assertThat(record1.get("value_3"), nullValue());
    assertThat(record1.get("value_4"), equalTo("Record 1 Value 4"));
    assertThat(record1.get("value_5"), nullValue());

    final Map<String, String> record2 = rebuildRecord(table1Columns, allRows.get(1));
    assertThat(record2.size(), equalTo(7));
    assertThat(record2.get("id"), equalTo("2"));
    assertThat(record2.get("version"), equalTo("Record 2 version"));
    assertThat(record2.get("value_1"), equalTo("Record 2 Value 1"));
    assertThat(record2.get("value_2"), equalTo("Record 2 Value 2"));
    assertThat(record2.get("value_3"), equalTo("Record 2 Value 3"));
    assertThat(record2.get("value_4"), nullValue());
    assertThat(record2.get("value_5"), nullValue());

    final Map<String, String> record3 = rebuildRecord(table1Columns, allRows.get(2));
    assertThat(record3.size(), equalTo(7));
    assertThat(record3.get("id"), equalTo("3"));
    assertThat(record3.get("version"), equalTo("Record 3 version"));
    assertThat(record3.get("value_1"), nullValue());
    assertThat(record3.get("value_2"), nullValue());
    assertThat(record3.get("value_3"), nullValue());
    assertThat(record3.get("value_4"), nullValue());
    assertThat(record3.get("value_5"), equalTo("Record 3 Value 5"));

    final Map<String, String> record4 = rebuildRecord(table2Columns, allRows.get(3));
    assertThat(record4.size(), equalTo(4));
    assertThat(record4.get("id"), equalTo("4"));
    assertThat(record4.get("version"), equalTo("Record 4 version"));
    assertThat(record4.get("value_6"), equalTo("Record 4 Value 6"));
    assertThat(record4.get("value_7"), equalTo("Record 4 Value 7"));

    verify(consumer, times(2)).endTable();

    verify(consumer).endDataSet();
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:80,代码来源:YamlDataSetProducerTest.java


注:本文中的org.dbunit.dataset.stream.IDataSetProducer.produce方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。