com.testvagrant.optimus.devicemanager.BrowserstackDeviceManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optimus-lite Show documentation
Show all versions of optimus-lite Show documentation
Optimus Lite API to manage test devices and create appium driver based on platform
package com.testvagrant.optimus.devicemanager;
import com.testvagrant.optimus.core.exceptions.NoSuchDeviceException;
import com.testvagrant.optimus.core.models.OptimusSupportedPlatforms;
import com.testvagrant.optimus.core.models.TargetDetails;
import com.testvagrant.optimus.core.remote.CloudConfigBuilder;
import com.testvagrant.optimus.core.remote.browserstack.BrowserStackDeviceClient;
import java.util.List;
import java.util.function.Predicate;
public class BrowserstackDeviceManager {
private final List devices;
private static BrowserstackDeviceManager deviceManager;
private OptimusSupportedPlatforms platform;
private BrowserstackDeviceManager(OptimusSupportedPlatforms platform) {
BrowserStackDeviceClient browserStackClient =
new BrowserStackDeviceClient(new CloudConfigBuilder().build());
devices =
platform.equals(OptimusSupportedPlatforms.IOS)
? browserStackClient.getIosDevices()
: browserStackClient.getAndroidDevices();
}
public static BrowserstackDeviceManager getInstance(OptimusSupportedPlatforms platform) {
return new BrowserstackDeviceManager(platform);
}
public synchronized TargetDetails getDevice(Predicate deviceFilterPredicate) {
return devices.stream()
.filter(deviceFilterPredicate)
.findFirst()
.orElseThrow(NoSuchDeviceException::new);
}
public TargetDetails getDevice() {
return getDevice(platformQueryPredicate());
}
protected Predicate platformQueryPredicate() {
return TargetDetails -> !TargetDetails.getName().isEmpty();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy