@Before public void setup() { when(this.client.getWebConnection()).thenReturn(mock(WebConnection.class)); this.builder = new MockMvcWebConnectionBuilderSupport(this.wac) {}; }
@Before public void setup() { mockStatic(Utility.class); mMockActivity = mock(Activity.class); mMockPackageManager = mock(PackageManager.class); when(mMockActivity.getPackageManager()).thenReturn(mMockPackageManager); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); options = new Options(); when(uriLoader.handles(any(Uri.class))).thenReturn(true); loader = new StringLoader<>(uriLoader); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); when(this.byteSource.getBytes(anyString())).thenReturn( Optional.ofNullable(new byte[1])); this.testee = new JarCreatingJarFinder(this.byteSource); }
@Before public void setUp() throws InvalidTransactionTypeKernelException txState = Mockito.spy( new TxState() ); when( transaction.getReasonIfTerminated() ).thenReturn( Optional.empty() ); when( transaction.statementLocks() ).thenReturn( new SimpleStatementLocks( locks ) ); when( transaction.dataWrite() ).thenReturn( write ); when( transaction.isOpen() ).thenReturn( true ); when( transaction.lockTracer() ).thenReturn( LockTracer.NONE );
@Before public void setUp() throws Exception { reset(requestHandler); when(requestHandler.cancel(anyString(), anyString())).thenReturn(EurekaHttpResponse.status(200)); when(requestHandler.getDelta()).thenReturn( anEurekaHttpResponse(200, new Applications()).type(MediaType.APPLICATION_JSON_TYPE).build() ); }
@Before public void setUp() { initMocks(this); sharedPreferenceListenerCaptor = ArgumentCaptor.forClass(OnSharedPreferenceChangeListener.class); doNothing().when(sharedPreferences).registerOnSharedPreferenceChangeListener( sharedPreferenceListenerCaptor.capture()); updatable = mockUpdatable(); secondUpdatable = mockUpdatable(); }
@Before public void setup() throws SQLException { connection = mock(Connection.class); dbmd = mock(DatabaseMetaData.class); jdbcMetadata = mock(DefaultJdbcMetadata.class); PowerMockito.stub(PowerMockito.method(SqlUtil.class, "getConnection")).toReturn(connection); PowerMockito.mockStatic(JdbcMetadataFactory.class); when(JdbcMetadataFactory.getJdbcMetadata(anyString(), any(DBConnConf.class))).thenReturn(jdbcMetadata); when(connection.getMetaData()).thenReturn(dbmd); jdbcExplorer = spy(JdbcExplorer.class); }
@Before public void setUp() throws Exception { systemEnvironment = mock(SystemEnvironment.class); URLService urlService = mock(URLService.class); GoAgentServerHttpClient httpClient = mock(GoAgentServerHttpClient.class); jvmExitter = mock(AgentUpgradeService.JvmExitter.class); agentUpgradeService = spy(new AgentUpgradeService(urlService, httpClient, systemEnvironment, jvmExitter)); HttpGet httpMethod = mock(HttpGet.class); doReturn(httpMethod).when(agentUpgradeService).getAgentLatestStatusGetMethod(); closeableHttpResponse = mock(CloseableHttpResponse.class); when(closeableHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK")); when(httpClient.execute(httpMethod)).thenReturn(closeableHttpResponse); }
@Before public void setUpPluginRegistry() throws Exception { // Intercept access to registry registry = LifecycleSupport.registry = KettleLifecycleSupport.registry = mock( PluginRegistry.class ); registeredPlugins = new ArrayList<PluginInterface>(); when( registry.getPlugins( KettleLifecyclePluginType.class ) ).thenReturn( registeredPlugins ); typeListenerRegistration = ArgumentCaptor.forClass( PluginTypeListener.class ); doNothing().when( registry ).addPluginListener( eq( KettleLifecyclePluginType.class ), typeListenerRegistration.capture() ); }
@SuppressWarnings("unchecked") @Before public void setUp() { MockitoAnnotations.initMocks(this); when(handler.obtainMessage(anyInt(), isA(DelayTarget.class))).thenReturn(mock(Message.class)); firstFrame = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); ByteBuffer byteBuffer = ByteBuffer.allocate(10); when(gifDecoder.getData()).thenReturn(byteBuffer); requestBuilder = mock(RequestBuilder.class, new ReturnsSelfAnswer()); loader = createGifFrameLoader(handler); }
@Before public void setUp() { query = new Query(queryBody, Optional.empty()); when(session.getId()).thenReturn("session-id"); when(statementParser.parseSingleStatement(anyString())) .thenAnswer(invocation -> new PreparedStatement<>(invocation.getArgument(0).toString(), query)); when(serviceContext.getSchemaRegistryClient()).thenReturn(schemaRegistryClient); when(serviceContext.getTopicClient()).thenReturn(topicClient); when(ksqlEngine.isAcceptingStatements()).thenReturn(true); givenRequest(VALID_REQUEST); wsQueryEndpoint = new WSQueryEndpoint( ksqlConfig, OBJECT_MAPPER, statementParser, ksqlEngine, serviceContext, commandQueue, exec, queryPublisher, topicPublisher, activenessRegistrar, COMMAND_QUEUE_CATCHUP_TIMEOUT); }
@Before public void before() { stringObserver = TestHelper.mockObserver(); for (Thread t : Thread.getAllStackTraces().keySet()) { if (t.getName().startsWith("RxNewThread")) { count++; } } }
@Before public void setUp() { MockitoAnnotations.initMocks(this); context = RuntimeEnvironment.application; doAnswer(new Util.WriteDigest("first")).when(first) .updateDiskCacheKey(any(MessageDigest.class)); doAnswer(new Util.WriteDigest("second")).when(second) .updateDiskCacheKey(any(MessageDigest.class)); }
@Before public void setUp() throws Exception { mockHelper = new StepMockHelper<>( "Add Constants", ConstantMeta.class, ConstantData.class ); when( mockHelper.logChannelInterfaceFactory.create( any(), any( LoggingObjectInterface.class ) ) ).thenReturn( mockHelper.logChannelInterface ); when( mockHelper.trans.isRunning() ).thenReturn( true ); doReturn( rowMetaAndData ).when( mockHelper.stepDataInterface ).getConstants(); constantSpy = Mockito.spy( new Constant( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ) ); }
@Before public void before() throws Exception { mClientContext = ClientContext.create(mConf); mContext = PowerMockito.mock(FileSystemContext.class); mAddress = Mockito.mock(WorkerNetAddress.class); mClient = mock(BlockWorkerClient.class); mRequestObserver = mock(ClientCallStreamObserver.class); PowerMockito.when(mContext.getClientContext()).thenReturn(mClientContext); PowerMockito.when(mContext.getConf()).thenReturn(mConf); PowerMockito.when(mContext.acquireBlockWorkerClient(mAddress)).thenReturn(mClient); PowerMockito.doNothing().when(mContext).releaseBlockWorkerClient(mAddress, mClient); PowerMockito.when(mClient.writeBlock(any(StreamObserver.class))).thenReturn(mRequestObserver); PowerMockito.when(mRequestObserver.isReady()).thenReturn(true); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); doAnswer(new AddBitmapPoolAnswer(addedBitmaps)).when(pool).put(any(Bitmap.class)); when(pool.getDirty(anyInt(), anyInt(), any(Bitmap.Config.class))) .thenAnswer(new CreateBitmap()); when(cache.put(any(Key.class), anyResource())) .thenAnswer(new AddBitmapCacheAnswer(addedBitmaps)); }