Java Code Examples for org.mockito.mockito#verifyNoInteractions()
The following examples show how to use
org.mockito.mockito#verifyNoInteractions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXWSClientMetricsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void usingClientProxyStopIsCalledWhenServerReturnsFault() throws Exception { final JaxWsClientFactoryBean factory = new JaxWsClientFactoryBean(); factory.setAddress("local://services/Book"); factory.setServiceClass(IBookWebService.class); factory.setFeatures(Arrays.asList(new MetricsFeature(provider))); try { final Client client = factory.create(); expectedException.expect(SoapFault.class); client.invoke("getBook", 11); } finally { Mockito.verify(operationContext, times(1)).start(any(Exchange.class)); Mockito.verify(operationContext, times(1)).stop(anyLong(), anyLong(), anyLong(), any(Exchange.class)); Mockito.verify(endpointContext, times(1)).start(any(Exchange.class)); Mockito.verify(endpointContext, times(1)).stop(anyLong(), anyLong(), anyLong(), any(Exchange.class)); Mockito.verifyNoInteractions(resourceContext); } }
Example 2
Source File: ObjectHeaderTest.java From jhdf with MIT License | 6 votes |
@Test void testLazyObjectHeader() throws ConcurrentException, IOException { FileChannel spyFc = Mockito.spy(fc); HdfFileChannel hdfFileChannel = new HdfFileChannel(spyFc, sb); LazyInitializer<ObjectHeader> lazyObjectHeader = ObjectHeader.lazyReadObjectHeader(hdfFileChannel, 10904); // int8 // header // Creating the lazy object header should not touch the file Mockito.verifyNoInteractions(spyFc); // Get the actual header should cause the file to be read lazyObjectHeader.get(); // Check the file was read verify(spyFc, Mockito.atLeastOnce()).read(any(ByteBuffer.class), anyLong()); // Ensure nothing else was done to the file Mockito.verifyNoMoreInteractions(spyFc); }
Example 3
Source File: UserControllerTest.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void updateUserGroupsNotUpdated() { final TypeReport typeReport = new TypeReport( User.class ); typeReport.getStats().incCreated(); final ImportReport importReport = new ImportReport(); importReport.setStatus( Status.OK ); importReport.addTypeReport( typeReport ); if ( importReport.getStatus() == Status.OK && importReport.getStats().getUpdated() == 1 ) { userController.updateUserGroups( "def2", parsedUser, currentUser ); } Mockito.verifyNoInteractions( currentUserService ); Mockito.verifyNoInteractions( userService ); Mockito.verifyNoInteractions( userGroupService ); }
Example 4
Source File: JAXRSClientMetricsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void usingWebClientStopIsCalledWhenServerReturnsNotFound() throws Exception { final WebClient client = WebClient.create("http://localhost:" + wireMockRule.port() + "/books/10", Arrays.asList(JacksonJsonProvider.class), Arrays.asList(new MetricsFeature(provider)), null); stubFor(get(urlEqualTo("/books/10")) .willReturn(aResponse() .withStatus(404))); try { expectedException.expect(ProcessingException.class); client.get().readEntity(Book.class); } finally { Mockito.verify(resourceContext, times(1)).start(any(Exchange.class)); Mockito.verify(resourceContext, times(1)).stop(anyLong(), anyLong(), anyLong(), any(Exchange.class)); Mockito.verify(endpointContext, times(1)).start(any(Exchange.class)); Mockito.verify(endpointContext, times(1)).stop(anyLong(), anyLong(), anyLong(), any(Exchange.class)); Mockito.verifyNoInteractions(operationContext); } }
Example 5
Source File: OpenTracingTracerFactoryTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test public void testCreateWithProvidedTracerCloseProvider() { // As used when setting a JmsTracer on the connection factory Tracer mock = Mockito.mock(Tracer.class); //Check it doesn't close underlying tracer if not asked JmsTracer jmsTracerDontClose = OpenTracingTracerFactory.create(mock, false); Mockito.verifyNoInteractions(mock); jmsTracerDontClose.close(); Mockito.verifyNoInteractions(mock); //Check it does close underlying tracer when asked JmsTracer jmsTracerClose = OpenTracingTracerFactory.create(mock, true); Mockito.verifyNoInteractions(mock); jmsTracerClose.close(); Mockito.verify(mock).close(); Mockito.verifyNoMoreInteractions(mock); }
Example 6
Source File: AcknowledgementForwarderActorStarterTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void getEmptyOptionalIfNoAcknowledgementsRequested() { final DittoHeaders dittoHeaders = DittoHeaders.newBuilder().correlationId(testName.getMethodName()).build(); final AcknowledgementForwarderActorStarter underTest = getActorStarter(dittoHeaders); softly.assertThat(underTest.get()).isNotPresent(); Mockito.verifyNoInteractions(actorContext); }
Example 7
Source File: WindowsActionsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testSwitchToNewWindowNoNewWindow() { when(webDriverProvider.get()).thenReturn(webDriver); TargetLocator targetLocator = mock(TargetLocator.class); mockWindowHandles(WINDOW1); assertEquals(WINDOW1, windowsActions.switchToNewWindow(WINDOW1)); Mockito.verifyNoInteractions(targetLocator); }
Example 8
Source File: RootRouteExceptionHandlerTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void handleCompletionExceptionWithUnhandledRuntimeExceptionAsCause() { final NumberFormatException numberFormatException = new NumberFormatException("42"); final CompletionException completionException = new CompletionException(numberFormatException); final TestRoute testRoute = getTestRoute(() -> { throw completionException; }); testRoute.run(HTTP_REQUEST) .assertStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .assertMediaType(MediaTypes.TEXT_PLAIN); Mockito.verifyNoInteractions(dreToHttpResponse); }
Example 9
Source File: AbortProcessListenerTest.java From multiapps-controller with Apache License 2.0 | 5 votes |
@Test public void testWithEntityCreatedEvent() { FlowableEngineEntityEvent entityCreatedEvent = mockFlowableEngineEvent(FlowableEngineEntityEvent.class, FlowableEngineEventType.ENTITY_CREATED); abortProcessListenerWithContext.onEvent(entityCreatedEvent); Mockito.verifyNoInteractions(eventHandler); }
Example 10
Source File: ErrorProcessListenerTest.java From multiapps-controller with Apache License 2.0 | 5 votes |
@Test public void testEntityCreatedWithNoException() { FlowableEngineEntityEvent engineEntityEvent = Mockito.mock(FlowableEngineEntityEvent.class); DeadLetterJobEntity job = Mockito.mock(DeadLetterJobEntity.class); Mockito.when(engineEntityEvent.getEntity()) .thenReturn(job); errorProcessListener.entityCreated(engineEntityEvent); Mockito.verifyNoInteractions(eventHandler); }
Example 11
Source File: NullContentTestCase.java From vespa with Apache License 2.0 | 5 votes |
@Test public void requireThatWriteThrowsException() { CompletionHandler completion = Mockito.mock(CompletionHandler.class); try { NullContent.INSTANCE.write(ByteBuffer.allocate(69), completion); fail(); } catch (UnsupportedOperationException e) { } Mockito.verifyNoInteractions(completion); }
Example 12
Source File: ErrorProcessListenerTest.java From multiapps-controller with Apache License 2.0 | 5 votes |
@Test public void testJobExecutionFailureWithNoException() { FlowableEngineEntityEvent engineEntityEvent = Mockito.mock(FlowableEngineEntityEvent.class, Mockito.withSettings() .extraInterfaces(FlowableExceptionEvent.class)); errorProcessListener.jobExecutionFailure(engineEntityEvent); Mockito.verifyNoInteractions(eventHandler); }
Example 13
Source File: RootRouteExceptionHandlerTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void handleUnknownErrorAsInternalServerError() { final TestRoute testRoute = getTestRoute(() -> { throw new AssertionError(); }); testRoute.run(HTTP_REQUEST) .assertStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .assertMediaType(MediaTypes.TEXT_PLAIN); Mockito.verifyNoInteractions(dreToHttpResponse); }
Example 14
Source File: JAXRSClientMetricsTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void usingClientStopIsCalledWhenServerReturnSuccessfulResponse() throws Exception { final Client client = ClientBuilder .newClient() .register(new MetricsFeature(provider)) .register(JacksonJsonProvider.class); stubFor(get(urlEqualTo("/books/10")) .withHeader("Accept", equalTo(MediaType.APPLICATION_JSON)) .willReturn(aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON) .withBody("{}") .withStatus(200))); try { client .target("http://localhost:" + wireMockRule.port() + "/books/10") .request(MediaType.APPLICATION_JSON) .get() .readEntity(Book.class); } finally { Mockito.verify(resourceContext, times(1)).start(any(Exchange.class)); Mockito.verify(resourceContext, times(1)).stop(anyLong(), anyLong(), anyLong(), any(Exchange.class)); Mockito.verify(endpointContext, times(1)).start(any(Exchange.class)); Mockito.verify(endpointContext, times(1)).stop(anyLong(), anyLong(), anyLong(), any(Exchange.class)); Mockito.verifyNoInteractions(operationContext); } }
Example 15
Source File: OpenTracingTracerTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testCreateAndClose() { // Test when set TO close the underlying Tracer Tracer mockTracer1 = Mockito.mock(Tracer.class); JmsTracer jmsTracer1 = new OpenTracingTracer(mockTracer1, true); Mockito.verifyNoInteractions(mockTracer1); jmsTracer1.close(); Mockito.verify(mockTracer1).close(); Mockito.verifyNoMoreInteractions(mockTracer1); }
Example 16
Source File: AbstractBoundInstrumentTest.java From opentelemetry-java with Apache License 2.0 | 5 votes |
@Test public void recordLongValue() { TestBoundInstrument testBoundInstrument = new TestBoundInstrument(aggregator); Mockito.verifyNoInteractions(aggregator); Mockito.doNothing().when(aggregator).recordLong(Mockito.anyLong()); testBoundInstrument.recordLong(13); Mockito.verify(aggregator, Mockito.times(1)).recordLong(13); }
Example 17
Source File: AbstractBoundInstrumentTest.java From opentelemetry-java with Apache License 2.0 | 5 votes |
@Test public void recordDoubleValue() { TestBoundInstrument testBoundInstrument = new TestBoundInstrument(aggregator); Mockito.verifyNoInteractions(aggregator); Mockito.doNothing().when(aggregator).recordDouble(Mockito.anyDouble()); testBoundInstrument.recordDouble(1.2); Mockito.verify(aggregator, Mockito.times(1)).recordDouble(1.2); }
Example 18
Source File: CheckExternalFilterTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void filterNullValueShouldWriteToExternal() { final Map<String, HeaderDefinition> headerDefinitions = Mockito.mock(Map.class); final CheckExternalFilter underTest = CheckExternalFilter.shouldWriteToExternal(headerDefinitions); assertThat(underTest.apply("foo", null)).isNull(); Mockito.verifyNoInteractions(headerDefinitions); }
Example 19
Source File: ConfigUpdaterTest.java From Plan with GNU Lesser General Public License v3.0 | 4 votes |
@AfterEach void ensureNoErrors() { Mockito.verifyNoInteractions(errorLogger); }
Example 20
Source File: AbortProcessListenerTest.java From multiapps-controller with Apache License 2.0 | 4 votes |
@Test public void testWithWrongEventClass() { abortProcessListenerWithContext.onEvent(Mockito.mock(FlowableEvent.class)); Mockito.verifyNoInteractions(eventHandler); }