@Test(expected = IllegalArgumentException.class) public void findAndroidDeviceThrowsIllegalArgumentExceptionIfCapabilitiesNull() throws Exception { DeviceStore store = new DeviceStore(EMULATOR_PORT, anDeviceManager()); store.findAndroidDevice(null); }
public synchronized AndroidDevice findAndroidDevice(SelendroidCapabilities caps) throws DeviceStoreException { Preconditions.checkArgument(caps != null, "Error: capabilities are null"); if (androidDevices.isEmpty()) { throw new DeviceStoreException("Fatal Error: Device Store does not contain any Android Device."); } String platformVersion = caps.getPlatformVersion(); Iterable<AndroidDevice> candidateDevices = Strings.isNullOrEmpty(platformVersion) ? Iterables.concat(androidDevices.values()) : androidDevices.get(DeviceTargetPlatform.fromPlatformVersion(platformVersion)); candidateDevices = MoreObjects.firstNonNull(candidateDevices, Collections.EMPTY_LIST); FluentIterable<AndroidDevice> allMatchingDevices = FluentIterable.from(candidateDevices) .filter(deviceNotInUse()) .filter(deviceSatisfiesCapabilities(caps)); if (!allMatchingDevices.isEmpty()) { AndroidDevice matchingDevice = allMatchingDevices.filter(deviceRunning()).first() .or(allMatchingDevices.first()).get(); if (!deviceRunning().apply(matchingDevice)) { log.info("Using potential match: " + matchingDevice); } devicesInUse.add(matchingDevice); return matchingDevice; } else { throw new DeviceStoreException("No devices are found. " + "This can happen if the devices are in use or no device screen " + "matches the required capabilities."); } }
DeviceStore { public synchronized AndroidDevice findAndroidDevice(SelendroidCapabilities caps) throws DeviceStoreException { Preconditions.checkArgument(caps != null, "Error: capabilities are null"); if (androidDevices.isEmpty()) { throw new DeviceStoreException("Fatal Error: Device Store does not contain any Android Device."); } String platformVersion = caps.getPlatformVersion(); Iterable<AndroidDevice> candidateDevices = Strings.isNullOrEmpty(platformVersion) ? Iterables.concat(androidDevices.values()) : androidDevices.get(DeviceTargetPlatform.fromPlatformVersion(platformVersion)); candidateDevices = MoreObjects.firstNonNull(candidateDevices, Collections.EMPTY_LIST); FluentIterable<AndroidDevice> allMatchingDevices = FluentIterable.from(candidateDevices) .filter(deviceNotInUse()) .filter(deviceSatisfiesCapabilities(caps)); if (!allMatchingDevices.isEmpty()) { AndroidDevice matchingDevice = allMatchingDevices.filter(deviceRunning()).first() .or(allMatchingDevices.first()).get(); if (!deviceRunning().apply(matchingDevice)) { log.info("Using potential match: " + matchingDevice); } devicesInUse.add(matchingDevice); return matchingDevice; } else { throw new DeviceStoreException("No devices are found. " + "This can happen if the devices are in use or no device screen " + "matches the required capabilities."); } } }
DeviceStore { public synchronized AndroidDevice findAndroidDevice(SelendroidCapabilities caps) throws DeviceStoreException { Preconditions.checkArgument(caps != null, "Error: capabilities are null"); if (androidDevices.isEmpty()) { throw new DeviceStoreException("Fatal Error: Device Store does not contain any Android Device."); } String platformVersion = caps.getPlatformVersion(); Iterable<AndroidDevice> candidateDevices = Strings.isNullOrEmpty(platformVersion) ? Iterables.concat(androidDevices.values()) : androidDevices.get(DeviceTargetPlatform.fromPlatformVersion(platformVersion)); candidateDevices = MoreObjects.firstNonNull(candidateDevices, Collections.EMPTY_LIST); FluentIterable<AndroidDevice> allMatchingDevices = FluentIterable.from(candidateDevices) .filter(deviceNotInUse()) .filter(deviceSatisfiesCapabilities(caps)); if (!allMatchingDevices.isEmpty()) { AndroidDevice matchingDevice = allMatchingDevices.filter(deviceRunning()).first() .or(allMatchingDevices.first()).get(); if (!deviceRunning().apply(matchingDevice)) { log.info("Using potential match: " + matchingDevice); } devicesInUse.add(matchingDevice); return matchingDevice; } else { throw new DeviceStoreException("No devices are found. " + "This can happen if the devices are in use or no device screen " + "matches the required capabilities."); } } DeviceStore(Integer emulatorPort, DeviceManager deviceManager);  DeviceStore(EmulatorPortFinder androidEmulatorPortFinder,
                     DeviceManager deviceManager); }
