@Before public void before() throws Exception { MockitoAnnotations.initMocks(this); loader = spy(new FilterLoader(registry, compiler, filterFactory)); doReturn(TestZuulFilter.class).when(compiler).compile(file); when(file.getAbsolutePath()).thenReturn("/filters/in/SomeFilter.groovy"); }
@Before public void setUp() throws Exception { this.databaseOperator = mock(DatabaseOperator.class); this.storage = mock(Storage.class); when(this.databaseOperator.query( eq(StorageCleaner.SQL_FETCH_PVR), anyObject(), eq(TEST_PROJECT_ID))) .thenReturn(Arrays.asList("14/14-9.zip", "14/14-8.zip", "14/14-7.zip")); when(this.storage.delete("14/14-8.zip")).thenReturn(true); when(this.storage.delete("14/14-7.zip")).thenReturn(false); when(this.databaseOperator.update(any(), anyVararg())).thenReturn(1); }
@Before public void setUp() throws Exception { when(this.createSession.save()).thenReturn(Mono.empty()); when(this.createSession.getId()).thenReturn("create-session-id"); when(this.updateSession.getId()).thenReturn("update-session-id"); when(this.sessionStore.createWebSession()).thenReturn(Mono.just(this.createSession)); when(this.sessionStore.retrieveSession(this.updateSession.getId())).thenReturn(Mono.just(this.updateSession)); this.sessionManager = new DefaultWebSessionManager(); this.sessionManager.setSessionIdResolver(this.sessionIdResolver); this.sessionManager.setSessionStore(this.sessionStore); MockServerHttpRequest request = MockServerHttpRequest.get("/path").build(); MockServerHttpResponse response = new MockServerHttpResponse(); this.exchange = new DefaultServerWebExchange(request, response, this.sessionManager, ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); }
@Before public void setup() { when(this.client.getWebConnection()).thenReturn(mock(WebConnection.class)); this.builder = new MockMvcWebConnectionBuilderSupport(this.wac) {}; }
@Before public void setUp() throws IOException { MockitoAnnotations.initMocks(this); String assetPath = "/some/asset/path"; fetcher = new StreamAssetPathFetcher(assetManager, assetPath); when(assetManager.open(eq(assetPath))).thenReturn(expected); }
@Before public void setUp() throws PackageManager.NameNotFoundException { MockitoAnnotations.initMocks(this); applicationInfo = new ApplicationInfo(); applicationInfo.metaData = new Bundle(); String packageName = "com.bumptech.test"; when(context.getPackageName()).thenReturn(packageName); PackageManager pm = mock(PackageManager.class); when(pm.getApplicationInfo(eq(packageName), eq(PackageManager.GET_META_DATA))) .thenReturn(applicationInfo); when(context.getPackageManager()).thenReturn(pm); parser = new ManifestParser(context); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); when(arrayPool.get(anyInt(), eq(byte[].class))) .thenAnswer(new Answer<byte[]>() { @Override public byte[] answer(InvocationOnMock invocation) throws Throwable { int size = (Integer) invocation.getArguments()[0]; return new byte[size]; } }); }
@Before public void setup() { MockitoAnnotations.initMocks(this); this.exchangeFunction = mock(ExchangeFunction.class); when(this.exchangeFunction.exchange(this.captor.capture())).thenReturn(Mono.empty()); this.builder = WebClient.builder().baseUrl("/base").exchangeFunction(this.exchangeFunction); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); WebSocketClient webSocketClient = mock(WebSocketClient.class); this.stompClient = new TestWebSocketStompClient(webSocketClient); this.stompClient.setTaskScheduler(this.taskScheduler); this.stompClient.setStompSession(this.stompSession); this.webSocketHandlerCaptor = ArgumentCaptor.forClass(WebSocketHandler.class); this.handshakeFuture = new SettableListenableFuture<>(); when(webSocketClient.doHandshake(this.webSocketHandlerCaptor.capture(), any(), any(URI.class))) .thenReturn(this.handshakeFuture); }
@Before public void setUp() throws IOException { MockitoAnnotations.initMocks(this); URL url = new URL("http://www.google.com"); when(connectionFactory.build(eq(url))).thenReturn(urlConnection); when(urlConnection.getInputStream()).thenReturn(stream); when(urlConnection.getResponseCode()).thenReturn(200); when(glideUrl.toURL()).thenReturn(url); fetcher = new HttpUrlFetcher(glideUrl, TIMEOUT_MS, connectionFactory); }
@SuppressWarnings("unchecked") @Before public void setUp() { viewTransitionAnimationFactory = mock(ViewTransition.ViewTransitionAnimationFactory.class); view = mock(ImageView.class); adapter = mock(ViewAdapter.class); when(adapter.getView()).thenReturn(view); viewAnimation = new ViewTransition<>(viewTransitionAnimationFactory); }