@Before public void setUp(){ MockitoAnnotations.initMocks( this ); mockStatic( NongBeerServiceManager.class ); mockStatic( RxBus.class ); mockManager = mock( NongBeerServiceManager.class ); when( NongBeerServiceManager.getInstance() ).thenReturn( mockManager ); presenter = new BeerProductFragmentPresenter(); presenter.attachView( mockView ); spyPresenter = spy( presenter ); spyPresenter.attachView( mockView ); Bus mockBus = mock( Bus.class ); when( RxBus.get() ).thenReturn( mockBus ); }
@Before public void setup() { SystemProperties.getDefault().setBlockchainConfig(new FrontierConfig(new FrontierConfig.FrontierConstants() { @Override public BigInteger getMINIMUM_DIFFICULTY() { return BigInteger.ONE; } })); // Initialize mocks created above MockitoAnnotations.initMocks(this); when(ethereum.addNewMinedBlock(any(Block.class))).thenAnswer(new Answer<ImportResult>() { @Override public ImportResult answer(InvocationOnMock invocation) throws Throwable { Block block = (Block) invocation.getArguments()[0]; return bc.getBlockchain().tryToConnect(block); } }); }
@Before public void setup() { MockitoAnnotations.initMocks(this); String mockProfile[] = {"test"}; JHipsterProperties.Ribbon ribbon = new JHipsterProperties.Ribbon(); ribbon.setDisplayOnActiveProfiles(mockProfile); when(jHipsterProperties.getRibbon()).thenReturn(ribbon); String activeProfiles[] = {"test"}; when(environment.getDefaultProfiles()).thenReturn(activeProfiles); when(environment.getActiveProfiles()).thenReturn(activeProfiles); ProfileInfoResource profileInfoResource = new ProfileInfoResource(environment, jHipsterProperties); this.restProfileMockMvc = MockMvcBuilders .standaloneSetup(profileInfoResource) .build(); }
@Before public void setup() { MockitoAnnotations.initMocks(this); mFakeClock = new FakeClock(); mExecutorService = new TestExecutorService(mFakeClock); mDefaultBitmapFramePreparer = new DefaultBitmapFramePreparer( mPlatformBitmapFactory, mBitmapFrameRenderer, BITMAP_CONFIG, mExecutorService); when(mAnimationBackend.getFrameCount()).thenReturn(FRAME_COUNT); when(mAnimationBackend.getIntrinsicWidth()).thenReturn(BACKEND_INTRINSIC_WIDTH); when(mAnimationBackend.getIntrinsicHeight()).thenReturn(BACKEND_INTRINSIC_HEIGHT); when(mBitmapReference.isValid()).thenReturn(true); when(mBitmapReference.get()).thenReturn(mBitmap); }
@Before public void setup() { MockitoAnnotations.initMocks(this); doNothing().when(mockMailService).sendActivationEmail((User) anyObject()); AccountResource accountResource = new AccountResource(); ReflectionTestUtils.setField(accountResource, "userRepository", userRepository); ReflectionTestUtils.setField(accountResource, "userService", userService); ReflectionTestUtils.setField(accountResource, "mailService", mockMailService); AccountResource accountUserMockResource = new AccountResource(); ReflectionTestUtils.setField(accountUserMockResource, "userRepository", userRepository); ReflectionTestUtils.setField(accountUserMockResource, "userService", mockUserService); ReflectionTestUtils.setField(accountUserMockResource, "mailService", mockMailService); this.restMvc = MockMvcBuilders.standaloneSetup(accountResource).build(); this.restUserMockMvc = MockMvcBuilders.standaloneSetup(accountUserMockResource).build(); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); executorProvider = new ExecutorProvider() { @Override public Executor getUiExecutor() { return uiExecutor; } @Override public Executor getComputationExecutor() { return computationExecutor; } @Override public Executor getDiskExecutor() { return diskExecutor; } @Override public Executor getNetworkExecutor() { return networkExecutor; } }; }
@Before public void setUp() { MockitoAnnotations.initMocks(this); setupActivity = Robolectric.setupActivity(TestSetupActivity.class); nicknameEntryWrapper = (TextInputLayout) setupActivity .findViewById(R.id.nickname_entry_wrapper); passwordConfirmationWrapper = (TextInputLayout) setupActivity .findViewById(R.id.password_confirm_wrapper); nicknameEntry = (EditText) setupActivity.findViewById(R.id.nickname_entry); passwordEntry = (EditText) setupActivity.findViewById(R.id.password_entry); passwordConfirmation = (EditText) setupActivity.findViewById(R.id.password_confirm); strengthMeter = (StrengthMeter) setupActivity.findViewById(R.id.strength_meter); createAccountButton = (Button) setupActivity.findViewById(R.id.create_account); }
@Before public void setupTasksPresenter() { // Mockito has a very convenient way to inject mocks by using the @Mock annotation. To // inject the mocks in the test the initMocks method needs to be called. MockitoAnnotations.initMocks(this); // Make the sure that all schedulers are immediate. mSchedulerProvider = new ImmediateSchedulerProvider(); // Get a reference to the class under test mTasksPresenter = new TasksPresenter(mTasksRepository, mTasksView, mSchedulerProvider); // The presenter won't update the view unless it's active. when(mTasksView.isActive()).thenReturn(true); // We subscribe the tasks to 3, with one active and two completed TASKS = Lists.newArrayList(new Task("Title1", "Description1"), new Task("Title2", "Description2", true), new Task("Title3", "Description3", true)); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(capability.getName()).thenReturn("CAP"); for (int i = 0; i < 3; i++) { CommandMetadata mock = mock(CommandMetadata.class); when(mock.getName()).thenReturn("command" + i); when(mock.getCapability()).thenReturn(capability); commands.add(mock); } when(commandMetadataRepository.findAll(eq(CommandEditCommand.SORT))).thenReturn(commands); when(commandMetadataRepository.findByName(eq("test"))).thenReturn(metadata); when(capabilityRepository.findByName(eq("CAP"))).thenReturn(capability); command = new CommandEditCommand(commandMetadataRepository, capabilityRepository); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); gifHeader = Mockito.spy(new GifHeader()); when(parser.parseHeader()).thenReturn(gifHeader); when(parserPool.obtain(isA(ByteBuffer.class))).thenReturn(parser); when(decoderFactory.build(isA(GifDecoder.BitmapProvider.class), eq(gifHeader), isA(ByteBuffer.class), anyInt())) .thenReturn(gifDecoder); List<ImageHeaderParser> parsers = new ArrayList<>(); parsers.add(new DefaultImageHeaderParser()); options = new Options(); decoder = new ByteBufferGifDecoder( RuntimeEnvironment.application, parsers, bitmapPool, new LruArrayPool(ARRAY_POOL_SIZE_BYTES), parserPool, decoderFactory); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); doReturn(false).when(mockRaftActorContext).hasFollowers(); doReturn(mockConfigParams).when(mockRaftActorContext).getConfigParams(); doReturn(10L).when(mockConfigParams).getSnapshotBatchCount(); doReturn(70).when(mockConfigParams).getSnapshotDataThresholdPercentage(); doReturn(mockReplicatedLog).when(mockRaftActorContext).getReplicatedLog(); doReturn("123").when(mockRaftActorContext).getId(); doReturn(mockDataPersistenceProvider).when(mockRaftActorContext).getPersistenceProvider(); doReturn(mockRaftActorBehavior).when(mockRaftActorContext).getCurrentBehavior(); doReturn("123").when(mockRaftActorBehavior).getLeaderId(); doReturn(mockElectionTerm).when(mockRaftActorContext).getTermInformation(); doReturn(5L).when(mockElectionTerm).getCurrentTerm(); doReturn("member5").when(mockElectionTerm).getVotedFor(); doReturn(new FileBackedOutputStreamFactory(10000000, "target")) .when(mockRaftActorContext).getFileBackedOutputStreamFactory(); snapshotManager = new SnapshotManager(mockRaftActorContext, LoggerFactory.getLogger(this.getClass())); factory = new TestActorFactory(getSystem()); actorRef = factory.createActor(MessageCollectorActor.props(), factory.generateActorId("test-")); doReturn(actorRef).when(mockRaftActorContext).getActor(); snapshotManager.setCreateSnapshotConsumer(mockProcedure); }
@Before public void before() throws NoSuchFieldException, IllegalAccessException { MockitoAnnotations.initMocks(this); setField(navigationStateManager, "contextPath", "/context-path"); }
@BeforeMethod void beforeMethod() { this.attributeCache = Mockito.mock(AttributeCache.class); this.externalSubjectAttributeReader = new ExternalSubjectAttributeReader(null, this.attributeCache, 3000); MockitoAnnotations.initMocks(this); }
@BeforeEach public void prepare() { MockitoAnnotations.initMocks(this); when(extensionContext.getStore(Namespace.create(WatcherExtension.class, extensionContext))) .thenReturn(store); sut = new WatcherExtension(logger); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); HttpParams httpParams = new BasicHttpParams(); when(mockHttpClientFactory.create()).thenReturn(mockHttpClient); when(mockHttpClient.getParams()).thenReturn(httpParams); when(mockHttpClient.getConnectionManager()).thenReturn(mockClientConnectionManager); when(mockClientConnectionManager.getSchemeRegistry()).thenReturn(mockSchemeRegistry); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); doReturn(delegateTxChain).when(dataBroker).createTransactionChain(any()); txChain = new ShardedDOMDataBrokerDelegatingTransactionChain("1", TestModel.createTestContext(), dataBroker, txChainlistener); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); when(bluetoothDevice.getAddress()).thenReturn(MAC); DeviceManager.getInstance(RuntimeEnvironment.application).putDevice(device, MAC); subscription = new CharacteristicSubscriptionImpl( RuntimeEnvironment.application, bluetoothDevice, SERVICE_UUID, CHARACTERISTIC_UUID); subscription.setOnCharacteristicsChangedListener(changedListener); }
@PostConstruct public void setup() { MockitoAnnotations.initMocks(this); ContentResource contentResource = new ContentResource(); ReflectionTestUtils.setField(contentResource, "contentRepository", contentRepository); this.restContentMockMvc = MockMvcBuilders.standaloneSetup(contentResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter).build(); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); store = new ValidationProfileStore(); store.setEntityManager(getEm()); store.setQueryFactory(new JPAQueryFactory(getEm())); service = new ValidationService(); service.setValidationProfileStore(store); }
@Before public void setup() { MockitoAnnotations.initMocks(this); TenantContext.setCurrent(new TenantInfo("tenant", "userLogin", "", "protocol", "domain", "port", "")); when(request.getNativeRequest(eq(HttpServletRequest.class))).thenReturn(httpRequest); when(oauth1ConnectionFactory.getOAuthOperations()).thenReturn(oauth1Operations); when(oauth2ConnectionFactory.getOAuthOperations()).thenReturn(oauth2Operations); }
@BeforeEach void beforeEach() throws GfaParseException { MockitoAnnotations.initMocks(this); parser = spyMetadataParser(); gfaFile = createGraph(); cache = new NodeMetadataCache(gfaFile); HygeneEventBus.getInstance().register(cache); }
@Before public void setup() { MockitoAnnotations.initMocks(this); OperinoResource operinoResource = new OperinoResource(operinoService, operinoComponentService); this.restOperinoMockMvc = MockMvcBuilders.standaloneSetup(operinoResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setMessageConverters(jacksonMessageConverter).build(); }
@Before public void setUp() throws IOException { MockitoAnnotations.initMocks(this); initApplicationsMock(); initConfigurationEntriesMock(); initConfigurationSubscriptionsMock(); }
@Before public void setup() throws Exception { MockitoAnnotations.initMocks(this); this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).dispatchOptions(true).build(); this.bookRepository.deleteAllInBatch(); this.book = bookRepository.save(new Book("Tom's adventure", "fine book", "Tom")); this.bookList.add(bookRepository.save(new Book( "Harry Potter and the Cursed Child", "A description", "J. K. Rowling"))); this.bookList.add(bookRepository.save(new Book( "The Lord of the Rings", "The Lord of the Rings is an epic high fantasy novel written by English author and scholar J. R. R. Tolkien.", "J. R. R. Tolkien"))); }
@Before public void setup() { MockitoAnnotations.initMocks(this); SubscriberResource subscriberResource = new SubscriberResource(); ReflectionTestUtils.setField(subscriberResource, "subscriberService", subscriberService); this.restSubscriberMockMvc = MockMvcBuilders.standaloneSetup(subscriberResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter).build(); }
@BeforeEach public void setUp() { MockitoAnnotations.initMocks(this); documentTransformer = new DocumentTransformer(objectMapper); repository = new DecoratingMongoRepository(delegate, documentTransformer); }
@Before public void setup() { MockitoAnnotations.initMocks(this); EntryResource entryResource = new EntryResource(entryRepository, entrySearchRepository); this.restEntryMockMvc = MockMvcBuilders.standaloneSetup(entryResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setMessageConverters(jacksonMessageConverter).build(); }
@PostConstruct public void setup() { MockitoAnnotations.initMocks(this); ImageCompletionExerciseResource imageCompletionExerciseResource = new ImageCompletionExerciseResource(); ReflectionTestUtils.setField(imageCompletionExerciseResource, "imageCompletionExerciseRepository", imageCompletionExerciseRepository); this.restImageCompletionExerciseMockMvc = MockMvcBuilders.standaloneSetup(imageCompletionExerciseResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter).build(); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); uri = Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, "123"); fetcher = new ThumbFetcher(uri, opener); }
@Before public void setupTest() { MockitoAnnotations.initMocks(BookmarkPresenterTest.this); QuranSettings.setInstance(settings); when(appContext.getString(anyInt())).thenReturn("Test"); when(appContext.getResources()).thenReturn(resources); when(resources.getStringArray(anyInt())).thenReturn(RESOURCE_ARRAY); when(appContext.getApplicationContext()).thenReturn(appContext); }
@PostConstruct public void setup() { MockitoAnnotations.initMocks(this); TopicResource topicResource = new TopicResource(); ReflectionTestUtils.setField(topicResource, "topicRepository", topicRepository); this.restTopicMockMvc = MockMvcBuilders.standaloneSetup(topicResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter).build(); }
@Before public void setup() { MockitoAnnotations.initMocks(this); AuditEventService auditEventService = new AuditEventService(auditEventRepository, auditEventConverter); AuditResource auditResource = new AuditResource(auditEventService); this.restAuditMockMvc = MockMvcBuilders.standaloneSetup(auditResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setConversionService(formattingConversionService) .setMessageConverters(jacksonMessageConverter).build(); }
@Before public void setup() { MockitoAnnotations.initMocks(this); BrandResource brandResource = new BrandResource(brandService); this.restBrandMockMvc = MockMvcBuilders.standaloneSetup(brandResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setMessageConverters(jacksonMessageConverter).build(); }
@Before public void setup() { MockitoAnnotations.initMocks(this); router = new RootRouter( view, interactor, component, new LoggedOutBuilder(component), new LoggedInBuilder(component)); }
@Before public void testInitialize() throws Exception { MockitoAnnotations.initMocks(this); this.service.validator = this.validatorMock; when(this.em.getTransaction()).thenReturn(this.tx); when(this.dbMgr.getTransactionalEntityManager()).thenReturn(this.em); when(this.dbMgr.getTransactionControl()).thenReturn(this.txControl); this.txControl.setEntityManager(this.em); }
@Before public void before() { MockitoAnnotations.initMocks(this); when(context.getAuthentication()).thenReturn(authentication); SecurityContextHolder.setContext(context); }
@PostConstruct public void setup() { MockitoAnnotations.initMocks(this); ImageCompletionSolutionResource imageCompletionSolutionResource = new ImageCompletionSolutionResource(); ReflectionTestUtils.setField(imageCompletionSolutionResource, "imageCompletionSolutionRepository", imageCompletionSolutionRepository); this.restImageCompletionSolutionMockMvc = MockMvcBuilders.standaloneSetup(imageCompletionSolutionResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setMessageConverters(jacksonMessageConverter).build(); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); this.spaceGetter = new CFOptimizedSpaceGetter(restTemplateFactory); when(restTemplateFactory.getRestTemplate(client)).thenReturn(restTemplate); when(client.login()).thenReturn(new DefaultOAuth2AccessToken(DUMMY)); when(client.getCloudControllerUrl()).thenReturn(new URL(CONTROLLER_URL)); }
@Before public void setup() { MockitoAnnotations.initMocks(this); doNothing().when(mockMailService).sendSocialRegistrationValidationEmail(anyObject(), anyString()); doNothing().when(mockConnectionRepository).addConnection(anyObject()); when(mockUsersConnectionRepository.createConnectionRepository(anyString())).thenReturn(mockConnectionRepository); socialService = new SocialService(mockUsersConnectionRepository, authorityRepository, passwordEncoder, userRepository, mockMailService, userSearchRepository); }