DeviceStore { public synchronized AndroidDevice findAndroidDevice(SelendroidCapabilities caps) throws DeviceStoreException { Preconditions.checkArgument(caps != null, "Error: capabilities are null"); if (androidDevices.isEmpty()) { throw new DeviceStoreException("Fatal Error: Device Store does not contain any Android Device."); } String platformVersion = caps.getPlatformVersion(); Iterable<AndroidDevice> candidateDevices = Strings.isNullOrEmpty(platformVersion) ? Iterables.concat(androidDevices.values()) : androidDevices.get(DeviceTargetPlatform.fromPlatformVersion(platformVersion)); candidateDevices = MoreObjects.firstNonNull(candidateDevices, Collections.EMPTY_LIST); FluentIterable<AndroidDevice> allMatchingDevices = FluentIterable.from(candidateDevices) .filter(deviceNotInUse()) .filter(deviceSatisfiesCapabilities(caps)); if (!allMatchingDevices.isEmpty()) { AndroidDevice matchingDevice = allMatchingDevices.filter(deviceRunning()).first() .or(allMatchingDevices.first()).get(); if (!deviceRunning().apply(matchingDevice)) { log.info("Using potential match: " + matchingDevice); } devicesInUse.add(matchingDevice); return matchingDevice; } else { throw new DeviceStoreException("No devices are found. " + "This can happen if the devices are in use or no device screen " + "matches the required capabilities."); } } DeviceStore(Integer emulatorPort, DeviceManager deviceManager);  DeviceStore(EmulatorPortFinder androidEmulatorPortFinder,
                     DeviceManager deviceManager); Integer nextEmulatorPort(); void release(AndroidDevice device, AndroidApp aut); synchronized void addDevice(AndroidDevice androidDevice); synchronized void updateDevice(AndroidDevice device); void addEmulators(List<AndroidEmulator> emulators); synchronized AndroidDevice findAndroidDevice(SelendroidCapabilities caps); List<AndroidDevice> getDevices(); void removeAndroidDevice(AndroidDevice device); void setClearData(boolean clearData); void setKeepEmulator(boolean keepEmulator); }
DeviceStore { public synchronized AndroidDevice findAndroidDevice(SelendroidCapabilities caps) throws DeviceStoreException { Preconditions.checkArgument(caps != null, "Error: capabilities are null"); if (androidDevices.isEmpty()) { throw new DeviceStoreException("Fatal Error: Device Store does not contain any Android Device."); } String platformVersion = caps.getPlatformVersion(); Iterable<AndroidDevice> candidateDevices = Strings.isNullOrEmpty(platformVersion) ? Iterables.concat(androidDevices.values()) : androidDevices.get(DeviceTargetPlatform.fromPlatformVersion(platformVersion)); candidateDevices = MoreObjects.firstNonNull(candidateDevices, Collections.EMPTY_LIST); FluentIterable<AndroidDevice> allMatchingDevices = FluentIterable.from(candidateDevices) .filter(deviceNotInUse()) .filter(deviceSatisfiesCapabilities(caps)); if (!allMatchingDevices.isEmpty()) { AndroidDevice matchingDevice = allMatchingDevices.filter(deviceRunning()).first() .or(allMatchingDevices.first()).get(); if (!deviceRunning().apply(matchingDevice)) { log.info("Using potential match: " + matchingDevice); } devicesInUse.add(matchingDevice); return matchingDevice; } else { throw new DeviceStoreException("No devices are found. " + "This can happen if the devices are in use or no device screen " + "matches the required capabilities."); } } DeviceStore(Integer emulatorPort, DeviceManager deviceManager);  DeviceStore(EmulatorPortFinder androidEmulatorPortFinder,
                     DeviceManager deviceManager); Integer nextEmulatorPort(); void release(AndroidDevice device, AndroidApp aut); synchronized void addDevice(AndroidDevice androidDevice); synchronized void updateDevice(AndroidDevice device); void addEmulators(List<AndroidEmulator> emulators); synchronized AndroidDevice findAndroidDevice(SelendroidCapabilities caps); List<AndroidDevice> getDevices(); void removeAndroidDevice(AndroidDevice device); void setClearData(boolean clearData); void setKeepEmulator(boolean keepEmulator);  }