How to use checkIfDevicesIsAlreadyProvisioned method of com.testsigma.service.ProvisioningProfileService class

Best Testsigma code snippet using com.testsigma.service.ProvisioningProfileService.checkIfDevicesIsAlreadyProvisioned

Source:ProvisioningProfileService.java Github

copy

Full Screen

...103 throw new TestsigmaException(e.getMessage(), e);104 }105 return provisioningProfile;106 }107 private void checkIfDevicesIsAlreadyProvisioned(List<String> deviceUDIDs, ProvisioningProfile provisioningProfile)108 throws TestsigmaException {109 List<ProvisioningProfileDevice> conflictingDevices = provisioningProfileDeviceService110 .findAllByDeviceUDIdInAndProvisioningProfileIdNot(deviceUDIDs, provisioningProfile.getId());111 if (conflictingDevices.size() > 0) {112 List<String> conflictingDeviceUDIDs = conflictingDevices.stream()113 .map(ProvisioningProfileDevice::getDeviceUDId).collect(Collectors.toList());114 String errorMsg = "These devices are already provisioned through difference provisioning profile"115 + conflictingDeviceUDIDs + " Devices with multiple provisioning profiles are not allowed.";116 throw new TestsigmaException(errorMsg, errorMsg);117 }118 }119 private void removeProvisionedDevicesNotInProvisioningProfile(List<String> deviceUDIDs, ProvisioningProfile provisioningProfile)120 throws TestsigmaException {121 List<ProvisioningProfileDevice> existingDevices = provisioningProfileDeviceService122 .findAllByProvisioningProfileId(provisioningProfile.getId());123 if (existingDevices.size() > 0) {124 List<String> existingDeviceUDIDs = existingDevices.stream()125 .map(ProvisioningProfileDevice::getDeviceUDId).collect(Collectors.toList());126 existingDeviceUDIDs.removeAll(deviceUDIDs);127 if (existingDeviceUDIDs.size() > 0) {128 log.info("Removing existing device from provisioning profile devices - " + existingDeviceUDIDs);129 List<ProvisioningProfileDevice> removableDevices = provisioningProfileDeviceService130 .findAllByDeviceUDIdIn(existingDeviceUDIDs);131 List<Long> removedAgentDeviceIds = removableDevices.stream()132 .map(ProvisioningProfileDevice::getAgentDeviceId).collect(Collectors.toList());133 List<TestDevice> testDeviceServices = testDeviceService134 .findAllByAgentDeviceIds(removedAgentDeviceIds);135 if (testDeviceServices.size() > 0) {136 List<Long> existingExecutionIds = testDeviceServices.stream()137 .map(TestDevice::getTestPlanId).collect(Collectors.toList());138 throw new TestsigmaException("There are bellow devices removed from provision profile but have executions ::"139 + existingExecutionIds);140 }141 provisioningProfileDeviceService.deleteAllByDeviceUDIDIn(existingDeviceUDIDs);142 }143 log.info("Final list of device UUID's post cleanup - " + deviceUDIDs);144 }145 }146 private void parseDeviceInfoFromProvisioningProfile(File tempProvFile, ProvisioningProfile provisioningProfile)147 throws TestsigmaException, IOException {148 List<String> deviceUDIDs = profileParserService.parseDevices(tempProvFile);149 String teamId = profileParserService.getTeamId(tempProvFile);150 log.info("Identified devices from provisioning profile - " + deviceUDIDs);151 log.info("Identified team id from provisioning profile - " + teamId);152 provisioningProfile.setDeviceUDIDs(deviceUDIDs);153 provisioningProfile.setTeamId(teamId);154 checkIfDevicesIsAlreadyProvisioned(deviceUDIDs, provisioningProfile);155 removeProvisionedDevicesNotInProvisioningProfile(deviceUDIDs, provisioningProfile);156 provisioningProfileDeviceService.create(deviceUDIDs, provisioningProfile);157 }158 private void updateCRT(MultipartFile cer, ProvisioningProfile provisioningProfile) throws TestsigmaException {159 try {160 String profilePathPrefix = certificateService.s3Prefix(provisioningProfile.getId());161 String certificateLocalName = provisioningProfile.getId()162 + CertificateService.CERTIFICATE_FILE_SUFFIX;163 String certificateS3Name = profilePathPrefix + CertificateService.CERTIFICATE_FILE_SUFFIX;164 File cerFile = File.createTempFile(certificateLocalName, CertificateService.CERTIFICATE_CER_EXTENSION);165 File crt = File.createTempFile(certificateLocalName, CertificateService.CERTIFICATE_CRT_EXTENSION);166 File pem = File.createTempFile(certificateLocalName, CertificateService.PEM_EXTENSION);167 cer.transferTo(cerFile.toPath());168 log.info(String.format("Uploading certificate(cer) for provisioningProfile [%s] - [%s]", provisioningProfile.getId(),...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testsigma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful