Improving test cases so that offline instrumentation is not needed

This commit improves the test cases written to the device management rest API component with partial mocking so that the offline instrumentation is not needed to show the code coverage with the jacoco plugin.
revert-70aa11f8
Madawa Soysa 7 years ago
parent f648958143
commit 73a613489f

@ -61,23 +61,6 @@
<goals> <goals>
<goal>prepare-agent</goal> <goal>prepare-agent</goal>
</goals> </goals>
<configuration>
<excludes>
<exclude>org.wso2.carbon.device.mgt.jaxrs.*</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution> </execution>
<execution> <execution>
<id>jacoco-site</id> <id>jacoco-site</id>
@ -86,9 +69,6 @@
<goal>report</goal> <goal>report</goal>
</goals> </goals>
<configuration> <configuration>
<includes>
<include>org.wso2.carbon.device.mgt.jaxrs.*</include>
</includes>
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile> <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory> <outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
</configuration> </configuration>

@ -89,9 +89,8 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing if the device is enrolled when the device is enrolled.") @Test(description = "Testing if the device is enrolled when the device is enrolled.")
public void testIsEnrolledWhenDeviceIsEnrolled() throws Exception { public void testIsEnrolledWhenDeviceIsEnrolled() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.doReturn(this.deviceManagementProviderService) .toReturn(this.deviceManagementProviderService);
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService");
Mockito.when(this.deviceManagementProviderService.isEnrolled(Mockito.any(DeviceIdentifier.class))) Mockito.when(this.deviceManagementProviderService.isEnrolled(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true); .thenReturn(true);
Response response = this.deviceManagementService.isEnrolled(TEST_DEVICE_TYPE, UUID.randomUUID().toString()); Response response = this.deviceManagementService.isEnrolled(TEST_DEVICE_TYPE, UUID.randomUUID().toString());
@ -103,9 +102,8 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing if the device is enrolled when the device is not enrolled.", @Test(description = "Testing if the device is enrolled when the device is not enrolled.",
dependsOnMethods = "testIsEnrolledWhenDeviceIsEnrolled") dependsOnMethods = "testIsEnrolledWhenDeviceIsEnrolled")
public void testIsEnrolledWhenDeviceIsNotEnrolled() throws Exception { public void testIsEnrolledWhenDeviceIsNotEnrolled() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.doReturn(this.deviceManagementProviderService) .toReturn(this.deviceManagementProviderService);
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService");
Mockito.when(this.deviceManagementProviderService.isEnrolled(Mockito.any(DeviceIdentifier.class))) Mockito.when(this.deviceManagementProviderService.isEnrolled(Mockito.any(DeviceIdentifier.class)))
.thenReturn(false); .thenReturn(false);
Response response = this.deviceManagementService.isEnrolled(TEST_DEVICE_TYPE, UUID.randomUUID().toString()); Response response = this.deviceManagementService.isEnrolled(TEST_DEVICE_TYPE, UUID.randomUUID().toString());
@ -117,9 +115,8 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing if the device enrolled api when exception occurred.", @Test(description = "Testing if the device enrolled api when exception occurred.",
dependsOnMethods = "testIsEnrolledWhenDeviceIsNotEnrolled") dependsOnMethods = "testIsEnrolledWhenDeviceIsNotEnrolled")
public void testIsEnrolledError() throws Exception { public void testIsEnrolledError() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.doReturn(this.deviceManagementProviderService) .toReturn(this.deviceManagementProviderService);
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService");
Mockito.when(this.deviceManagementProviderService.isEnrolled(Mockito.any(DeviceIdentifier.class))) Mockito.when(this.deviceManagementProviderService.isEnrolled(Mockito.any(DeviceIdentifier.class)))
.thenThrow(new DeviceManagementException()); .thenThrow(new DeviceManagementException());
Response response = this.deviceManagementService.isEnrolled(TEST_DEVICE_TYPE, UUID.randomUUID().toString()); Response response = this.deviceManagementService.isEnrolled(TEST_DEVICE_TYPE, UUID.randomUUID().toString());
@ -130,11 +127,10 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices when request exists both name and role.") @Test(description = "Testing get devices when request exists both name and role.")
public void testGetDevicesWhenBothNameAndRoleAvailable() throws Exception { public void testGetDevicesWhenBothNameAndRoleAvailable() throws Exception {
PowerMockito.mockStatic(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.doReturn(this.deviceManagementProviderService) .toReturn(this.deviceManagementProviderService);
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
PowerMockito.doReturn(this.deviceAccessAuthorizationService) .toReturn(this.deviceAccessAuthorizationService);
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService");
Response response = this.deviceManagementService Response response = this.deviceManagementService
.getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
DEFAULT_STATUS, 1, null, null, false, 10, 5); DEFAULT_STATUS, 1, null, null, false, 10, 5);
@ -143,18 +139,14 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices with correct request.") @Test(description = "Testing get devices with correct request.")
public void testGetDevices() throws Exception { public void testGetDevices() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.spy(MultitenantUtils.class); .toReturn(this.deviceManagementProviderService);
PowerMockito.spy(CarbonContext.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
.toReturn(this.deviceAccessAuthorizationService);
PowerMockito.doReturn(this.deviceManagementProviderService) PowerMockito.stub(PowerMockito.method(MultitenantUtils.class, "getTenantAwareUsername"))
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); .toReturn(TENANT_AWARE_USERNAME);
PowerMockito.doReturn(this.deviceAccessAuthorizationService) PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"); .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
PowerMockito.doReturn(TENANT_AWARE_USERNAME)
.when(MultitenantUtils.class, "getTenantAwareUsername", Mockito.anyString());
PowerMockito.doReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS))
.when(CarbonContext.class, "getThreadLocalCarbonContext");
Response response = this.deviceManagementService Response response = this.deviceManagementService
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
@ -176,12 +168,10 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices when DeviceAccessAuthorizationService is not available") @Test(description = "Testing get devices when DeviceAccessAuthorizationService is not available")
public void testGetDevicesWithErroneousDeviceAccessAuthorizationService() throws Exception { public void testGetDevicesWithErroneousDeviceAccessAuthorizationService() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
.toReturn(this.deviceManagementProviderService);
PowerMockito.doReturn(this.deviceManagementProviderService) PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); .toReturn(null);
PowerMockito.doReturn(null)
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService");
Response response = this.deviceManagementService Response response = this.deviceManagementService
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
DEFAULT_STATUS, 1, null, null, false, 10, 5); DEFAULT_STATUS, 1, null, null, false, 10, 5);
@ -190,18 +180,14 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices when user is the device admin") @Test(description = "Testing get devices when user is the device admin")
public void testGetDevicesWhenUserIsAdmin() throws Exception { public void testGetDevicesWhenUserIsAdmin() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.spy(MultitenantUtils.class); .toReturn(this.deviceManagementProviderService);
PowerMockito.spy(CarbonContext.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
.toReturn(this.deviceAccessAuthorizationService);
PowerMockito.doReturn(this.deviceManagementProviderService) PowerMockito.stub(PowerMockito.method(MultitenantUtils.class, "getTenantAwareUsername"))
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); .toReturn(TENANT_AWARE_USERNAME);
PowerMockito.doReturn(this.deviceAccessAuthorizationService) PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"); .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
PowerMockito.doReturn(TENANT_AWARE_USERNAME)
.when(MultitenantUtils.class, "getTenantAwareUsername", Mockito.anyString());
PowerMockito.doReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS))
.when(CarbonContext.class, "getThreadLocalCarbonContext");
Mockito.when(deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(true); Mockito.when(deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(true);
Response response = this.deviceManagementService Response response = this.deviceManagementService
@ -216,25 +202,21 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices when user is unauthorized.") @Test(description = "Testing get devices when user is unauthorized.")
public void testGetDevicesWhenUserIsUnauthorized() throws Exception { public void testGetDevicesWhenUserIsUnauthorized() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class);
PowerMockito.spy(MultitenantUtils.class); PowerMockito.spy(MultitenantUtils.class);
PowerMockito.spy(CarbonContext.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
.toReturn(this.deviceManagementProviderService);
PowerMockito.doReturn(this.deviceManagementProviderService) PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); .toReturn(this.deviceAccessAuthorizationService);
PowerMockito.doReturn(this.deviceAccessAuthorizationService) PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"); .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
PowerMockito.doReturn(TENANT_AWARE_USERNAME) PowerMockito.doReturn(TENANT_AWARE_USERNAME)
.when(MultitenantUtils.class, "getTenantAwareUsername", DEFAULT_USERNAME); .when(MultitenantUtils.class, "getTenantAwareUsername", DEFAULT_USERNAME);
PowerMockito.doReturn("newuser@carbon.super") PowerMockito.doReturn("newuser@carbon.super").when(MultitenantUtils.class, "getTenantAwareUsername", "newuser");
.when(MultitenantUtils.class, "getTenantAwareUsername", "newuser");
PowerMockito.doReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS))
.when(CarbonContext.class, "getThreadLocalCarbonContext");
Mockito.when(this.deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(false); Mockito.when(this.deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(false);
Response response = this.deviceManagementService Response response = this.deviceManagementService
.getDevices(null, TEST_DEVICE_TYPE, "newuser", null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, .getDevices(null, TEST_DEVICE_TYPE, "newuser", null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, DEFAULT_STATUS, 1,
DEFAULT_STATUS, 1, null, null, false, 10, 5); null, null, false, 10, 5);
Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode()); Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode());
Mockito.reset(this.deviceAccessAuthorizationService); Mockito.reset(this.deviceAccessAuthorizationService);
} }
@ -242,19 +224,14 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices with IF-Modified-Since") @Test(description = "Testing get devices with IF-Modified-Since")
public void testGetDevicesWithModifiedSince() throws Exception { public void testGetDevicesWithModifiedSince() throws Exception {
String ifModifiedSince = new SimpleDateFormat(DEFAULT_DATE_FORMAT).format(new Date()); String ifModifiedSince = new SimpleDateFormat(DEFAULT_DATE_FORMAT).format(new Date());
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.spy(DeviceMgtAPIUtils.class); .toReturn(this.deviceManagementProviderService);
PowerMockito.spy(MultitenantUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
PowerMockito.spy(CarbonContext.class); .toReturn(this.deviceAccessAuthorizationService);
PowerMockito.stub(PowerMockito.method(MultitenantUtils.class, "getTenantAwareUsername"))
PowerMockito.doReturn(this.deviceManagementProviderService) .toReturn(TENANT_AWARE_USERNAME);
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
PowerMockito.doReturn(this.deviceAccessAuthorizationService) .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService");
PowerMockito.doReturn(TENANT_AWARE_USERNAME)
.when(MultitenantUtils.class, "getTenantAwareUsername", Mockito.anyString());
PowerMockito.doReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS))
.when(CarbonContext.class, "getThreadLocalCarbonContext");
Response response = this.deviceManagementService Response response = this.deviceManagementService
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
@ -273,19 +250,14 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices with Since") @Test(description = "Testing get devices with Since")
public void testGetDevicesWithSince() throws Exception { public void testGetDevicesWithSince() throws Exception {
String since = new SimpleDateFormat(DEFAULT_DATE_FORMAT).format(new Date()); String since = new SimpleDateFormat(DEFAULT_DATE_FORMAT).format(new Date());
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.spy(DeviceMgtAPIUtils.class); .toReturn(this.deviceManagementProviderService);
PowerMockito.spy(MultitenantUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
PowerMockito.spy(CarbonContext.class); .toReturn(this.deviceAccessAuthorizationService);
PowerMockito.stub(PowerMockito.method(MultitenantUtils.class, "getTenantAwareUsername"))
PowerMockito.doReturn(this.deviceManagementProviderService) .toReturn(TENANT_AWARE_USERNAME);
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
PowerMockito.doReturn(this.deviceAccessAuthorizationService) .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService");
PowerMockito.doReturn(TENANT_AWARE_USERNAME)
.when(MultitenantUtils.class, "getTenantAwareUsername", Mockito.anyString());
PowerMockito.doReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS))
.when(CarbonContext.class, "getThreadLocalCarbonContext");
Response response = this.deviceManagementService Response response = this.deviceManagementService
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
@ -303,18 +275,14 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices when unable to retrieve devices") @Test(description = "Testing get devices when unable to retrieve devices")
public void testGetDeviceServerErrorWhenGettingDeviceList() throws Exception { public void testGetDeviceServerErrorWhenGettingDeviceList() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.spy(MultitenantUtils.class); .toReturn(this.deviceManagementProviderService);
PowerMockito.spy(CarbonContext.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
.toReturn(this.deviceAccessAuthorizationService);
PowerMockito.doReturn(this.deviceManagementProviderService) PowerMockito.stub(PowerMockito.method(MultitenantUtils.class, "getTenantAwareUsername"))
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); .toReturn(TENANT_AWARE_USERNAME);
PowerMockito.doReturn(this.deviceAccessAuthorizationService) PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"); .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
PowerMockito.doReturn(TENANT_AWARE_USERNAME)
.when(MultitenantUtils.class, "getTenantAwareUsername", Mockito.anyString());
PowerMockito.doReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS))
.when(CarbonContext.class, "getThreadLocalCarbonContext");
Mockito.when(this.deviceManagementProviderService.getAllDevices(Mockito.any(PaginationRequest.class), Mockito.anyBoolean())) Mockito.when(this.deviceManagementProviderService.getAllDevices(Mockito.any(PaginationRequest.class), Mockito.anyBoolean()))
.thenThrow(new DeviceManagementException()); .thenThrow(new DeviceManagementException());
@ -327,18 +295,14 @@ public class DeviceManagementServiceImplTest {
@Test(description = "Testing get devices when unable to check if the user is the admin user") @Test(description = "Testing get devices when unable to check if the user is the admin user")
public void testGetDevicesServerErrorWhenCheckingAdminUser() throws Exception { public void testGetDevicesServerErrorWhenCheckingAdminUser() throws Exception {
PowerMockito.spy(DeviceMgtAPIUtils.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
PowerMockito.spy(MultitenantUtils.class); .toReturn(this.deviceManagementProviderService);
PowerMockito.spy(CarbonContext.class); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"))
.toReturn(this.deviceAccessAuthorizationService);
PowerMockito.doReturn(this.deviceManagementProviderService) PowerMockito.stub(PowerMockito.method(MultitenantUtils.class, "getTenantAwareUsername"))
.when(DeviceMgtAPIUtils.class, "getDeviceManagementService"); .toReturn(TENANT_AWARE_USERNAME);
PowerMockito.doReturn(this.deviceAccessAuthorizationService) PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
.when(DeviceMgtAPIUtils.class, "getDeviceAccessAuthorizationService"); .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
PowerMockito.doReturn(TENANT_AWARE_USERNAME)
.when(MultitenantUtils.class, "getTenantAwareUsername", DEFAULT_USERNAME);
PowerMockito.doReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS))
.when(CarbonContext.class, "getThreadLocalCarbonContext");
Mockito.when(this.deviceAccessAuthorizationService.isDeviceAdminUser()) Mockito.when(this.deviceAccessAuthorizationService.isDeviceAdminUser())
.thenThrow(new DeviceAccessAuthorizationException()); .thenThrow(new DeviceAccessAuthorizationException());

Loading…
Cancel
Save