Java Code Examples for org.powermock.api.mockito.PowerMockito#stub()

The following examples show how to use org.powermock.api.mockito.PowerMockito#stub() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityProviderServiceImplTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Test(description = "This method tests getting details of an activity for a given device")
public void testGetActivitiesForInvalidUser() throws OperationManagementException {
    PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "isAdmin")).toReturn(false);
    PowerMockito.stub(PowerMockito.method(RequestValidationUtil.class, "validateActivityId"));
    PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
            .toReturn(this.deviceManagementProviderService);
    Mockito.when(
            this.deviceManagementProviderService.getFilteredActivities(OPERATION_CODE, OFFSET, LIMIT))
            .thenReturn(activities);
    Response response = this.activityInfoProviderService.getActivities(OPERATION_CODE, OFFSET, LIMIT);
    Assert.assertNotNull(response);
    Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode());
    Mockito.reset(this.deviceManagementProviderService);
}
 
Example 2
Source File: RemoteAddLocalAdd.java    From PeerWasp with MIT License 5 votes vote down vote up
@Test
public void localAndRemoteVersionNotEqual() throws Exception {
	PowerMockito.mockStatic(ConflictHandler.class);

	local.put(filePath, file1);
	remote.put(filePath, file2);

	listSync.sync(local, localDatabase, remote, remoteDatabase);

	PowerMockito.stub(PowerMockito.method(ConflictHandler.class, "rename"));
	PowerMockito.verifyStatic();
	ConflictHandler.resolveConflict(Matchers.any(Path.class));

	Mockito.verifyNoMoreInteractions(fileEventManager);
}