|
|
|
@ -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.policy.mgt.Profile;
|
|
|
|
|
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.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.core.BasePolicyManagementDAOTest;
|
|
|
|
|
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.ProfileManagerDAOException;
|
|
|
|
|
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.services.SimplePolicyEvaluationTest;
|
|
|
|
|
import org.wso2.carbon.policy.mgt.core.util.FeatureCreator;
|
|
|
|
|
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());
|
|
|
|
|
//Creating profile object
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -101,7 +93,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
new FeatureManagerDAOException());
|
|
|
|
|
//Creating profile object
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -139,7 +132,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
String newProfileName = "Updated Test Profile";
|
|
|
|
|
Profile savedProfile = profileManager.getProfile(profile1.getProfileId());
|
|
|
|
|
savedProfile.setProfileName(newProfileName);
|
|
|
|
|
testThrowingException(savedProfile, p -> profileManager.updateProfile(p), "profileDAO", profileDAO,
|
|
|
|
|
testThrowingException(profileManager, savedProfile, p -> profileManager.updateProfile((Profile) p),
|
|
|
|
|
"profileDAO", profileDAO,
|
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -153,7 +147,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
String newProfileName = "Updated Test Profile";
|
|
|
|
|
Profile savedProfile = profileManager.getProfile(profile1.getProfileId());
|
|
|
|
|
savedProfile.setProfileName(newProfileName);
|
|
|
|
|
testThrowingException(savedProfile, p -> profileManager.updateProfile(p), "featureDAO", featureDAO,
|
|
|
|
|
testThrowingException(profileManager, savedProfile, p -> profileManager.updateProfile((Profile) p),
|
|
|
|
|
"featureDAO", featureDAO,
|
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -196,7 +191,9 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testGetProfileThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -205,7 +202,9 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testGetProfileThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -235,7 +234,7 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testGetAllProfilesThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
|
when(profileDAO.getAllProfiles()).thenThrow(new ProfileManagerDAOException());
|
|
|
|
|
testThrowingException(profile1, p -> profileManager.getAllProfiles(), "profileDAO", profileDAO,
|
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getAllProfiles(), "profileDAO", profileDAO,
|
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -244,7 +243,7 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testGetAllProfilesThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
|
when(featureDAO.getAllProfileFeatures()).thenThrow(new FeatureManagerDAOException());
|
|
|
|
|
testThrowingException(profile1, p -> profileManager.getAllProfiles(), "featureDAO", featureDAO,
|
|
|
|
|
testThrowingException(profileManager, profile1, p -> profileManager.getAllProfiles(), "featureDAO", featureDAO,
|
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -275,7 +274,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testGetProfilesOfDeviceTypeThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
|
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,
|
|
|
|
|
ProfileManagerDAOException.class);
|
|
|
|
|
}
|
|
|
|
@ -286,7 +286,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testGetProfilesOfDeviceTypeThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
|
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,
|
|
|
|
|
FeatureManagerDAOException.class);
|
|
|
|
|
}
|
|
|
|
@ -311,7 +312,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testDeleteProfileThrowingProfileManagerDAOException() throws Exception {
|
|
|
|
|
ProfileDAO profileDAO = mock(ProfileDAOImpl.class);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -320,7 +322,8 @@ public class ProfileManagerImplTest extends BasePolicyManagementDAOTest {
|
|
|
|
|
public void testDeleteProfileThrowingFeatureManagerDAOException() throws Exception {
|
|
|
|
|
FeatureDAO featureDAO = mock(FeatureDAO.class);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|