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


Java MockSettings.defaultAnswer方法代码示例

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


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

示例1: process

import org.mockito.MockSettings; //导入方法依赖的package包/类
public Object process(Mock annotation, Field field) {
    MockSettings mockSettings = Mockito.withSettings();
    if (annotation.extraInterfaces().length > 0) { // never null
        mockSettings.extraInterfaces(annotation.extraInterfaces());
    }
    if ("".equals(annotation.name())) {
        mockSettings.name(field.getName());
    } else {
        mockSettings.name(annotation.name());
    }
    if(annotation.serializable()){
    	mockSettings.serializable();
    }

    // see @Mock answer default value
    mockSettings.defaultAnswer(annotation.answer().get());
    return Mockito.mock(field.getType(), mockSettings);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:MockAnnotationProcessor.java

示例2: getParameterValue

import org.mockito.MockSettings; //导入方法依赖的package包/类
@Override
public Object getParameterValue(Parameter parameter) {
  Mock annotation = parameter.getAnnotation(Mock.class);
  MockSettings settings = Mockito.withSettings();
  if (annotation.extraInterfaces().length > 0) {
    settings.extraInterfaces(annotation.extraInterfaces());
  }
  if (annotation.serializable()) {
    settings.serializable();
  }
  settings.name(annotation.name().isEmpty() ? parameter.getName() : annotation.name());
  settings.defaultAnswer(annotation.answer());

  return Mockito.mock(parameter.getType(), settings);
}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:16,代码来源:MockParameterFactory.java

示例3: apply

import org.mockito.MockSettings; //导入方法依赖的package包/类
@Override
public MockSettings apply(MockSettings mockSettings) {
	if(Answer.class.equals(answerClass)) {
		return mockSettings;
	}

	return mockSettings.defaultAnswer(createAnswerInstance());
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:9,代码来源:DefaultAnswerMockSettings.java

示例4: createSpy

import org.mockito.MockSettings; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T createSpy(String name, Object instance) {
	Assert.notNull(instance, "Instance must not be null");
	Assert.isInstanceOf(this.classToSpy, instance);
	if (this.mockUtil.isSpy(instance)) {
		return (T) instance;
	}
	MockSettings settings = MockReset.withSettings(getReset());
	if (StringUtils.hasLength(name)) {
		settings.name(name);
	}
	settings.spiedInstance(instance);
	settings.defaultAnswer(Mockito.CALLS_REAL_METHODS);
	return (T) Mockito.mock(instance.getClass(), settings);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:SpyDefinition.java

示例5: createMock

import org.mockito.MockSettings; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T createMock(String name) {
	MockSettings settings = MockReset.withSettings(getReset());
	if (StringUtils.hasLength(name)) {
		settings.name(name);
	}
	if (!this.extraInterfaces.isEmpty()) {
		settings.extraInterfaces(this.extraInterfaces.toArray(new Class<?>[] {}));
	}
	settings.defaultAnswer(getAnswer(this.answer));
	if (this.serializable) {
		settings.serializable();
	}
	return (T) Mockito.mock(this.classToMock, settings);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:MockDefinition.java

示例6: createMock

import org.mockito.MockSettings; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T createMock(String name) {
	MockSettings settings = MockReset.withSettings(getReset());
	if (StringUtils.hasLength(name)) {
		settings.name(name);
	}
	if (!this.extraInterfaces.isEmpty()) {
		settings.extraInterfaces(this.extraInterfaces.toArray(new Class<?>[] {}));
	}
	settings.defaultAnswer(this.answer.get());
	if (this.serializable) {
		settings.serializable();
	}
	return (T) Mockito.mock(this.classToMock, settings);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:16,代码来源:MockDefinition.java

示例7: processAnnotationOn

import org.mockito.MockSettings; //导入方法依赖的package包/类
private Object processAnnotationOn(Mock annotation, Field field) {
    MockSettings mockSettings = Mockito.withSettings();
    if (annotation.extraInterfaces().length > 0) { // never null
        mockSettings.extraInterfaces(annotation.extraInterfaces());
    }
    if ("".equals(annotation.name())) {
        mockSettings.name(field.getName());
    } else {
        mockSettings.name(annotation.name());
    }

    // see @Mock answer default value
    mockSettings.defaultAnswer(annotation.answer().get());
    return Mockito.mock(field.getType(), mockSettings);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:16,代码来源:DefaultAnnotationEngine.java


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