com.testvagrant.monitor.services.DevicesServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optimus-monitor Show documentation
Show all versions of optimus-monitor Show documentation
The Java Client provides access to Optimus cloud for all java based projects.
The newest version!
package com.testvagrant.monitor.services;
import com.testvagrant.monitor.clients.DevicesClient;
import com.testvagrant.monitor.entities.DeviceDetails;
import com.testvagrant.monitor.exceptions.DeviceEngagedException;
import com.testvagrant.monitor.exceptions.DeviceReleaseException;
import com.testvagrant.monitor.reql.DeviceMatcherFunction;
import com.testvagrant.monitor.requests.Device;
import com.testvagrant.monitor.utils.DeviceToDeviceDetailsMapper;
import org.json.simple.JSONObject;
import java.util.List;
import static com.testvagrant.monitor.utils.DeviceToDeviceDetailsMapper.getDevicesFromDeviceDetails;
public class DevicesServiceImpl extends OptimusServiceImpl implements DevicesService {
@Override
public DeviceDetails getDeviceByUdid(String udid) {
Device deviceByUdid = new DevicesClient().getDeviceByUdid(getLatestBuild(), udid);
return DeviceToDeviceDetailsMapper.getDeviceDetails(deviceByUdid);
}
@Override
public List getAllDevices() {
return new DevicesClient().getAllDevices(getLatestBuild());
}
@Override
public void insertDeviceList(List deviceDetailsList) {
List devicesFromDeviceDetails = getDevicesFromDeviceDetails(getLatestBuild(), deviceDetailsList);
new DevicesClient().storeDevices(devicesFromDeviceDetails);
}
@Override
public Device updateFirstAvailableDeviceToEngaged(JSONObject testFeed) throws DeviceEngagedException {
Device matchingDevice = new DeviceMatcherFunction().getDeviceQuery(testFeed);
return new DevicesClient().getDevice(getLatestBuild(), matchingDevice);
}
@Override
public Device updateFirstAvailableDeviceToEngaged(String udid) throws DeviceEngagedException {
return new DevicesClient().getDeviceByUdid(getLatestBuild(), udid);
}
@Override
public void updateDeviceScreenshot(String udid, byte[] screenshot) {
Device deviceToUpdate = new DevicesClient().getDeviceByUdid(getLatestBuild(), udid);
deviceToUpdate.setScreenshot(screenshot);
new DevicesClient().storeScreenShot(getLatestBuild(), deviceToUpdate);
}
@Override
public void updateStatusToAvailableForDevice(String udid) throws DeviceReleaseException {
Device deviceToUpdate = new DevicesClient().getDeviceByUdid(getLatestBuild(), udid);
deviceToUpdate.setStatus("Available");
new DevicesClient().releaseDevice(deviceToUpdate);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy