/** * Verify a private method invocation for a class with a given verification * mode. * * @see {@link Mockito#verify(Object)} * @throws Exception * If something unexpected goes wrong. */ public static PrivateMethodVerification verifyPrivate(Class<?> clazz, VerificationMode verificationMode) throws Exception { return verifyPrivate((Object) clazz, verificationMode); }
public static PowerMockitoStubber doReturn(Object toBeReturned, Object... othersToBeReturned) { if (othersToBeReturned != null && othersToBeReturned.length == 0) { return doReturn(toBeReturned); } return POWERMOCKITO_CORE.doAnswer(new ChainReturns(toBeReturned, othersToBeReturned)); } }
public final void currentSecurityContextPowermockSetup() throws Exception { spy(DelegatingSecurityContextCallable.class); doReturn(wrappedCallable).when(DelegatingSecurityContextCallable.class, "create", callable, null); spy(DelegatingSecurityContextRunnable.class); doReturn(wrappedRunnable).when(DelegatingSecurityContextRunnable.class, "create", runnable, null); }
private void setupShellMocks(String username, List<String> groups) throws IOException { PowerMockito.mockStatic(ShellUtils.class); String shellResult = ""; for (String group: groups) { shellResult = shellResult + " " + group; } PowerMockito.when( ShellUtils.execCommand(ShellUtils.getGroupsForUserCommand(Mockito.eq(username)))) .thenReturn(shellResult); }
@Before public void setUp() { PowerMockito.mockStatic( AttributesUtil.class ); }
@Override public OperatorStateBackend createOperatorStateBackend( Environment env, String operatorIdentifier) throws Exception { return spy(delegate.createOperatorStateBackend(env, operatorIdentifier)); }
@Before public void setUp() throws Exception { PowerMockito.mockStatic(Stats.class); }
@Override public CheckpointStorage createCheckpointStorage(JobID jobId) throws IOException { return spy(delegate.createCheckpointStorage(jobId)); } }
/** * Verify a private method invocation for a class. * * @see {@link Mockito#verify(Object)} * @throws Exception * If something unexpected goes wrong. */ public static PrivateMethodVerification verifyPrivate(Class<?> clazz) throws Exception { return verifyPrivate((Object) clazz); }
@Before public void before() throws Exception { mockStatic(NativeAppCallAttachmentStore.class); providerUnderTest = new FacebookContentProvider(); }
private Intent createErrorResultIntent() { Intent intent = new Intent(); LoginClient.Request request = mock(LoginClient.Request.class); LoginClient.Result result = LoginClient.Result.createErrorResult(request, "foo", "bar"); intent.putExtra(LoginFragment.RESULT_KEY, result); return intent; }
@Override public CompletedCheckpointStorageLocation resolveCheckpoint(String externalPointer) throws IOException { return spy(delegate.resolveCheckpoint(externalPointer)); }
/** * Verify a private method invocation for an instance. * * @see {@link Mockito#verify(Object)} * @throws Exception * If something unexpected goes wrong. */ public static PrivateMethodVerification verifyPrivate(Object object) throws Exception { return verifyPrivate(object, times(1)); }
private Intent createCancelResultIntent() { Intent intent = new Intent(); LoginClient.Request request = mock(LoginClient.Request.class); LoginClient.Result result = LoginClient.Result.createCancelResult(request, null); intent.putExtra(LoginFragment.RESULT_KEY, result); return intent; }
@Override public <K> AbstractKeyedStateBackend<K> createKeyedStateBackend( Environment env, JobID jobID, String operatorIdentifier, TypeSerializer<K> keySerializer, int numberOfKeyGroups, KeyGroupRange keyGroupRange, TaskKvStateRegistry kvStateRegistry, TtlTimeProvider ttlTimeProvider, MetricGroup metricGroup) throws IOException { return spy(delegate.createKeyedStateBackend( env, jobID, operatorIdentifier, keySerializer, numberOfKeyGroups, keyGroupRange, kvStateRegistry, ttlTimeProvider, metricGroup)); }
@Before public void before() { mWorkerId = 0; mJobMasterClient = Mockito.mock(JobMasterClient.class); mTaskExecutorManager = PowerMockito.mock(TaskExecutorManager.class); WorkerNetAddress workerNetAddress = PowerMockito.mock(WorkerNetAddress.class); mUfsManager = Mockito.mock(UfsManager.class); mCommandHandlingExecutor = new CommandHandlingExecutor(mTaskExecutorManager, mUfsManager, mJobMasterClient, workerNetAddress); }
@Test(expected = CoprocessorException.class) public void testStart() throws IOException { CoprocessorEnvironment env = PowerMockito.mock(RegionServerCoprocessorEnvironment.class); CubeVisitService service = new CubeVisitService(); service.start(env); }