本文整理汇总了Java中org.mockito.Mockito.verifyZeroInteractions方法的典型用法代码示例。如果您正苦于以下问题:Java Mockito.verifyZeroInteractions方法的具体用法?Java Mockito.verifyZeroInteractions怎么用?Java Mockito.verifyZeroInteractions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mockito.Mockito
的用法示例。
在下文中一共展示了Mockito.verifyZeroInteractions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetNavigator
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testSetNavigator()
{
navigationStateManager.setNavigator(null);
Mockito.verifyZeroInteractions(popStateListenerRegistration);
Mockito.verifyZeroInteractions(page);
Mockito.when(page.addPopStateListener(ArgumentMatchers.any(Page.PopStateListener.class)))
.thenReturn(popStateListenerRegistration);
navigationStateManager.setNavigator(navigator);
Mockito.verify(page)
.addPopStateListener(ArgumentMatchers.any(Page.PopStateListener.class));
navigationStateManager.setNavigator(null);
Mockito.verify(popStateListenerRegistration).remove();
}
示例2: should_not_spy_on_spy
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void should_not_spy_on_spy() {
//given
final String spyName = "myService";
final Service spy = Mockito.spy(new Service());
final DoubleDefinition spyDefinition = doubleDefinition(Service.class, spyName);
final ToSpyReplacingProcessor postProcessor = new TestContextBuilder()
.withSpyBean(spyName, spy, spyDefinition)
.withSpy(spyDefinition)
.build()
.toSpyReplacingProcessor;
//when
postProcessor.postProcessAfterInitialization(spy, spyName);
//then
Mockito.verifyZeroInteractions(doubleFactory);
}
示例3: should_never_reset_mock
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void should_never_reset_mock() throws Exception {
//given
final Object mock = Mockito.mock(Object.class, "mock to reset");
final String noResetMockName = "no reset mock";
final TestContext testContext = createTestContext(
new DoubleRegistry(
singletonList(
DoubleDefinition.builder()
.name(noResetMockName)
.doubleClass(Object.class)
.doubleConfiguration(neverReset())
.build()),
emptyList()),
Stream.of(bean(noResetMockName, mock)));
//when
executionListener.beforeTestMethod(testContext);
executionListener.afterTestMethod(testContext);
//then
Mockito.verifyZeroInteractions(resetExecutor);
}
示例4: cpuUsageModuleConstructors
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void cpuUsageModuleConstructors() {
new CpuUsageModule();
new CpuUsageModule(0);
new CpuUsageModule(0, 0);
new CpuUsageModule(mockViewModule);
new CpuUsageModule(0, mockViewModule);
Mockito.verifyZeroInteractions(mockViewModule);
}
示例5: testEmfWithoutProps
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testEmfWithoutProps() throws InvalidSyntaxException, ConfigurationException {
ManagedEMF emf = new ManagedEMF(builder, "test");
emf.updated(null);
Mockito.verifyZeroInteractions(builder);
Hashtable<String, Object> props = new Hashtable<String, Object>();
emf.updated(props);
verify(builder).createEntityManagerFactory(props);
emf.updated(null);
verify(builder).closeEMF();
}
示例6: shouldNotDragStickieWithoutDragStart
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldNotDragStickieWithoutDragStart() throws Exception {
Point<Integer> currentStickiePosition = stickieProperties.getPosition();
Point<Integer> point = new Point<Integer>(666, 777);
stickieDragController.dragMove(point);
Mockito.verifyZeroInteractions(stickiePresenter);
assertEquals(currentStickiePosition, stickieProperties.getPosition());
}
示例7: installModule
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void installModule() throws Exception {
new DebugOverlay.Builder(mockApplication)
.modules(mockOverlayModule)
.build()
.install();
Mockito.verifyZeroInteractions(mockApplication, mockOverlayModule);
}
示例8: testDisallowedMethod
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testDisallowedMethod() throws ServletException, IOException {
// Setup the configuration settings of the server
Map<String, String> conf = new HashMap<String, String>();
conf.put(CrossOriginFilter.ALLOWED_ORIGINS, "example.com");
FilterConfig filterConfig = new FilterConfigTest(conf);
// Origin is not specified for same origin requests
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
Mockito.when(mockReq.getHeader(CrossOriginFilter.ORIGIN)).thenReturn("example.com");
Mockito.when(
mockReq.getHeader(CrossOriginFilter.ACCESS_CONTROL_REQUEST_METHOD))
.thenReturn("DISALLOWED_METHOD");
// Objects to verify interactions based on request
HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
FilterChain mockChain = Mockito.mock(FilterChain.class);
// Object under test
CrossOriginFilter filter = new CrossOriginFilter();
filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockRes);
Mockito.verify(mockChain).doFilter(mockReq, mockRes);
}
示例9: installAppLayer
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void installAppLayer() {
new DebugOverlay.Builder(mockApplication)
.allowSystemLayer(false)
.modules(mockOverlayModule)
.build()
.install();
Mockito.verifyZeroInteractions(mockApplication, mockOverlayModule);
}
示例10: installModulesWithPosition
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void installModulesWithPosition() {
assertEquals(9, Position.values().length);
new DebugOverlay.Builder(mockApplication)
.modules(mockOverlayModule,
new MemInfoModule(mockApplication),
new FpsModule())
.position(Position.values()[0])
.build()
.install();
Mockito.verifyZeroInteractions(mockApplication, mockOverlayModule);
}
示例11: shouldntThrowEventWhenIndexOfCurrentPersonaNotChanged
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldntThrowEventWhenIndexOfCurrentPersonaNotChanged() throws Exception {
// given
int samePersonaIndex = 0;
// when
personaService.setCurrentPersonaIndex(samePersonaIndex);
// then
Mockito.verifyZeroInteractions(eventsBus);
}
示例12: taskNotCalledAsPeriodIsNotPassedYet
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void taskNotCalledAsPeriodIsNotPassedYet() throws InterruptedException {
scheduler.schedulePeriodicTask(task, Long.MAX_VALUE);
Thread.sleep(PERIOD);
scheduler.runTasks();
Mockito.verifyZeroInteractions(task);
}
示例13: testNotificationListenerUnknownNetconfNotification
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testNotificationListenerUnknownNetconfNotification() throws Exception {
final ConfigPersisterNotificationListener testeListener = new ConfigPersisterNotificationListener(persisterAggregator, facadeFactory);
try {
testeListener.handleNotification(unknownNetconfNotif, null);
Assert.fail("Unknown netconf notification should fail");
} catch (final IllegalStateException e) {
Mockito.verifyZeroInteractions(mockPersister);
}
}
示例14: testNoHeaderDefaultConfig_badRequest
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testNoHeaderDefaultConfig_badRequest()
throws ServletException, IOException {
// Setup the configuration settings of the server
FilterConfig filterConfig = Mockito.mock(FilterConfig.class);
Mockito.when(filterConfig.getInitParameter(
RestCsrfPreventionFilter.CUSTOM_HEADER_PARAM)).thenReturn(null);
Mockito.when(filterConfig.getInitParameter(
RestCsrfPreventionFilter.CUSTOM_METHODS_TO_IGNORE_PARAM)).
thenReturn(null);
// CSRF has not been sent
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_DEFAULT)).
thenReturn(null);
Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_USER_AGENT)).
thenReturn(BROWSER_AGENT);
// Objects to verify interactions based on request
HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
FilterChain mockChain = Mockito.mock(FilterChain.class);
// Object under test
RestCsrfPreventionFilter filter = new RestCsrfPreventionFilter();
filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain);
verify(mockRes, atLeastOnce()).sendError(
HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
Mockito.verifyZeroInteractions(mockChain);
}
示例15: testNoHeaderCustomAgentConfig_badRequest
import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testNoHeaderCustomAgentConfig_badRequest()
throws ServletException, IOException {
// Setup the configuration settings of the server
FilterConfig filterConfig = Mockito.mock(FilterConfig.class);
Mockito.when(filterConfig.getInitParameter(
RestCsrfPreventionFilter.CUSTOM_HEADER_PARAM)).thenReturn(null);
Mockito.when(filterConfig.getInitParameter(
RestCsrfPreventionFilter.CUSTOM_METHODS_TO_IGNORE_PARAM)).
thenReturn(null);
Mockito.when(filterConfig.getInitParameter(
RestCsrfPreventionFilter.BROWSER_USER_AGENT_PARAM)).
thenReturn("^Mozilla.*,^Opera.*,curl");
// CSRF has not been sent
HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_DEFAULT)).
thenReturn(null);
Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_USER_AGENT)).
thenReturn("curl");
// Objects to verify interactions based on request
HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
FilterChain mockChain = Mockito.mock(FilterChain.class);
// Object under test
RestCsrfPreventionFilter filter = new RestCsrfPreventionFilter();
filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain);
verify(mockRes, atLeastOnce()).sendError(
HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
Mockito.verifyZeroInteractions(mockChain);
}