mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Fix test failures in Android plugins
This commit is contained in:
parent
f35050c24a
commit
acbfdad962
@ -34,42 +34,24 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.mobile.android.api.impl;
|
package org.wso2.carbon.device.mgt.mobile.android.api.impl;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import com.google.api.client.http.HttpStatusCodes;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
||||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
|
||||||
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
|
||||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
|
||||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
|
|
||||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.api.DeviceManagementAPI;
|
import org.wso2.carbon.device.mgt.mobile.android.api.DeviceManagementAPI;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.Message;
|
import org.wso2.carbon.device.mgt.mobile.android.common.Message;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidApplication;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidApplication;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseUser;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException;
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.exception.NotFoundException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException;
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService;
|
import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils;
|
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils;
|
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
@ -87,7 +69,6 @@ import javax.ws.rs.Produces;
|
|||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Path("/devices")
|
@Path("/devices")
|
||||||
@ -129,30 +110,23 @@ public class DeviceManagementAPIImpl implements DeviceManagementAPI {
|
|||||||
log.error(msg);
|
log.error(msg);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||||
}
|
}
|
||||||
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
try {
|
try {
|
||||||
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
||||||
androidService.getPendingOperations(id, resultOperations);
|
List<? extends Operation> pendingOperations = androidService
|
||||||
} catch (DeviceManagementException e) {
|
.getPendingOperations(id, resultOperations, disableGoogleApps);
|
||||||
String msg = "Issue in retrieving device management service instance";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new UnexpectedServerErrorException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<? extends Operation> pendingOperations;
|
|
||||||
try {
|
|
||||||
pendingOperations = AndroidDeviceUtils.getPendingOperations(deviceIdentifier, !disableGoogleApps);
|
|
||||||
} catch (OperationManagementException e) {
|
|
||||||
String msg = "Issue in retrieving operation management service instance";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new UnexpectedServerErrorException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.CREATED).entity(pendingOperations).build();
|
return Response.status(Response.Status.CREATED).entity(pendingOperations).build();
|
||||||
|
} catch (InvalidDeviceException e) {
|
||||||
|
String msg = "Device identifier is invalid. Device identifier " + id;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while getting pending operations of the device.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new UnexpectedServerErrorException(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
|
||||||
|
.setMessage(msg).build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Override
|
@Override
|
||||||
@ -184,13 +158,13 @@ public class DeviceManagementAPIImpl implements DeviceManagementAPI {
|
|||||||
try {
|
try {
|
||||||
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
||||||
Message responseMessage = androidService.isEnrolled(id, deviceIdentifier);
|
Message responseMessage = androidService.isEnrolled(id, deviceIdentifier);
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).build();
|
return Response.status(Integer.parseInt(responseMessage.getResponseCode())).entity(responseMessage).build();
|
||||||
|
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while checking enrollment status of the device.";
|
String msg = "Error occurred while checking enrollment status of the device.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
|
||||||
|
.setMessage(msg).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,13 +172,9 @@ public class DeviceManagementAPIImpl implements DeviceManagementAPI {
|
|||||||
@Path("/{id}")
|
@Path("/{id}")
|
||||||
@Override
|
@Override
|
||||||
public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) {
|
public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) {
|
||||||
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
|
||||||
Device device = androidService.modifyEnrollment(id, androidDevice);
|
|
||||||
boolean result;
|
|
||||||
try {
|
try {
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
if (androidService.modifyEnrollment(id, androidDevice)) {
|
||||||
if (result) {
|
|
||||||
Message responseMessage = new Message();
|
Message responseMessage = new Message();
|
||||||
responseMessage.setResponseCode(Response.Status.ACCEPTED.toString());
|
responseMessage.setResponseCode(Response.Status.ACCEPTED.toString());
|
||||||
responseMessage.setResponseMessage("Enrollment of Android device that " +
|
responseMessage.setResponseMessage("Enrollment of Android device that " +
|
||||||
@ -230,11 +200,9 @@ public class DeviceManagementAPIImpl implements DeviceManagementAPI {
|
|||||||
@Path("/{id}")
|
@Path("/{id}")
|
||||||
@Override
|
@Override
|
||||||
public Response disEnrollDevice(@PathParam("id") String id) {
|
public Response disEnrollDevice(@PathParam("id") String id) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
AndroidService androidService = AndroidAPIUtils.getAndroidService();
|
||||||
boolean result = androidService.disEnrollDevice(id);
|
if (androidService.disEnrollDevice(id)) {
|
||||||
if (result) {
|
|
||||||
String msg = "Android device that carries id '" + id + "' is successfully ";
|
String msg = "Android device that carries id '" + id + "' is successfully ";
|
||||||
Message responseMessage = new Message();
|
Message responseMessage = new Message();
|
||||||
responseMessage.setResponseCode(Response.Status.OK.toString());
|
responseMessage.setResponseCode(Response.Status.OK.toString());
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.android.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the exception thrown during validating the request.
|
||||||
|
*/
|
||||||
|
public class NotFoundExceptionDup extends AndroidDeviceMgtPluginException {
|
||||||
|
|
||||||
|
public NotFoundExceptionDup(String message, Throwable ex) {
|
||||||
|
super(message, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotFoundExceptionDup(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -22,6 +22,8 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|||||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
@ -119,11 +121,12 @@ public interface AndroidService {
|
|||||||
//DeviceManagementAPIImpl
|
//DeviceManagementAPIImpl
|
||||||
Message updateApplicationList(String id, List<AndroidApplication> androidApplications) throws ApplicationManagementException;
|
Message updateApplicationList(String id, List<AndroidApplication> androidApplications) throws ApplicationManagementException;
|
||||||
|
|
||||||
void getPendingOperations(String id, List<? extends Operation> resultOperations) throws DeviceManagementException;
|
List<? extends Operation> getPendingOperations(String id, List<? extends Operation> resultOperations, boolean disableGoogleApps)
|
||||||
|
throws DeviceManagementException, InvalidDeviceException;
|
||||||
|
|
||||||
Response enrollDevice(AndroidDevice androidDevice) throws DeviceManagementException;
|
Response enrollDevice(AndroidDevice androidDevice) throws DeviceManagementException;
|
||||||
|
|
||||||
Device modifyEnrollment(String id, AndroidDevice androidDevice);
|
boolean modifyEnrollment(String id, AndroidDevice androidDevice) throws DeviceManagementException;
|
||||||
|
|
||||||
boolean disEnrollDevice(String id) throws DeviceManagementException;
|
boolean disEnrollDevice(String id) throws DeviceManagementException;
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.android.core.impl;
|
package org.wso2.carbon.device.mgt.mobile.android.core.impl;
|
||||||
|
|
||||||
|
import com.google.api.client.http.HttpStatusCodes;
|
||||||
import com.google.api.services.androidenterprise.model.ProductsListResponse;
|
import com.google.api.services.androidenterprise.model.ProductsListResponse;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@ -35,6 +36,7 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
|||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException;
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
||||||
@ -261,9 +263,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setPayLoad(file.toJSON());
|
operation.setPayLoad(file.toJSON());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(fileTransferBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(fileTransferBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found.";
|
String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -288,8 +289,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setPayLoad(lock.toJSON());
|
operation.setPayLoad(lock.toJSON());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -305,8 +305,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK);
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
operation.setEnabled(true);
|
operation.setEnabled(true);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -321,8 +320,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION);
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -337,8 +335,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD);
|
operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -361,8 +358,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.CAMERA);
|
operation.setCode(AndroidConstants.OperationCodes.CAMERA);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
operation.setEnabled(camera.isEnabled());
|
operation.setEnabled(camera.isEnabled());
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(cameraBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(cameraBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -377,8 +373,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -393,8 +388,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.LOGCAT);
|
operation.setCode(AndroidConstants.OperationCodes.LOGCAT);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -409,8 +403,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE);
|
operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -433,8 +426,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA);
|
operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(wipeData.toJSON());
|
operation.setPayLoad(wipeData.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(wipeDataBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(wipeDataBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -449,8 +441,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST);
|
operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -465,8 +456,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING);
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -481,8 +471,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT);
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -497,8 +486,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
CommandOperation operation = new CommandOperation();
|
CommandOperation operation = new CommandOperation();
|
||||||
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_TASK_MODE);
|
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_TASK_MODE);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -514,8 +502,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE);
|
operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
operation.setEnabled(true);
|
operation.setEnabled(true);
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -545,9 +532,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION);
|
operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(applicationInstallation.toJSON());
|
operation.setPayLoad(applicationInstallation.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -575,9 +561,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(applicationUpdate.toJSON());
|
operation.setPayLoad(applicationUpdate.toJSON());
|
||||||
|
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(applicationUpdateBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(applicationUpdateBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -603,9 +588,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION);
|
operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(applicationUninstallation.toJSON());
|
operation.setPayLoad(applicationUninstallation.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(applicationUninstallationBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(applicationUninstallationBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -628,9 +612,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS);
|
operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(blacklistApplications.toJSON());
|
operation.setPayLoad(blacklistApplications.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(blacklistApplicationsBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(blacklistApplicationsBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -655,9 +638,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE);
|
operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(upgradeFirmware.toJSON());
|
operation.setPayLoad(upgradeFirmware.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(upgradeFirmwareBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(upgradeFirmwareBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -680,8 +662,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.VPN);
|
operation.setCode(AndroidConstants.OperationCodes.VPN);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(vpn.toJSON());
|
operation.setPayLoad(vpn.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(vpnConfiguration.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(vpnConfiguration.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -704,8 +685,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION);
|
operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(notification.toJSON());
|
operation.setPayLoad(notification.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(notificationBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(notificationBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -729,8 +709,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(wifi.toJSON());
|
operation.setPayLoad(wifi.toJSON());
|
||||||
|
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(wifiBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(wifiBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -753,8 +732,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE);
|
operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
operation.setEnabled(deviceEncryption.isEncrypted());
|
operation.setEnabled(deviceEncryption.isEncrypted());
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(encryptionBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(encryptionBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -777,8 +755,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE);
|
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(lockCode.toJSON());
|
operation.setPayLoad(lockCode.toJSON());
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(lockCodeBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(lockCodeBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -802,9 +779,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(passcodePolicy.toJSON());
|
operation.setPayLoad(passcodePolicy.toJSON());
|
||||||
|
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(passwordPolicyBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(passwordPolicyBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -829,8 +805,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(webClip.toJSON());
|
operation.setPayLoad(webClip.toJSON());
|
||||||
|
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(webClipBeanWrapper.getDeviceIDs(), operation);
|
return AndroidDeviceUtils.getOperationResponse(webClipBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
log.error(errorMessage, e);
|
log.error(errorMessage, e);
|
||||||
@ -856,9 +831,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(globalProxy.toJSON());
|
operation.setPayLoad(globalProxy.toJSON());
|
||||||
|
|
||||||
Activity activity = AndroidDeviceUtils
|
return AndroidDeviceUtils
|
||||||
.getOperationResponse(globalProxyBeanWrapper.getDeviceIDs(), operation);
|
.getOperationResponse(globalProxyBeanWrapper.getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
} else {
|
} else {
|
||||||
String errorMessage = "The payload of the global proxy operation is incorrect";
|
String errorMessage = "The payload of the global proxy operation is incorrect";
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
@ -890,9 +864,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setPayLoad(configureDisplayMessage.toJSON());
|
operation.setPayLoad(configureDisplayMessage.toJSON());
|
||||||
|
|
||||||
Activity activity = AndroidDeviceUtils.getOperationResponse(displayMessageBeanWrapper.
|
return AndroidDeviceUtils.getOperationResponse(displayMessageBeanWrapper.
|
||||||
getDeviceIDs(), operation);
|
getDeviceIDs(), operation);
|
||||||
return activity;
|
|
||||||
|
|
||||||
} catch (InvalidDeviceException e) {
|
} catch (InvalidDeviceException e) {
|
||||||
String errorMessage = "Invalid Device Identifiers found.";
|
String errorMessage = "Invalid Device Identifiers found.";
|
||||||
@ -935,46 +908,66 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getPendingOperations(String id, List<? extends Operation> resultOperations) throws DeviceManagementException {
|
public List<? extends Operation> getPendingOperations(String deviceId, List<? extends Operation> resultOperations,
|
||||||
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
|
boolean disableGoogleApps) throws DeviceManagementException, InvalidDeviceException {
|
||||||
|
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(deviceId);
|
||||||
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
||||||
String msg = "Device not found for identifier '" + id + "'";
|
String msg = "Device not found for identifier '" + deviceId + "'";
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new NotFoundException(
|
throw new InvalidDeviceException(msg);
|
||||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build());
|
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Invoking Android pending operations:" + id);
|
log.debug("Invoking Android pending operations:" + deviceId);
|
||||||
}
|
}
|
||||||
if (resultOperations != null && !resultOperations.isEmpty()) {
|
if (resultOperations != null && !resultOperations.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
updateOperations(id, resultOperations);
|
for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : resultOperations) {
|
||||||
|
AndroidDeviceUtils.updateOperation(deviceId, operation);
|
||||||
|
if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) {
|
||||||
|
org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new org.wso2.carbon.device.mgt.common.notification.mgt.Notification();
|
||||||
|
DeviceIdentifier id = new DeviceIdentifier();
|
||||||
|
id.setId(deviceId);
|
||||||
|
id.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||||
|
String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName();
|
||||||
|
notification.setOperationId(operation.getId());
|
||||||
|
notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification.
|
||||||
|
Status.NEW.toString());
|
||||||
|
notification.setDescription(
|
||||||
|
operation.getCode() + " operation failed to execute on device " + deviceName + " (ID: "
|
||||||
|
+ deviceId + ")");
|
||||||
|
AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification);
|
||||||
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Updating operation '" + operation.toString() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String msg = "Issue in retrieving operation management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
} catch (PolicyComplianceException e) {
|
||||||
|
String msg = "Issue in updating Monitoring operation";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
} catch (org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException e) {
|
||||||
|
String msg = "Issue in retrieving application management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
} catch (NotificationManagementException e) {
|
||||||
|
String msg = "Issue in retrieving Notification management service instance";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return AndroidDeviceUtils.getPendingOperations(deviceIdentifier, !disableGoogleApps);
|
||||||
} catch (OperationManagementException e) {
|
} catch (OperationManagementException e) {
|
||||||
String msg = "Issue in retrieving operation management service instance";
|
String msg = "Issue in retrieving operation management service instance";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
|
||||||
} catch (PolicyComplianceException e) {
|
.setMessage(msg).build());
|
||||||
String msg = "Issue in updating Monitoring operation";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new UnexpectedServerErrorException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Issue in retrieving device management service instance";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new UnexpectedServerErrorException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
||||||
} catch (org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException e) {
|
|
||||||
String msg = "Issue in retrieving application management service instance";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new UnexpectedServerErrorException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
||||||
} catch (NotificationManagementException e) {
|
|
||||||
String msg = "Issue in retrieving Notification management service instance";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new UnexpectedServerErrorException(
|
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1114,7 +1107,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device modifyEnrollment(String id, AndroidDevice androidDevice){
|
public boolean modifyEnrollment(String id, AndroidDevice androidDevice) throws DeviceManagementException {
|
||||||
Device device;
|
Device device;
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
deviceIdentifier.setId(id);
|
deviceIdentifier.setId(id);
|
||||||
@ -1161,16 +1154,14 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
if(androidDevice.getProperties() != null) {
|
if(androidDevice.getProperties() != null) {
|
||||||
device.setProperties(androidDevice.getProperties());
|
device.setProperties(androidDevice.getProperties());
|
||||||
}
|
}
|
||||||
return device;
|
return AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean disEnrollDevice(String id) throws DeviceManagementException{
|
public boolean disEnrollDevice(String id) throws DeviceManagementException{
|
||||||
boolean result;
|
|
||||||
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
|
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
|
||||||
AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier);
|
AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier);
|
||||||
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
return AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1292,31 +1283,6 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOperations(String deviceId, List<? extends Operation> operations)
|
|
||||||
throws OperationManagementException, PolicyComplianceException,
|
|
||||||
org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException, NotificationManagementException, DeviceManagementException {
|
|
||||||
for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) {
|
|
||||||
AndroidDeviceUtils.updateOperation(deviceId, operation);
|
|
||||||
if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) {
|
|
||||||
org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new
|
|
||||||
org.wso2.carbon.device.mgt.common.notification.mgt.Notification();
|
|
||||||
DeviceIdentifier id = new DeviceIdentifier();
|
|
||||||
id.setId(deviceId);
|
|
||||||
id.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
|
|
||||||
String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName();
|
|
||||||
notification.setOperationId(operation.getId());
|
|
||||||
notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification.
|
|
||||||
Status.NEW.toString());
|
|
||||||
notification.setDescription(operation.getCode() + " operation failed to execute on device " +
|
|
||||||
deviceName + " (ID: " + deviceId + ")");
|
|
||||||
AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification);
|
|
||||||
}
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Updating operation '" + operation.toString() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the device location
|
* Extracts the device location
|
||||||
*
|
*
|
||||||
@ -1402,7 +1368,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
List<AndroidEnterpriseUser> androidEnterpriseUsers = AndroidAPIUtils.getAndroidPluginService()
|
List<AndroidEnterpriseUser> androidEnterpriseUsers = AndroidAPIUtils.getAndroidPluginService()
|
||||||
.getEnterpriseUser(CarbonContext.getThreadLocalCarbonContext().getUsername());
|
.getEnterpriseUser(CarbonContext.getThreadLocalCarbonContext().getUsername());
|
||||||
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
||||||
if (androidEnterpriseUsers != null && androidEnterpriseUsers.size() > 0) {
|
if (androidEnterpriseUsers != null && !androidEnterpriseUsers.isEmpty()) {
|
||||||
googleUserId = androidEnterpriseUsers.get(0).getGoogleUserId();
|
googleUserId = androidEnterpriseUsers.get(0).getGoogleUserId();
|
||||||
// If this device is also present, only need to provide a token for this request.
|
// If this device is also present, only need to provide a token for this request.
|
||||||
for (AndroidEnterpriseUser enterprise : androidEnterpriseUsers) {
|
for (AndroidEnterpriseUser enterprise : androidEnterpriseUsers) {
|
||||||
@ -1430,9 +1396,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|||||||
|
|
||||||
AndroidAPIUtils.getAndroidPluginService().addEnterpriseUser(androidEnterpriseUser);
|
AndroidAPIUtils.getAndroidPluginService().addEnterpriseUser(androidEnterpriseUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -18,294 +18,290 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.android.core;
|
package org.wso2.carbon.device.mgt.mobile.android.core;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.testng.PowerMockObjectFactory;
|
import org.powermock.modules.testng.PowerMockObjectFactory;
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.IObjectFactory;
|
import org.testng.IObjectFactory;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.ObjectFactory;
|
import org.testng.annotations.ObjectFactory;
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.android.core.impl.AndroidServiceImpl;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceManagementProviderServiceMock;
|
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceManagementProviderServiceMock;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils.TestUtils;
|
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils.TestUtils;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils;
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"})
|
||||||
@PrepareForTest(AndroidAPIUtils.class)
|
@PrepareForTest(AndroidAPIUtils.class)
|
||||||
public class DeviceManagementAdminServiceTests {
|
public class DeviceManagementAdminServiceTests {
|
||||||
|
|
||||||
// private DeviceManagementAdminServiceImpl deviceManagementAdminService;
|
private AndroidServiceImpl androidService;
|
||||||
|
|
||||||
@ObjectFactory
|
@ObjectFactory
|
||||||
public IObjectFactory getObjectFactory() {
|
public IObjectFactory getObjectFactory() {
|
||||||
return new PowerMockObjectFactory();
|
return new PowerMockObjectFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @BeforeClass
|
@BeforeClass
|
||||||
// public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
public void init() {
|
||||||
// MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
// deviceManagementAdminService = new DeviceManagementAdminServiceImpl();
|
androidService = new AndroidServiceImpl();
|
||||||
// }
|
}
|
||||||
|
|
||||||
private void mockDeviceManagementService()
|
private void mockDeviceManagementService() {
|
||||||
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService"))
|
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService"))
|
||||||
.toReturn(new DeviceManagementProviderServiceMock());
|
.toReturn(new DeviceManagementProviderServiceMock());
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void testConfigureDeviceLock()
|
public void testConfigureDeviceLock() throws OperationManagementException {
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
mockDeviceManagementService();
|
||||||
// mockDeviceManagementService();
|
Activity activity = androidService.configureDeviceLock(TestUtils.getDeviceLockBeanWrapper());
|
||||||
// Response response = deviceManagementAdminService.configureDeviceLock(TestUtils.getDeviceLockBeanWrapper());
|
Assert.assertNotNull(activity);
|
||||||
// Assert.assertNotNull(response);
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testConfigureDeviceUnlock()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.configureDeviceUnlock(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetDeviceLocation()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.getDeviceLocation(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testRemovePassword()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.removePassword(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testConfigureCamera()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.configureCamera(TestUtils.getCamerabeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetDeviceInformation()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.getDeviceInformation(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetDeviceLogcat()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.getDeviceLogcat(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testWipeDevice()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.wipeDevice(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testWipeData()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.wipeData(TestUtils.getWipeDataBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetApplications()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.getApplications(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testRingDevice()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.ringDevice(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testRebootDevice()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.rebootDevice(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testChangeLockTask()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.changeLockTask(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testMuteDevice()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.muteDevice(TestUtils.getDeviceIds());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testInstallApplication()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService
|
|
||||||
// .installApplication(TestUtils.getApplicationInstallationBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testUpdateApplication()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.updateApplication(TestUtils.getApplicationUpdateBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testUninstallApplicationPublic()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService
|
|
||||||
// .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperPublic());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testUninstallApplicationWebApp()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService
|
|
||||||
// .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperWebApp());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testBlacklistApplications()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService
|
|
||||||
// .blacklistApplications(TestUtils.getBlacklistApplicationsBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testUpgradeFirmware()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.upgradeFirmware(TestUtils.getUpgradeFirmwareBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testConfigureVPN()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.configureVPN(TestUtils.getVpnBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testSendNotification()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.sendNotification(TestUtils.getNotificationBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testConfigureWifi()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.configureWifi(TestUtils.getWifiBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testEncryptStorage()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.encryptStorage(TestUtils.getEncryptionBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testChangeLockCode()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.changeLockCode(TestUtils.getLockCodeBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testSetPasswordPolicy()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.setPasswordPolicy(TestUtils.getPasswordPolicyBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testSetWebClip()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementAdminService.setWebClip(TestUtils.getWebClipBeanWrapper());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigureDeviceUnlock()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.configureDeviceUnlock(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetDeviceLocation()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.getDeviceLocation(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemovePassword()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.removePassword(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigureCamera()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.configureCamera(TestUtils.getCamerabeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetDeviceInformation()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.getDeviceInformation(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetDeviceLogcat()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.getDeviceLogcat(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWipeDevice()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.wipeDevice(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWipeData()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.wipeData(TestUtils.getWipeDataBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetApplications()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.getApplications(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRingDevice()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.ringDevice(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRebootDevice()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.rebootDevice(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangeLockTask()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.changeLockTask(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMuteDevice()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.muteDevice(TestUtils.getDeviceIds());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInstallApplication()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService
|
||||||
|
.installApplication(TestUtils.getApplicationInstallationBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateApplication()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.updateApplication(TestUtils.getApplicationUpdateBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUninstallApplicationPublic()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService
|
||||||
|
.uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperPublic());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUninstallApplicationWebApp()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService
|
||||||
|
.uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperWebApp());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlacklistApplications()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService
|
||||||
|
.blacklistApplications(TestUtils.getBlacklistApplicationsBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpgradeFirmware()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.upgradeFirmware(TestUtils.getUpgradeFirmwareBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigureVPN()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.configureVPN(TestUtils.getVpnBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSendNotification()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.sendNotification(TestUtils.getNotificationBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigureWifi()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.configureWifi(TestUtils.getWifiBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEncryptStorage()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.encryptStorage(TestUtils.getEncryptionBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangeLockCode()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.changeLockCode(TestUtils.getLockCodeBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetPasswordPolicy()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.setPasswordPolicy(TestUtils.getPasswordPolicyBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetWebClip()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Activity activity = androidService.setWebClip(TestUtils.getWebClipBeanWrapper());
|
||||||
|
Assert.assertNotNull(activity);
|
||||||
|
Assert.assertNotNull(activity.getActivityId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -29,10 +29,14 @@ import org.testng.annotations.BeforeClass;
|
|||||||
import org.testng.annotations.ObjectFactory;
|
import org.testng.annotations.ObjectFactory;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.android.common.Message;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.android.core.impl.AndroidServiceImpl;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.ApplicationManagementProviderServiceMock;
|
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.ApplicationManagementProviderServiceMock;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceInformationManagerServiceMock;
|
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceInformationManagerServiceMock;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceManagementProviderServiceMock;
|
import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceManagementProviderServiceMock;
|
||||||
@ -49,285 +53,275 @@ import java.util.List;
|
|||||||
@PrepareForTest(AndroidAPIUtils.class)
|
@PrepareForTest(AndroidAPIUtils.class)
|
||||||
public class DeviceManagementServiceTests {
|
public class DeviceManagementServiceTests {
|
||||||
|
|
||||||
// private DeviceManagementServiceImpl deviceManagementService;
|
private AndroidServiceImpl androidService;
|
||||||
|
|
||||||
// @ObjectFactory
|
|
||||||
// public IObjectFactory getObjectFactory() {
|
|
||||||
// return new PowerMockObjectFactory();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @BeforeClass
|
|
||||||
// public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// MockitoAnnotations.initMocks(this);
|
|
||||||
// deviceManagementService = new DeviceManagementServiceImpl();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void mockDeviceManagementService()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService"))
|
|
||||||
// .toReturn(new DeviceManagementProviderServiceMock());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void mockApplicationManagerService()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getApplicationManagerService"))
|
|
||||||
// .toReturn(new ApplicationManagementProviderServiceMock());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void mockPolicyManagerService()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getPolicyManagerService"))
|
|
||||||
// .toReturn(new PolicyManagerServiceMock());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void mockDeviceInformationManagerService()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceInformationManagerService"))
|
|
||||||
// .toReturn(new DeviceInformationManagerServiceMock());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void mockNotificationManagementService()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getNotificationManagementService"))
|
|
||||||
// .toReturn(new NotificationManagementServiceMock());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void mockUser()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getAuthenticatedUser"))
|
|
||||||
// .toReturn("admin");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testUpdateApplicationList()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockApplicationManagerService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .updateApplicationList(TestUtils.getDeviceId(), TestUtils.getAndroidApplications());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsForNullDevice()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, null, null, null);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsInvalidDevice()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, "1234", null, null);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsNullResponse()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, TestUtils.getDeviceId(), null, null);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsWithMonitorResponse()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockPolicyManagerService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, TestUtils.getDeviceId(), null,
|
|
||||||
// TestUtils.getSuccessMonitorOperationResponse());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsWithApplicationResponse()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockApplicationManagerService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, TestUtils.getDeviceId(), null,
|
|
||||||
// TestUtils.getSuccessApplicationOperationResponse());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsWithDeviceInfoResponse()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockDeviceInformationManagerService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, TestUtils.getDeviceId(), null,
|
|
||||||
// TestUtils.getSuccessInfoOperationResponse());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsWithInProgressResponse()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, TestUtils.getDeviceId(), null,
|
|
||||||
// TestUtils.getInProgressOperationResponse());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testGetPendingOperationsWithErrorResponse()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockNotificationManagementService();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .getPendingOperations(true, TestUtils.getDeviceId(), null,
|
|
||||||
// TestUtils.getErrorOperationResponse());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testEnrollDeviceWithoutLocationSuccess()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockPolicyManagerService();
|
|
||||||
// mockUser();
|
|
||||||
// Response response = deviceManagementService.enrollDevice(TestUtils.getBasicAndroidDevice());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testEnrollDeviceWithLocationSuccess()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockDeviceInformationManagerService();
|
|
||||||
// mockPolicyManagerService();
|
|
||||||
// mockUser();
|
|
||||||
// AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
|
||||||
//
|
|
||||||
// List<Device.Property> properties = new ArrayList<>();
|
|
||||||
// Device.Property property = new Device.Property();
|
|
||||||
// property.setName("LATITUDE");
|
|
||||||
// property.setValue("79.5");
|
|
||||||
// properties.add(property);
|
|
||||||
// property = new Device.Property();
|
|
||||||
// property.setName("LONGITUDE");
|
|
||||||
// property.setValue("6.9");
|
|
||||||
// properties.add(property);
|
|
||||||
// property = new Device.Property();
|
|
||||||
// property.setName("ALTITUDE");
|
|
||||||
// property.setValue("-59.8373726");
|
|
||||||
// properties.add(property);
|
|
||||||
// property = new Device.Property();
|
|
||||||
// property.setName("SPEED");
|
|
||||||
// property.setValue("0.5123423333");
|
|
||||||
// properties.add(property);
|
|
||||||
// property = new Device.Property();
|
|
||||||
// property.setName("BEARING");
|
|
||||||
// property.setValue("44.0");
|
|
||||||
// properties.add(property);
|
|
||||||
// property = new Device.Property();
|
|
||||||
// property.setName("DISTANCE");
|
|
||||||
// property.setValue("44.0");
|
|
||||||
// properties.add(property);
|
|
||||||
// androidDevice.setProperties(properties);
|
|
||||||
//
|
|
||||||
// Response response = deviceManagementService.enrollDevice(androidDevice);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testEnrollDeviceUnSuccess()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockUser();
|
|
||||||
// AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
|
||||||
// androidDevice.setDeviceIdentifier("1234");
|
|
||||||
// Response response = deviceManagementService.enrollDevice(androidDevice);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testIsEnrolledExists()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService.isEnrolled(TestUtils.getDeviceId(), null);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testIsEnrolledNonExist()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService.isEnrolled("1234", null);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testIsEnrolledNull()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService.isEnrolled(null, null);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testModifyEnrollmentSuccess()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockUser();
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .modifyEnrollment(TestUtils.getDeviceId(), TestUtils.getBasicAndroidDevice());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testModifyEnrollmentUnSuccess()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// mockUser();
|
|
||||||
// AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
|
||||||
// androidDevice.setDeviceIdentifier("1234");
|
|
||||||
// Response response = deviceManagementService
|
|
||||||
// .modifyEnrollment(TestUtils.getDeviceId(), androidDevice);
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testDisEnrollDeviceSuccess()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId());
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testDisenrollUnSuccess()
|
|
||||||
// throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
|
||||||
// mockDeviceManagementService();
|
|
||||||
// Response response = deviceManagementService.disEnrollDevice("1234");
|
|
||||||
// Assert.assertNotNull(response);
|
|
||||||
// Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
@ObjectFactory
|
||||||
|
public IObjectFactory getObjectFactory() {
|
||||||
|
return new PowerMockObjectFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
androidService = new AndroidServiceImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mockDeviceManagementService()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService"))
|
||||||
|
.toReturn(new DeviceManagementProviderServiceMock());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mockApplicationManagerService()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getApplicationManagerService"))
|
||||||
|
.toReturn(new ApplicationManagementProviderServiceMock());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mockPolicyManagerService()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getPolicyManagerService"))
|
||||||
|
.toReturn(new PolicyManagerServiceMock());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mockDeviceInformationManagerService()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceInformationManagerService"))
|
||||||
|
.toReturn(new DeviceInformationManagerServiceMock());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mockNotificationManagementService()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getNotificationManagementService"))
|
||||||
|
.toReturn(new NotificationManagementServiceMock());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mockUser()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getAuthenticatedUser"))
|
||||||
|
.toReturn("admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateApplicationList()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException,
|
||||||
|
ApplicationManagementException {
|
||||||
|
mockApplicationManagerService();
|
||||||
|
Message message = androidService
|
||||||
|
.updateApplicationList(TestUtils.getDeviceId(), TestUtils.getAndroidApplications());
|
||||||
|
Assert.assertNotNull(message);
|
||||||
|
Assert.assertEquals(message.getResponseCode(), Response.Status.ACCEPTED.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test (expectedExceptions = {InvalidDeviceException.class})
|
||||||
|
public void testGetPendingOperationsForNullDevice()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
List<? extends Operation> resultOperations = new ArrayList<>();
|
||||||
|
androidService.getPendingOperations(null, resultOperations, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test (expectedExceptions = {InvalidDeviceException.class})
|
||||||
|
public void testGetPendingOperationsForInvalidDevice()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
List<? extends Operation> resultOperations = new ArrayList<>();
|
||||||
|
androidService.getPendingOperations("1234", resultOperations, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPendingOperationsNullResponse()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
List<? extends Operation> pendingOperations = androidService
|
||||||
|
.getPendingOperations(TestUtils.getDeviceId(), null, true);
|
||||||
|
Assert.assertNotNull(pendingOperations);
|
||||||
|
Assert.assertFalse((pendingOperations.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPendingOperationsWithMonitorResponse()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockPolicyManagerService();
|
||||||
|
List<? extends Operation> pendingOperations = androidService
|
||||||
|
.getPendingOperations(TestUtils.getDeviceId(), TestUtils.getSuccessMonitorOperationResponse(), true);
|
||||||
|
Assert.assertNotNull(pendingOperations);
|
||||||
|
Assert.assertFalse((pendingOperations.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPendingOperationsWithApplicationResponse()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockApplicationManagerService();
|
||||||
|
List<? extends Operation> pendingOperations = androidService
|
||||||
|
.getPendingOperations(TestUtils.getDeviceId(), TestUtils.getSuccessApplicationOperationResponse(),
|
||||||
|
true);
|
||||||
|
Assert.assertNotNull(pendingOperations);
|
||||||
|
Assert.assertFalse((pendingOperations.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPendingOperationsWithDeviceInfoResponse()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockDeviceInformationManagerService();
|
||||||
|
List<? extends Operation> pendingOperations = androidService
|
||||||
|
.getPendingOperations(TestUtils.getDeviceId(),
|
||||||
|
TestUtils.getSuccessInfoOperationResponse(), true);
|
||||||
|
Assert.assertNotNull(pendingOperations);
|
||||||
|
Assert.assertFalse((pendingOperations.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPendingOperationsWithInProgressResponse()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
List<? extends Operation> pendingOperations = androidService
|
||||||
|
.getPendingOperations(TestUtils.getDeviceId(),
|
||||||
|
TestUtils.getInProgressOperationResponse(), true);
|
||||||
|
Assert.assertNotNull(pendingOperations);
|
||||||
|
Assert.assertFalse((pendingOperations.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPendingOperationsWithErrorResponse()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockNotificationManagementService();
|
||||||
|
List<? extends Operation> pendingOperations = androidService
|
||||||
|
.getPendingOperations(TestUtils.getDeviceId(),
|
||||||
|
TestUtils.getErrorOperationResponse(), true);
|
||||||
|
Assert.assertNotNull(pendingOperations);
|
||||||
|
Assert.assertFalse((pendingOperations.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnrollDeviceWithoutLocationSuccess()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockPolicyManagerService();
|
||||||
|
mockUser();
|
||||||
|
Response response = androidService.enrollDevice(TestUtils.getBasicAndroidDevice());
|
||||||
|
Assert.assertNotNull(response);
|
||||||
|
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnrollDeviceWithLocationSuccess()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockDeviceInformationManagerService();
|
||||||
|
mockPolicyManagerService();
|
||||||
|
mockUser();
|
||||||
|
AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
||||||
|
|
||||||
|
List<Device.Property> properties = new ArrayList<>();
|
||||||
|
Device.Property property = new Device.Property();
|
||||||
|
property.setName("LATITUDE");
|
||||||
|
property.setValue("79.5");
|
||||||
|
properties.add(property);
|
||||||
|
property = new Device.Property();
|
||||||
|
property.setName("LONGITUDE");
|
||||||
|
property.setValue("6.9");
|
||||||
|
properties.add(property);
|
||||||
|
property = new Device.Property();
|
||||||
|
property.setName("ALTITUDE");
|
||||||
|
property.setValue("-59.8373726");
|
||||||
|
properties.add(property);
|
||||||
|
property = new Device.Property();
|
||||||
|
property.setName("SPEED");
|
||||||
|
property.setValue("0.5123423333");
|
||||||
|
properties.add(property);
|
||||||
|
property = new Device.Property();
|
||||||
|
property.setName("BEARING");
|
||||||
|
property.setValue("44.0");
|
||||||
|
properties.add(property);
|
||||||
|
property = new Device.Property();
|
||||||
|
property.setName("DISTANCE");
|
||||||
|
property.setValue("44.0");
|
||||||
|
properties.add(property);
|
||||||
|
androidDevice.setProperties(properties);
|
||||||
|
|
||||||
|
Response response = androidService.enrollDevice(androidDevice);
|
||||||
|
Assert.assertNotNull(response);
|
||||||
|
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnrollDeviceUnSuccess()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockUser();
|
||||||
|
AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
||||||
|
androidDevice.setDeviceIdentifier("1234");
|
||||||
|
Response response = androidService.enrollDevice(androidDevice);
|
||||||
|
Assert.assertNotNull(response);
|
||||||
|
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsEnrolledExists()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Message message = androidService.isEnrolled(TestUtils.getDeviceId(), null);
|
||||||
|
Assert.assertNotNull(message);
|
||||||
|
Assert.assertEquals(message.getResponseCode(), Response.Status.OK.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsEnrolledNonExist()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Message message = androidService.isEnrolled("1234", null);
|
||||||
|
Assert.assertNotNull(message);
|
||||||
|
Assert.assertEquals(message.getResponseCode(), Response.Status.NOT_FOUND.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsEnrolledNull()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
Message response = androidService.isEnrolled(null, null);
|
||||||
|
Assert.assertNotNull(response);
|
||||||
|
Assert.assertEquals(response.getResponseCode(), Response.Status.NOT_FOUND.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testModifyEnrollmentSuccess()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockUser();
|
||||||
|
boolean status = androidService.modifyEnrollment(TestUtils.getDeviceId(), TestUtils.getBasicAndroidDevice());
|
||||||
|
Assert.assertTrue(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testModifyEnrollmentUnSuccess()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
mockUser();
|
||||||
|
AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice();
|
||||||
|
androidDevice.setDeviceIdentifier("1234");
|
||||||
|
boolean status = androidService
|
||||||
|
.modifyEnrollment(TestUtils.getDeviceId(), androidDevice);
|
||||||
|
Assert.assertFalse(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisEnrollDeviceSuccess()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
boolean status = androidService.disEnrollDevice(TestUtils.getDeviceId());
|
||||||
|
Assert.assertTrue(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisEnrollUnSuccess()
|
||||||
|
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||||
|
mockDeviceManagementService();
|
||||||
|
boolean status = androidService.disEnrollDevice("1234");
|
||||||
|
Assert.assertFalse(status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils;
|
package org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils;
|
||||||
|
|
||||||
import javafx.scene.Camera;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||||
@ -32,6 +31,7 @@ import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationInstalla
|
|||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUninstallation;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUninstallation;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUpdate;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUpdate;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.BlacklistApplications;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.BlacklistApplications;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.Camera;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceEncryption;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceEncryption;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceLock;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceLock;
|
||||||
import org.wso2.carbon.device.mgt.mobile.android.common.bean.LockCode;
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.LockCode;
|
||||||
@ -108,14 +108,14 @@ public class TestUtils {
|
|||||||
return deviceLockBeanWrapper;
|
return deviceLockBeanWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static CameraBeanWrapper getCamerabeanWrapper() {
|
public static CameraBeanWrapper getCamerabeanWrapper() {
|
||||||
// CameraBeanWrapper cameraBeanWrapper = new CameraBeanWrapper();
|
CameraBeanWrapper cameraBeanWrapper = new CameraBeanWrapper();
|
||||||
// cameraBeanWrapper.setDeviceIDs(getDeviceIds());
|
cameraBeanWrapper.setDeviceIDs(getDeviceIds());
|
||||||
// Camera camera = new Camera();
|
Camera camera = new Camera();
|
||||||
// camera.setEnabled(false);
|
camera.setEnabled(false);
|
||||||
// cameraBeanWrapper.setOperation(camera);
|
cameraBeanWrapper.setOperation(camera);
|
||||||
// return cameraBeanWrapper;
|
return cameraBeanWrapper;
|
||||||
// }
|
}
|
||||||
|
|
||||||
public static WipeDataBeanWrapper getWipeDataBeanWrapper() {
|
public static WipeDataBeanWrapper getWipeDataBeanWrapper() {
|
||||||
WipeDataBeanWrapper wipeDataBeanWrapper = new WipeDataBeanWrapper();
|
WipeDataBeanWrapper wipeDataBeanWrapper = new WipeDataBeanWrapper();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user