本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}