Search in sources :

Example 1 with STFDevice

use of com.qaprosoft.zafira.models.stf.STFDevice in project carina by qaprosoft.

the class DeviceInfo method process.

protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.setStatus(HttpStatus.SC_NOT_FOUND);
    String id = request.getParameter("session");
    if (id != null) {
        TestSession session = this.getRegistry().getExistingSession(ExternalSessionKey.fromString(id));
        if (session != null) {
            Map<String, Object> cap = session.getSlot().getCapabilities();
            if (cap.containsKey("udid")) {
                RemoteDevice device = new RemoteDevice();
                device.setName((String) cap.get("deviceName"));
                device.setOs((String) cap.get("platformName"));
                device.setOsVersion((String) cap.get("platformVersion"));
                device.setType((String) cap.get("deviceType"));
                device.setUdid((String) cap.get("udid"));
                STFDevice stfDevice = STF.getDevice(device.getUdid());
                if (stfDevice != null) {
                    device.setRemoteURL((String) stfDevice.getRemoteConnectUrl());
                }
                response.setStatus(HttpStatus.SC_OK);
                response.getWriter().print(new ObjectMapper().writeValueAsString(device));
                response.getWriter().close();
            }
        }
    }
}
Also used : TestSession(org.openqa.grid.internal.TestSession) RemoteDevice(com.qaprosoft.carina.commons.models.RemoteDevice) STFDevice(com.qaprosoft.zafira.models.stf.STFDevice) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RemoteDevice (com.qaprosoft.carina.commons.models.RemoteDevice)1 STFDevice (com.qaprosoft.zafira.models.stf.STFDevice)1 TestSession (org.openqa.grid.internal.TestSession)1