Search in sources :

Example 1 with IosDeveloperImageDTO

use of com.testsigma.agent.dto.IosDeveloperImageDTO in project testsigma by testsigmahq.

the class DeveloperImageService method mountDeveloperImage.

public void mountDeveloperImage(MobileDevice device) throws TestsigmaException, AutomatorException {
    log.info("Trying to mount developer image onto the device");
    if (!isDeveloperImageAvailable(device.getOsVersion())) {
        IosDeveloperImageDTO iosDeveloperImageDTO = fetchDeveloperImageLinks(device.getOsVersion());
        downloadDeveloperImage(device.getOsVersion(), iosDeveloperImageDTO);
    }
    String developerImageDirectory = developerImageDirectory(device.getOsVersion()).getAbsolutePath();
    if (new File(developerImageDirectory).exists()) {
        log.info("Developer image exists at - " + developerImageDirectory);
    } else {
        log.info("Developer image could not be fetched for osVersion - " + device.getOsVersion());
    }
    IosDeviceCommandExecutor iosDeviceCommandExecutor = new IosDeviceCommandExecutor();
    Process p = iosDeviceCommandExecutor.runDeviceCommand(new String[] { "-u", device.getUniqueId(), "developer", developerImageDirectory });
    String mountCommandOutput = iosDeviceCommandExecutor.getProcessStreamResponse(p);
    log.info("Response from mount developer image on device - " + mountCommandOutput);
    if (mountCommandOutput.contains("PairingDialogResponsePending")) {
        throw new TestsigmaException("Device is not yet paired. Triggered the trust dialogue. Please accept and try again", "Device is not yet paired. Triggered the trust dialogue. Please accept and try again");
    } else if (mountCommandOutput.contains("DeveloperImage already mounted")) {
        log.info("Developer image is already mounted in the device");
    } else if (mountCommandOutput.contains("DeveloperImage mounted successfully")) {
        log.info("Developer image is mounted successfully on the device");
    } else if (mountCommandOutput.contains("DeviceLocked")) {
        throw new TestsigmaException("Device is locked with a passcode. Please unlock and try again", "Device is locked with a passcode. Please unlock and try again");
    } else {
        throw new TestsigmaException("Unknown error while mounting developer image to the device", "Unknown error while mounting developer image to the device");
    }
}
Also used : IosDeviceCommandExecutor(com.testsigma.automator.mobile.ios.IosDeviceCommandExecutor) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) IosDeveloperImageDTO(com.testsigma.agent.dto.IosDeveloperImageDTO) File(java.io.File)

Example 2 with IosDeveloperImageDTO

use of com.testsigma.agent.dto.IosDeveloperImageDTO in project testsigma by testsigmahq.

the class DeveloperImageService method fetchDeveloperImageLinks.

public IosDeveloperImageDTO fetchDeveloperImageLinks(String osVersion) throws TestsigmaException {
    IosDeveloperImageDTO iosDeveloperImageDTO;
    log.info("Fetching developer image URL's from testsigma servers...");
    try {
        String authHeader = WebAppHttpClient.BEARER + " " + agentConfig.getJwtApiKey();
        HttpResponse<IosDeveloperImageDTO> response = httpClient.get(ServerURLBuilder.deviceDeveloperImageURL(this.agentConfig.getUUID(), osVersion), new TypeReference<>() {
        }, authHeader);
        log.info("Response of developer image fetch request - " + response.getStatusCode());
        if (response.getStatusCode() == HttpStatus.OK.value()) {
            iosDeveloperImageDTO = response.getResponseEntity();
        } else {
            String errorMsg = String.format("Error while fetching developer image - [%s] - [%s] ", response.getStatusCode(), response.getStatusMessage());
            throw new TestsigmaException(errorMsg, errorMsg);
        }
        log.info("Response from device developer image urls for os version - " + osVersion + " is - " + iosDeveloperImageDTO);
    } catch (Exception e) {
        throw new TestsigmaException(e.getMessage(), e);
    }
    return iosDeveloperImageDTO;
}
Also used : TestsigmaException(com.testsigma.agent.exception.TestsigmaException) IosDeveloperImageDTO(com.testsigma.agent.dto.IosDeveloperImageDTO) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TestsigmaException(com.testsigma.agent.exception.TestsigmaException)

Aggregations

IosDeveloperImageDTO (com.testsigma.agent.dto.IosDeveloperImageDTO)2 TestsigmaException (com.testsigma.agent.exception.TestsigmaException)2 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)1 IosDeviceCommandExecutor (com.testsigma.automator.mobile.ios.IosDeviceCommandExecutor)1 File (java.io.File)1