Java Code Examples for org.mockito.Mockito#verifyNoInteractions()
The following examples show how to use
org.mockito.Mockito#verifyNoInteractions() .
These examples are extracted from open source projects.
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 Project: jhdf File: ObjectHeaderTest.java License: 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 2
Source Project: dhis2-core File: UserControllerTest.java License: 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 3
Source Project: cxf File: JAXRSClientMetricsTest.java License: 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 4
Source Project: qpid-jms File: OpenTracingTracerFactoryTest.java License: 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 5
Source Project: cxf File: JAXWSClientMetricsTest.java License: 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 6
Source Project: vividus File: WindowsActionsTests.java License: 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 7
Source Project: ditto File: CheckExternalFilterTest.java License: 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 8
Source Project: opentelemetry-java File: AbstractBoundInstrumentTest.java License: 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 9
Source Project: opentelemetry-java File: AbstractBoundInstrumentTest.java License: 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 10
Source Project: qpid-jms File: OpenTracingTracerTest.java License: 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 11
Source Project: cxf File: JAXRSClientMetricsTest.java License: 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 12
Source Project: ditto File: RootRouteExceptionHandlerTest.java License: 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 13
Source Project: multiapps-controller File: ErrorProcessListenerTest.java License: 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 14
Source Project: vespa File: NullContentTestCase.java License: 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 15
Source Project: multiapps-controller File: ErrorProcessListenerTest.java License: 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 16
Source Project: multiapps-controller File: AbortProcessListenerTest.java License: 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 17
Source Project: ditto File: RootRouteExceptionHandlerTest.java License: 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 18
Source Project: ditto File: AcknowledgementForwarderActorStarterTest.java License: 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 19
Source Project: Plan File: ConfigUpdaterTest.java License: GNU Lesser General Public License v3.0 | 4 votes |
@AfterEach void ensureNoErrors() { Mockito.verifyNoInteractions(errorLogger); }
Example 20
Source Project: multiapps-controller File: AbortProcessListenerTest.java License: Apache License 2.0 | 4 votes |
@Test public void testWithWrongEventClass() { abortProcessListenerWithContext.onEvent(Mockito.mock(FlowableEvent.class)); Mockito.verifyNoInteractions(eventHandler); }