當前位置: 首頁>>代碼示例>>Java>>正文


Java MockitoAnnotations.initMocks方法代碼示例

本文整理匯總了Java中org.mockito.MockitoAnnotations.initMocks方法的典型用法代碼示例。如果您正苦於以下問題:Java MockitoAnnotations.initMocks方法的具體用法?Java MockitoAnnotations.initMocks怎麽用?Java MockitoAnnotations.initMocks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mockito.MockitoAnnotations的用法示例。


在下文中一共展示了MockitoAnnotations.initMocks方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:ManifestParserTest.java

示例2: setUp

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  exceptionListPool = FactoryPools.threadSafeList();

  multiFactory = new MultiModelLoaderFactory(exceptionListPool,
      multiModelLoaderFactory);
  when(firstFactory.build(eq(multiFactory))).thenReturn(firstModelLoader);
  when(secondFactory.build(eq(multiFactory))).thenReturn(secondModelLoader);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:MultiModelLoaderFactoryTest.java

示例3: setUp

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setUp() throws MalformedURLException {
    MockitoAnnotations.initMocks(this);
    Mockito.when(client.getCloudControllerUrl()).thenReturn(new URL(CONTROLLER_ENDPOINT));
    Mockito.when(client.getApplication(input.application.appName)).thenReturn(input.application.toCloudApp());
    Mockito.when(restTemplateFactory.getRestTemplate(Mockito.eq(client))).thenReturn(restTemplate);
    updateStaging = input.staging.toStaging();
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:9,代碼來源:ApplicationStagingUpdaterTest.java

示例4: testInitialize

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void testInitialize() throws Exception{
    MockitoAnnotations.initMocks(this);

    for (ApplianceManagerConnector mc: TEST_MANAGER_CONNECTORS) {
        doReturn(mc).when(this.em).find(ApplianceManagerConnector.class, mc.getId());
    }

    setupApplianceManagerApiFactory(POLICY_MAPPING_SUPPORTED_MC.getManagerType(), true);
    setupApplianceManagerApiFactory(POLICY_MAPPING_NOT_SUPPORTED_MC.getManagerType(), false);

    when(this.apiFactoryServiceMock.syncsSecurityGroup(POLICY_MAPPING_SUPPORTED_MC.getManagerType())).thenReturn(true);
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:14,代碼來源:MCConformanceCheckMetaTaskTest.java

示例5: setupDiaryPresenter

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setupDiaryPresenter() {
    // 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);

    // Get a reference to the class under test
    mDiaryPresenter = new DiaryPresenter(mDiaryRepository, mDiaryView);
}
 
開發者ID:jgevans,項目名稱:TherapyGuide,代碼行數:10,代碼來源:DiaryPresenterTest.java

示例6: setUp

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
    MockitoAnnotations.initMocks(this);
    globalProperties = new Properties();
    transformerProperties = new TransformerProperties(subsystem, globalProperties);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:8,代碼來源:TransformerPropertiesTest.java

示例7: setup

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    DisciplineResource disciplineResource = new DisciplineResource(disciplineService);
    this.restDisciplineMockMvc = MockMvcBuilders.standaloneSetup(disciplineResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
開發者ID:ElectronicArmory,項目名稱:Armory,代碼行數:10,代碼來源:DisciplineResourceIntTest.java

示例8: setup

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    MultipleChoiceAnswerResource multipleChoiceAnswerResource = new MultipleChoiceAnswerResource();
    ReflectionTestUtils.setField(multipleChoiceAnswerResource, "multipleChoiceAnswerRepository", multipleChoiceAnswerRepository);
    this.restMultipleChoiceAnswerMockMvc = MockMvcBuilders.standaloneSetup(multipleChoiceAnswerResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:10,代碼來源:MultipleChoiceAnswerResourceIntTest.java

示例9: setUp

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setUp(){
	MockitoAnnotations.initMocks(this);
	BankAccount bankAccount = new BankAccount();
	bankAccount.setId(56765l);
	bankAccount.setCpf("25146455732");
	try {
		when(client.create(any(), eq(BankAccount.class))).thenReturn(bankAccount);
		when(client.get(anyLong(), eq(BankAccount.class))).thenReturn(bankAccount);
	} catch (IOException e) {
		fail(e.getMessage());
	}
}
 
開發者ID:ac-silva,項目名稱:desafio-pagarme,代碼行數:14,代碼來源:BankAccountHandlerTest.java

示例10: setup

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setup() {
  MockitoAnnotations.initMocks(this);
  when(bitmapPool.get(anyInt(), anyInt(), any(Bitmap.Config.class)))
      .thenAnswer(new Util.CreateBitmap());
  Context context = RuntimeEnvironment.application;
  Glide.init(new GlideBuilder().setBitmapPool(bitmapPool).build(context));
  circleCrop = new CircleCrop();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:CircleCropTest.java

示例11: setUp

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
}
 
開發者ID:DDD-MicroService-Kata,項目名稱:petstore-order,代碼行數:5,代碼來源:OrderApplicationServiceTest.java

示例12: setup

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:5,代碼來源:ElectionTermImplTest.java

示例13: init

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void init() {
    MockitoAnnotations.initMocks(this);
    PowerMockito.mockStatic(DataStore.class);
    shiftControllerTest = new ShiftController();
}
 
開發者ID:cocolocomoco21,項目名稱:ULCRS,代碼行數:7,代碼來源:ShiftControllerTest.java

示例14: setup

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@Before
public void setup() {
  MockitoAnnotations.initMocks(this);

  interactor = TestRootInteractor.create(presenter);
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:7,代碼來源:RootInteractorTest.java

示例15: setUp

import org.mockito.MockitoAnnotations; //導入方法依賴的package包/類
@BeforeEach
void setUp() {
  MockitoAnnotations.initMocks(this);
  factory = new TableInfoFactory();
}
 
開發者ID:HPI-Information-Systems,項目名稱:AdvancedDataProfilingSeminar,代碼行數:6,代碼來源:TableInfoFactoryTest.java


注:本文中的org.mockito.MockitoAnnotations.initMocks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。