當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。