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


Java MockObject类代码示例

本文整理汇总了Java中org.unitils.mock.core.MockObject的典型用法代码示例。如果您正苦于以下问题:Java MockObject类的具体用法?Java MockObject怎么用?Java MockObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getMockName

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
/**
 * note: don't remove, used through reflection from {@link org.unitils.core.util.ObjectFormatter}
 *
 * @param object The object to check
 * @return The proxied type, null if the object is not a proxy or mock
 */
@SuppressWarnings({"UnusedDeclaration"})
public static String getMockName(Object object) {
    if (object == null) {
        return null;
    }
    if (object instanceof MockObject) {
        return ((MockObject) object).getName();
    }
    if (object instanceof Factory) {
        Callback callback = ((Factory) object).getCallback(0);
        if (callback instanceof CglibProxyMethodInterceptor) {
            return ((CglibProxyMethodInterceptor) callback).getMockName();
        }
    }
    return null;
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:23,代码来源:ProxyUtils.java

示例2: toPojoNameTests

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test
public void toPojoNameTests() {
    Mock<PojoData> nullMock = new MockObject<PojoData>(PojoData.class, null);
    nullMock.returns(null).getName();

    assertNull(FunctionsUtil.toPojoName.apply(nullMock.getMock()));
    nullMock.assertInvoked().getName();

    Mock<PojoData> mock = new MockObject<PojoData>(PojoData.class, null);
    mock.returns("dataset.name").getName();
    assertEquals("dataset.name", FunctionsUtil.toPojoName.apply(mock.getMock()));
    mock.assertInvoked().getName();

    Mock<PojoData> emptyMock = new MockObject<PojoData>(PojoData.class, null);
    emptyMock.returns("    ").getName();
    assertEquals("    ", FunctionsUtil.toPojoName.apply(emptyMock.getMock()));
    emptyMock.assertInvoked().getName();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:19,代码来源:FunctionsUtilTest.java

示例3: getLinesShouldSkipNullLines

import org.unitils.mock.core.MockObject; //导入依赖的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

示例4: getLinesShouldSkipEmptyLines

import org.unitils.mock.core.MockObject; //导入依赖的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

示例5: setUp

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
/**
 * Initializes the test.
 */
@Before
public void setUp() {
    suggestedAssertsReport = new SuggestedAssertsReport();
    testMock = new MockObject<TestInterface>("testMock", TestInterface.class, this);
    testProxy = testMock.getMock();
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:10,代码来源:SuggestedAssertsReportTest.java

示例6: toPojoIdTests

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test
public void toPojoIdTests() {
    Mock<PojoData> nullMock = new MockObject<PojoData>(PojoData.class, null);
    nullMock.returns(null).getId();

    assertNull(FunctionsUtil.toPojoId.apply(nullMock.getMock()));
    nullMock.assertInvoked().getId();

    Mock<PojoData> mock = new MockObject<PojoData>(PojoData.class, null);
    mock.returns(1L).getId();
    assertEquals(Long.valueOf(1), FunctionsUtil.toPojoId.apply(mock.getMock()));
    mock.assertInvoked().getId();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:14,代码来源:FunctionsUtilTest.java

示例7: toTagValueTests

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test
public void toTagValueTests() {
    Mock<TagAnnotationData> mock =
        new MockObject<TagAnnotationData>(TagAnnotationData.class, null);
    mock.returns(null).getTagValue();

    assertNull(FunctionsUtil.toTagValue.apply(mock.getMock()));
    mock.assertInvoked().getTagValue();

    TagAnnotationData input = new TagAnnotationData("tag.name");
    assertEquals("tag.name", FunctionsUtil.toTagValue.apply(input));
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:13,代码来源:FunctionsUtilTest.java

示例8: toAnnotationFileNameTests

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test
public void toAnnotationFileNameTests() {
    Mock<FileAnnotationData> mock =
        new MockObject<FileAnnotationData>(FileAnnotationData.class, null);
    mock.returns(null).getFileName();

    assertNull(FunctionsUtil.toAnnotationFileName.apply(mock.getMock()));
    mock.assertInvoked().getFileName();

    FileAnnotationData input = new FileAnnotationData(new File("file.name"));
    assertEquals("file.name", FunctionsUtil.toAnnotationFileName.apply(input));

    input = new FileAnnotationData(new File("    "));
    assertEquals("    ", FunctionsUtil.toAnnotationFileName.apply(input));
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:16,代码来源:FunctionsUtilTest.java

示例9: pojoDataShouldRejectNullDatasetName

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test(expectedExceptions = { IllegalArgumentException.class },
     expectedExceptionsMessageRegExp = TestsUtil.PRECONDITION_FAILED_REGEX)
public void pojoDataShouldRejectNullDatasetName() {
    Mock<DatasetData> datasetMock = new MockObject<DatasetData>(DatasetData.class, null);
    datasetMock.returns(null).getName();

    DefaultPojoData.fromDatasetData(datasetMock.getMock());

    datasetMock.assertInvoked().getName();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:11,代码来源:DefaultPojoDataTest.java

示例10: pojoDataShouldRejectNullImageName

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test(expectedExceptions = { IllegalArgumentException.class },
     expectedExceptionsMessageRegExp = TestsUtil.PRECONDITION_FAILED_REGEX)
public void pojoDataShouldRejectNullImageName() {
    Mock<ImageData> imageMock = new MockObject<ImageData>(ImageData.class, null);
    imageMock.returns(null).getName();

    DefaultPojoData.fromImageData(imageMock.getMock());

    imageMock.assertInvoked().getName();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:11,代码来源:DefaultPojoDataTest.java

示例11: pojoDataShouldRejectNullPlateName

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test(expectedExceptions = { IllegalArgumentException.class },
      expectedExceptionsMessageRegExp = TestsUtil.PRECONDITION_FAILED_REGEX)
public void pojoDataShouldRejectNullPlateName() {
    Mock<PlateData> plateMock = new MockObject<PlateData>(PlateData.class, null);
    plateMock.returns(null).getName();

    DefaultPojoData.fromPlateData(plateMock.getMock());

    plateMock.assertInvoked().getName();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:11,代码来源:DefaultPojoDataTest.java

示例12: pojoDataShouldConvertNullPlateAcquisitionNameToDefault

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
@Test
public void pojoDataShouldConvertNullPlateAcquisitionNameToDefault() {
    Mock<PlateAcquisitionData> paMock = new MockObject<PlateAcquisitionData>(PlateAcquisitionData.class, null);
    paMock.returns(null).getName();

    PojoData pojo = DefaultPojoData.fromPlateAcquisitionData(paMock.getMock());

    assertNotNull(pojo, "Non-null result expected");
    assertEquals(pojo.getName(), "Run " + pojo.getId(), "Incorrect pojo name");

    paMock.assertInvoked().getName();
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:13,代码来源:DefaultPojoDataTest.java

示例13: getLinesShouldSkipMalformedLinesWithEmptyTargetName

import org.unitils.mock.core.MockObject; //导入依赖的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

示例14: createMock

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
protected <T> Mock<T> createMock(Object testObject, String name, Class<?> type) {
    return new MockObject<T>(name, type, testObject);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:4,代码来源:MockModule.java

示例15: assertNoMoreInvocations

import org.unitils.mock.core.MockObject; //导入依赖的package包/类
public static void assertNoMoreInvocations() {
    MockObject.getCurrentScenario().assertNoMoreInvocations(getInvocationStackTrace(MockUnitils.class, false));
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:4,代码来源:MockUnitils.java


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