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


Java Mock.getMock方法代码示例

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


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

示例1: getLinesShouldSkipNullLines

import org.unitils.mock.Mock; //导入方法依赖的package包/类
@Test
public void getLinesShouldSkipNullLines() {
    Mock<CsvLineReader<CsvLine>> mockReader =
        new MockObject<CsvLineReader<CsvLine>>(CsvLineReader.class, null);

    Mock<CsvLine> mockLine = new MockObject<CsvLine>(CsvLine.class, null);
    mockLine.returns(1L).getNumber();
    mockLine.returns(0).getSize();
    mockLine.returns(null).getValueAt(0);

    Collection<CsvLine> nullLinesFixture = Arrays.asList(new CsvLine[] { mockLine.getMock() });

    mockReader.returns(nullLinesFixture).getLines();

    CsvAnnotationsReader reader = new CsvAnnotationsReader(mockReader.getMock());

    Collection<CsvAnnotationLine> result = reader.getLines();

    assertNotNull(result,"Non null lines expected");
    assertTrue(result.isEmpty(),"Empty lines expected");

    mockReader.assertInvoked().getLines();
    mockLine.assertInvoked().getSize();
    mockLine.assertNotInvoked().getValueAt(0);
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:26,代码来源:CsvAnnotationsReaderTest.java

示例2: getLinesShouldSkipEmptyLines

import org.unitils.mock.Mock; //导入方法依赖的package包/类
@Test
public void getLinesShouldSkipEmptyLines() {
    Mock<CsvLineReader<CsvLine>> mockReader =
        new MockObject<CsvLineReader<CsvLine>>(CsvLineReader.class, null);

    Mock<CsvLine> mockLine = new MockObject<CsvLine>(CsvLine.class, null);
    mockLine.returns(1L).getNumber();
    mockLine.returns(0).getSize();
    mockLine.returns("    ").getValueAt(0);

    Collection<CsvLine> emptyLinesFixture = Arrays.asList(new CsvLine[] { mockLine.getMock() });

    mockReader.returns(emptyLinesFixture).getLines();

    CsvAnnotationsReader reader = new CsvAnnotationsReader(mockReader.getMock());

    Collection<CsvAnnotationLine> result = reader.getLines();

    assertNotNull(result,"Non null lines expected");
    assertTrue(result.isEmpty(),"Empty lines expected");

    mockReader.assertInvoked().getLines();
    mockLine.assertInvoked().getSize();
    mockLine.assertNotInvoked().getValueAt(0);
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:26,代码来源:CsvAnnotationsReaderTest.java

示例3: getLinesShouldSkipMalformedLinesWithEmptyTargetName

import org.unitils.mock.Mock; //导入方法依赖的package包/类
@Test(dataProvider="empty-names-provider")
public void getLinesShouldSkipMalformedLinesWithEmptyTargetName(String invalidTargetName) {
    Mock<CsvLineReader<CsvLine>> mockReader =
        new MockObject<CsvLineReader<CsvLine>>(CsvLineReader.class, null);

    Mock<CsvLine> mockLine = new MockObject<CsvLine>(CsvLine.class, null);
    mockLine.returns(1L).getNumber();
    mockLine.returns(2).getSize();
    mockLine.returns(invalidTargetName).getValueAt(0);
    mockLine.returns("some.annotation").getValueAt(1);

    Collection<CsvLine> malformedLinesFixture =
        Arrays.asList(new CsvLine[] { mockLine.getMock() });

    mockReader.returns(malformedLinesFixture).getLines();

    CsvAnnotationsReader reader = new CsvAnnotationsReader(mockReader.getMock());

    Collection<CsvAnnotationLine> result = reader.getLines();

    assertNotNull(result,"Non null lines expected");
    assertTrue(result.isEmpty(),"Empty lines expected");

    mockReader.assertInvoked().getLines();
    mockLine.assertInvoked().getSize();
    mockLine.assertInvoked().getValueAt(0);
    mockLine.assertNotInvoked().getValueAt(1);
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:29,代码来源:CsvAnnotationsReaderTest.java

示例4: getLinesShouldSkipNullFileContent

import org.unitils.mock.Mock; //导入方法依赖的package包/类
@Test
public void getLinesShouldSkipNullFileContent() {
    Mock<CsvLineReader<CsvLine>> mockReader =
        new MockObject<CsvLineReader<CsvLine>>(CsvLineReader.class, null);

    mockReader.returns(null).getLines();

    CsvAnnotationsReader reader = new CsvAnnotationsReader(mockReader.getMock());

    Collection<CsvAnnotationLine> result = reader.getLines();

    assertNotNull(result,"Non null lines expected");
    assertTrue(result.isEmpty(),"Empty lines expected");

    mockReader.assertInvoked().getLines();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:17,代码来源:CsvAnnotationsReaderTest.java

示例5: getLinesShouldSkipEmptyFileContent

import org.unitils.mock.Mock; //导入方法依赖的package包/类
@Test
public void getLinesShouldSkipEmptyFileContent() {
    Mock<CsvLineReader<CsvLine>> mockReader =
        new MockObject<CsvLineReader<CsvLine>>(CsvLineReader.class, null);

    mockReader.returns(Collections.emptyList()).getLines();

    CsvAnnotationsReader reader = new CsvAnnotationsReader(mockReader.getMock());

    Collection<CsvAnnotationLine> result = reader.getLines();

    assertNotNull(result,"Non null lines expected");
    assertTrue(result.isEmpty(),"Empty lines expected");

    mockReader.assertInvoked().getLines();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:17,代码来源:CsvAnnotationsReaderTest.java

示例6: getLinesShouldSkipMalformedLinesWithEmptyAnnotations

import org.unitils.mock.Mock; //导入方法依赖的package包/类
@Test
public void getLinesShouldSkipMalformedLinesWithEmptyAnnotations() {
    Mock<CsvLineReader<CsvLine>> mockReader =
        new MockObject<CsvLineReader<CsvLine>>(CsvLineReader.class, null);

    Mock<CsvLine> mockLineWithNullList = new MockObject<CsvLine>(CsvLine.class, null);
    mockLineWithNullList.returns(1L).getNumber();
    mockLineWithNullList.returns(2).getSize();
    mockLineWithNullList.returns("some.container.name").getValueAt(0);
    mockLineWithNullList.returns(null).getValueAt(1);

    Mock<CsvLine> mockLineWithEmptyList = new MockObject<CsvLine>(CsvLine.class, null);
    mockLineWithEmptyList.returns(2L).getNumber();
    mockLineWithEmptyList.returns(2).getSize();
    mockLineWithEmptyList.returns("some.container.name").getValueAt(0);
    mockLineWithEmptyList.returns("    ").getValueAt(1);

    Collection<CsvLine> malformedLinesFixture =
        Arrays.asList(new CsvLine[] {
            mockLineWithNullList.getMock(), mockLineWithEmptyList.getMock()
        });

    mockReader.returns(malformedLinesFixture).getLines();

    CsvAnnotationsReader reader = new CsvAnnotationsReader(mockReader.getMock());

    Collection<CsvAnnotationLine> result = reader.getLines();

    assertNotNull(result,"Non null lines expected");
    assertTrue(result.isEmpty(),"Empty lines expected");

    mockReader.assertInvoked().getLines();

    mockLineWithNullList.assertInvoked().getSize();
    mockLineWithNullList.assertInvoked().getValueAt(0);
    mockLineWithNullList.assertInvoked().getValueAt(1);

    mockLineWithEmptyList.assertInvoked().getSize();
    mockLineWithEmptyList.assertInvoked().getValueAt(0);
    mockLineWithEmptyList.assertInvoked().getValueAt(1);
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:42,代码来源:CsvAnnotationsReaderTest.java


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