本文整理汇总了Java中org.mockito.MockitoAnnotations类的典型用法代码示例。如果您正苦于以下问题:Java MockitoAnnotations类的具体用法?Java MockitoAnnotations怎么用?Java MockitoAnnotations使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MockitoAnnotations类属于org.mockito包,在下文中一共展示了MockitoAnnotations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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 );
}
开发者ID:TheKhaeng,项目名称:nongbeer-mvp-android-demo,代码行数:19,代码来源:BeerProductFragmentPresenterUnitTest.java
示例2: setup
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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);
}
});
}
示例3: setup
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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();
}
示例4: setup
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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);
}
示例5: setup
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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();
}
示例6: setUp
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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;
}
};
}
示例7: setUp
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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);
}
示例8: setupTasksPresenter
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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));
}
示例9: setUp
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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);
}
示例10: setUp
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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);
}
示例11: setUp
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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);
}
示例12: before
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@Before
public void before() throws NoSuchFieldException, IllegalAccessException
{
MockitoAnnotations.initMocks(this);
setField(navigationStateManager, "contextPath", "/context-path");
}
示例13: beforeMethod
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@BeforeMethod
void beforeMethod() {
this.attributeCache = Mockito.mock(AttributeCache.class);
this.externalSubjectAttributeReader = new ExternalSubjectAttributeReader(null, this.attributeCache, 3000);
MockitoAnnotations.initMocks(this);
}
示例14: prepare
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@BeforeEach
public void prepare() {
MockitoAnnotations.initMocks(this);
when(extensionContext.getStore(Namespace.create(WatcherExtension.class, extensionContext)))
.thenReturn(store);
sut = new WatcherExtension(logger);
}
示例15: setUp
import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@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);
}