|
|
@ -13,14 +13,7 @@ import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
|
|
|
import org.wso2.carbon.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
|
|
|
|
|
|
|
|
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
|
|
|
|
|
|
|
|
import org.wso2.carbon.policy.mgt.common.ProfileManagementException;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.ProfileManagementException;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.BasePolicyManagementDAOTest;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.BasePolicyManagementDAOTest;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl;
|
|
|
@ -30,9 +23,7 @@ import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.dao.ProfileDAO;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.dao.ProfileDAO;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.dao.ProfileManagerDAOException;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.dao.ProfileManagerDAOException;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.dao.impl.ProfileDAOImpl;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.dao.impl.ProfileDAOImpl;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
|
|
|
|
|
|
|
import org.wso2.carbon.policy.mgt.core.mock.TypeXDeviceManagementService;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.mock.TypeXDeviceManagementService;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.services.SimplePolicyEvaluationTest;
|
|
|
|
|
|
|
|
import org.wso2.carbon.policy.mgt.core.util.FeatureCreator;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.util.FeatureCreator;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.util.ProfileCreator;
|
|
|
|
import org.wso2.carbon.policy.mgt.core.util.ProfileCreator;
|
|
|
|
|
|
|
|
|
|
|
@ -89,7 +80,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
when(profileDAO.addProfile(any(Profile.class))).thenThrow(new ProfileManagerDAOException());
|
|
|
|
when(profileDAO.addProfile(any(Profile.class))).thenThrow(new ProfileManagerDAOException());
|
|
|
|
//Creating profile object
|
|
|
|
//Creating profile object
|
|
|
|
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_C);
|
|
|
|
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_C);
|
|
|
|
testThrowingException(profile, p -> profileManager.addProfile(p), "profileDAO", profileDAO,
|
|
|
|
testThrowingException(profileManager, profile, p -> profileManager.addProfile((Profile) p), "profileDAO",
|
|
|
|
|
|
|
|
profileDAO,
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -101,7 +93,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
new FeatureManagerDAOException());
|
|
|
|
new FeatureManagerDAOException());
|
|
|
|
//Creating profile object
|
|
|
|
//Creating profile object
|
|
|
|
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_C);
|
|
|
|
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_C);
|
|
|
|
testThrowingException(profile, p -> profileManager.addProfile(p), "featureDAO", featureDAO,
|
|
|
|
testThrowingException(profileManager, profile, p -> profileManager.addProfile((Profile) p), "featureDAO",
|
|
|
|
|
|
|
|
featureDAO,
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -139,7 +132,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
String newProfileName = "Updated Test Profile";
|
|
|
|
String newProfileName = "Updated Test Profile";
|
|
|
|
Profile savedProfile = profileManager.getProfile(profile1.getProfileId());
|
|
|
|
Profile savedProfile = profileManager.getProfile(profile1.getProfileId());
|
|
|
|
savedProfile.setProfileName(newProfileName);
|
|
|
|
savedProfile.setProfileName(newProfileName);
|
|
|
|
testThrowingException(savedProfile, p -> profileManager.updateProfile(p), "profileDAO", profileDAO,
|
|
|
|
testThrowingException(profileManager, savedProfile, p -> profileManager.updateProfile((Profile) p),
|
|
|
|
|
|
|
|
"profileDAO", profileDAO,
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -153,7 +147,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
String newProfileName = "Updated Test Profile";
|
|
|
|
String newProfileName = "Updated Test Profile";
|
|
|
|
Profile savedProfile = profileManager.getProfile(profile1.getProfileId());
|
|
|
|
Profile savedProfile = profileManager.getProfile(profile1.getProfileId());
|
|
|
|
savedProfile.setProfileName(newProfileName);
|
|
|
|
savedProfile.setProfileName(newProfileName);
|
|
|
|
testThrowingException(savedProfile, p -> profileManager.updateProfile(p), "featureDAO", featureDAO,
|
|
|
|
testThrowingException(profileManager, savedProfile, p -> profileManager.updateProfile((Profile) p),
|
|
|
|
|
|
|
|
"featureDAO", featureDAO,
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -196,7 +191,9 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testGetProfileThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
public void testGetProfileThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
when(profileDAO.getProfile(anyInt())).thenThrow(new ProfileManagerDAOException());
|
|
|
|
when(profileDAO.getProfile(anyInt())).thenThrow(new ProfileManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.getProfile(p.getProfileId()), "profileDAO", profileDAO,
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getProfile(((Profile) p).getProfileId()),
|
|
|
|
|
|
|
|
"profileDAO",
|
|
|
|
|
|
|
|
profileDAO,
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -205,7 +202,9 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testGetProfileThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
public void testGetProfileThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
when(featureDAO.getFeaturesForProfile(anyInt())).thenThrow(new FeatureManagerDAOException());
|
|
|
|
when(featureDAO.getFeaturesForProfile(anyInt())).thenThrow(new FeatureManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.getProfile(p.getProfileId()), "featureDAO", featureDAO,
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getProfile(((Profile) p).getProfileId()),
|
|
|
|
|
|
|
|
"featureDAO",
|
|
|
|
|
|
|
|
featureDAO,
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -235,7 +234,7 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testGetAllProfilesThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
public void testGetAllProfilesThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
when(profileDAO.getAllProfiles()).thenThrow(new ProfileManagerDAOException());
|
|
|
|
when(profileDAO.getAllProfiles()).thenThrow(new ProfileManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.getAllProfiles(), "profileDAO", profileDAO,
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getAllProfiles(), "profileDAO", profileDAO,
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -244,7 +243,7 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testGetAllProfilesThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
public void testGetAllProfilesThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
when(featureDAO.getAllProfileFeatures()).thenThrow(new FeatureManagerDAOException());
|
|
|
|
when(featureDAO.getAllProfileFeatures()).thenThrow(new FeatureManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.getAllProfiles(), "featureDAO", featureDAO,
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getAllProfiles(), "featureDAO", featureDAO,
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -275,7 +274,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testGetProfilesOfDeviceTypeThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
public void testGetProfilesOfDeviceTypeThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
when(profileDAO.getProfilesOfDeviceType(anyString())).thenThrow(new ProfileManagerDAOException());
|
|
|
|
when(profileDAO.getProfilesOfDeviceType(anyString())).thenThrow(new ProfileManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.getProfilesOfDeviceType(DEVICE_TYPE_C), "profileDAO",
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getProfilesOfDeviceType(DEVICE_TYPE_C),
|
|
|
|
|
|
|
|
"profileDAO",
|
|
|
|
profileDAO,
|
|
|
|
profileDAO,
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -286,7 +286,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testGetProfilesOfDeviceTypeThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
public void testGetProfilesOfDeviceTypeThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
when(featureDAO.getAllProfileFeatures()).thenThrow(new FeatureManagerDAOException());
|
|
|
|
when(featureDAO.getAllProfileFeatures()).thenThrow(new FeatureManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.getProfilesOfDeviceType(DEVICE_TYPE_C), "featureDAO",
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getProfilesOfDeviceType(DEVICE_TYPE_C),
|
|
|
|
|
|
|
|
"featureDAO",
|
|
|
|
featureDAO,
|
|
|
|
featureDAO,
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -311,7 +312,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testDeleteProfileThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
public void testDeleteProfileThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
when(profileDAO.deleteProfile(any(Profile.class))).thenThrow(new ProfileManagerDAOException());
|
|
|
|
when(profileDAO.deleteProfile(any(Profile.class))).thenThrow(new ProfileManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.deleteProfile(profile1), "profileDAO", profileDAO,
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.deleteProfile(profile1), "profileDAO",
|
|
|
|
|
|
|
|
profileDAO,
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -320,7 +322,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
public void testDeleteProfileThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
public void testDeleteProfileThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
when(featureDAO.deleteFeaturesOfProfile(any(Profile.class))).thenThrow(new FeatureManagerDAOException());
|
|
|
|
when(featureDAO.deleteFeaturesOfProfile(any(Profile.class))).thenThrow(new FeatureManagerDAOException());
|
|
|
|
testThrowingException(profile1, p -> profileManager.deleteProfile(profile1), "featureDAO", featureDAO,
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.deleteProfile(profile1), "featureDAO",
|
|
|
|
|
|
|
|
featureDAO,
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|