当前位置: 首页>>代码示例>>Java>>正文


Java MockitoAnnotations类代码示例

本文整理汇总了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);
        }
    });
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:21,代码来源:ExternalMinerTest.java

示例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();
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:18,代码来源:ProfileInfoResourceIntTest.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DefaultBitmapFramePreparerTest.java

示例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();
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:19,代码来源:AccountResourceIntTest.java

示例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;
		}
	};
}
 
开发者ID:tuenti,项目名称:android-deferred,代码行数:27,代码来源:CallbacksTestBase.java

示例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);
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:20,代码来源:SetupActivityTest.java

示例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));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:TasksPresenterTest.java

示例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);
}
 
开发者ID:scionaltera,项目名称:emergentmud,代码行数:22,代码来源:CommandEditCommandTest.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ByteBufferGifDecoderTest.java

示例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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:30,代码来源:SnapshotManagerTest.java

示例12: before

import org.mockito.MockitoAnnotations; //导入依赖的package包/类
@Before
public void before() throws NoSuchFieldException, IllegalAccessException
{
    MockitoAnnotations.initMocks(this);

    setField(navigationStateManager, "contextPath", "/context-path");
}
 
开发者ID:apm78,项目名称:history-api-navigation,代码行数:8,代码来源:HistoryApiNavigationStateManagerTest.java

示例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);
}
 
开发者ID:eclipse,项目名称:keti,代码行数:8,代码来源:ExternalSubjectAttributeReaderTest.java

示例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);
}
 
开发者ID:glytching,项目名称:junit-extensions,代码行数:10,代码来源:WatcherExtensionMetaTest.java

示例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);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:11,代码来源:WebDavStoreTest.java


注:本文中的org.mockito.MockitoAnnotations类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。