Java Code Examples for org.mockito.MockitoAnnotations#initMocks()
The following examples show how to use
org.mockito.MockitoAnnotations#initMocks() .
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: ManagedChannelImplTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); expectedUri = new URI(TARGET); when(mockLoadBalancerFactory.newLoadBalancer(any(Helper.class))).thenReturn(mockLoadBalancer); transports = TestUtils.captureTransports(mockTransportFactory); when(mockTransportFactory.getScheduledExecutorService()) .thenReturn(timer.getScheduledExecutorService()); when(executorPool.getObject()).thenReturn(executor.getScheduledExecutorService()); when(balancerRpcExecutorPool.getObject()) .thenReturn(balancerRpcExecutor.getScheduledExecutorService()); channelBuilder = new ChannelBuilder() .nameResolverFactory(new FakeNameResolverFactory.Builder(expectedUri).build()) .loadBalancerFactory(mockLoadBalancerFactory) .userAgent(USER_AGENT) .idleTimeout(AbstractManagedChannelImplBuilder.IDLE_MODE_MAX_TIMEOUT_DAYS, TimeUnit.DAYS); channelBuilder.executorPool = executorPool; channelBuilder.binlog = null; channelBuilder.channelz = channelz; }
Example 2
Source File: BddStepsCounterTests.java From vividus with Apache License 2.0 | 5 votes |
@Before public void before() { MockitoAnnotations.initMocks(this); PowerMockito.mockStatic(Vividus.class); PowerMockito.mockStatic(BeanFactory.class); }
Example 3
Source File: DelayedMessageSchedulerTest.java From rqueue with Apache License 2.0 | 5 votes |
@Before public void init() { MockitoAnnotations.initMocks(this); QueueRegistry.delete(); QueueRegistry.register(fastQueueDetail); QueueRegistry.register(slowQueueDetail); }
Example 4
Source File: VerifyCodeResourceIntTest.java From cubeai with Apache License 2.0 | 5 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); final VerifyCodeResource verifyCodeResource = new VerifyCodeResource(verifyCodeRepository, verifyCodeService); this.restVerifyCodeMockMvc = MockMvcBuilders.standaloneSetup(verifyCodeResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setConversionService(createFormattingConversionService()) .setMessageConverters(jacksonMessageConverter).build(); }
Example 5
Source File: DescriptionResourceIntTest.java From cubeai with Apache License 2.0 | 5 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); final DescriptionResource descriptionResource = new DescriptionResource(descriptionRepository); this.restDescriptionMockMvc = MockMvcBuilders.standaloneSetup(descriptionResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setConversionService(createFormattingConversionService()) .setMessageConverters(jacksonMessageConverter).build(); }
Example 6
Source File: SubscribeHandlerTest.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); handler = new SubscribeHandler(clientSessionSubscriptionPersistence, retainedMessagePersistence, sharedSubscriptionService, eventLog, retainedMessagesSender, mqttConfigurationService); channel = new EmbeddedChannel(handler); channel.attr(ChannelAttributes.CLIENT_ID).set("client"); when(clientSessionSubscriptionPersistence.addSubscription(anyString(), any(Topic.class))).thenReturn(Futures.immediateFuture(null)); when(clientSessionSubscriptionPersistence.addSubscriptions(anyString(), any(ImmutableSet.class))).thenReturn(Futures.<Void>immediateFuture(null)); when(ctx.channel()).thenReturn(channel); when(ctx.writeAndFlush(anyObject())).thenReturn(channelFuture); when(ctx.executor()).thenReturn(ImmediateEventExecutor.INSTANCE); }
Example 7
Source File: ChannelInitializerFactoryImplTest.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Before public void before() { MockitoAnnotations.initMocks(this); channelInitializerFactory = new TestChannelInitializerFactory(channelDependencies, sslFactory, nonSslHandlerProvider); }
Example 8
Source File: PublishPayloadXodusLocalPersistenceTest.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Before public void before() throws Exception { MockitoAnnotations.initMocks(this); InternalConfigurations.PERSISTENCE_CLOSE_RETRIES.set(3); InternalConfigurations.PERSISTENCE_CLOSE_RETRY_INTERVAL.set(5); InternalConfigurations.PAYLOAD_PERSISTENCE_BUCKET_COUNT.set(8); when(localPersistenceFileUtil.getVersionedLocalPersistenceFolder(anyString(), anyString())).thenReturn(temporaryFolder.newFolder()); persistence = new PublishPayloadXodusLocalPersistence(localPersistenceFileUtil, new EnvironmentUtil(), new PersistenceStartup()); persistence.start(); }
Example 9
Source File: DocumentResourceIntTest.java From cubeai with Apache License 2.0 | 5 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); final DocumentResource documentResource = new DocumentResource(documentRepository, solutionRepository); this.restDocumentMockMvc = MockMvcBuilders.standaloneSetup(documentResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setConversionService(createFormattingConversionService()) .setMessageConverters(jacksonMessageConverter).build(); }
Example 10
Source File: RegisterApplicationMasterResponseReflectorTest.java From flink with Apache License 2.0 | 4 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); }
Example 11
Source File: PluginPriorityComparatorTest.java From hivemq-community-edition with Apache License 2.0 | 4 votes |
@Before public void before() { MockitoAnnotations.initMocks(this); comparator = new PluginPriorityComparator(hiveMQExtensions); }
Example 12
Source File: PublishWritePromiseListenerTest.java From hivemq-community-edition with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); }
Example 13
Source File: Mqtt3DisconnectDecoderTest.java From hivemq-community-edition with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); embeddedChannel = new EmbeddedChannel(TestMqttDecoder.create()); }
Example 14
Source File: NetworkInterfaceInformationTest.java From hivemq-community-edition with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); networkInterface = NetworkInterface.getByName("Does_Not_Exist"); networkInterfaceInformation = new NetworkInterfaceInformation(); }
Example 15
Source File: NettyClientHandlerTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
/** * Set up for test. */ @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); doAnswer( new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { StreamListener.MessageProducer producer = (StreamListener.MessageProducer) invocation.getArguments()[0]; InputStream message; while ((message = producer.next()) != null) { streamListenerMessageQueue.add(message); } return null; } }) .when(streamListener) .messagesAvailable(Matchers.<StreamListener.MessageProducer>any()); lifecycleManager = new ClientTransportLifecycleManager(listener); // This mocks the keepalive manager only for there's in which we verify it. For other tests // it'll be null which will be testing if we behave correctly when it's not present. if (setKeepaliveManagerFor.contains(testNameRule.getMethodName())) { mockKeepAliveManager = mock(KeepAliveManager.class); } initChannel(new GrpcHttp2ClientHeadersDecoder(GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE)); streamTransportState = new TransportStateImpl( handler(), channel().eventLoop(), DEFAULT_MAX_MESSAGE_SIZE, transportTracer); streamTransportState.setListener(streamListener); grpcHeaders = new DefaultHttp2Headers() .scheme(HTTPS) .authority(as("www.fake.com")) .path(as("/fakemethod")) .method(HTTP_METHOD) .add(as("auth"), as("sometoken")) .add(CONTENT_TYPE_HEADER, CONTENT_TYPE_GRPC) .add(TE_HEADER, TE_TRAILERS); // Simulate receipt of initial remote settings. ByteBuf serializedSettings = serializeSettings(new Http2Settings()); channelRead(serializedSettings); }
Example 16
Source File: ADCircuitBreakerServiceTests.java From anomaly-detection with Apache License 2.0 | 4 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); }
Example 17
Source File: SendRetainedMessageListenerAndScheduleNextTest.java From hivemq-community-edition with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(channel.eventLoop()).thenReturn(new DefaultEventLoop(Executors.newSingleThreadExecutor())); }
Example 18
Source File: PostgresQueryTest.java From flair-engine with Apache License 2.0 | 4 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); connection = connectionRepository.findByLinkId(POSTGRE_ID); }
Example 19
Source File: PluginOutputAsyncerImplTest.java From hivemq-community-edition with Apache License 2.0 | 4 votes |
@Before public void before() { MockitoAnnotations.initMocks(this); asyncer = new PluginOutputAsyncerImpl(shutdownHooks); }
Example 20
Source File: MessageDroppedServiceImplTest.java From hivemq-community-edition with Apache License 2.0 | 3 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); messageDroppedService = new MessageDroppedServiceImpl(new MetricsHolder(new MetricRegistry()), eventLog); }