@Test public void loadsPoolsWhenUsingRegexpToDescribeSerials() { Map<String, Collection<String>> groupings = newHashMap(); groupings.put("VMs", singletonList(".*:5555")); groupings.put("Real devices", asList("serial1", "serial2")); SerialBasedDevicePoolLoader poolLoader = new SerialBasedDevicePoolLoader(new ManualPooling(groupings)); Collection<Pool> pools = poolLoader.loadPools(devices); assertThat(pools, containsInAnyOrder( samePool( aDevicePool() .withName("Real devices") .addDevice(device) .addDevice(anotherDevice) .build() ), samePool( aDevicePool() .withName("VMs") .addDevice(emulator) .addDevice(anotherEmulator) .build() ) )); }
public Collection<Pool> loadPools(Devices devices) { Collection<Pool> pools = new ArrayList<>(); for (Entry<String, Collection<String>> pool : manualPooling.groupings.entrySet()) { Pool.Builder poolBuilder = aDevicePool().withName(pool.getKey()); for (String pattern : pool.getValue()) { Collection<Device> matchedDevices = devices.findDevices(pattern); for (Device matchedDevice : matchedDevices) { poolBuilder.addDevice(matchedDevice); } } pools.add(poolBuilder.build()); } return pools; }
SerialBasedDevicePoolLoader implements DevicePoolLoader { public Collection<Pool> loadPools(Devices devices) { Collection<Pool> pools = new ArrayList<>(); for (Entry<String, Collection<String>> pool : manualPooling.groupings.entrySet()) { Pool.Builder poolBuilder = aDevicePool().withName(pool.getKey()); for (String pattern : pool.getValue()) { Collection<Device> matchedDevices = devices.findDevices(pattern); for (Device matchedDevice : matchedDevices) { poolBuilder.addDevice(matchedDevice); } } pools.add(poolBuilder.build()); } return pools; } }
SerialBasedDevicePoolLoader implements DevicePoolLoader { public Collection<Pool> loadPools(Devices devices) { Collection<Pool> pools = new ArrayList<>(); for (Entry<String, Collection<String>> pool : manualPooling.groupings.entrySet()) { Pool.Builder poolBuilder = aDevicePool().withName(pool.getKey()); for (String pattern : pool.getValue()) { Collection<Device> matchedDevices = devices.findDevices(pattern); for (Device matchedDevice : matchedDevices) { poolBuilder.addDevice(matchedDevice); } } pools.add(poolBuilder.build()); } return pools; } SerialBasedDevicePoolLoader(ManualPooling manualPooling); }
SerialBasedDevicePoolLoader implements DevicePoolLoader { public Collection<Pool> loadPools(Devices devices) { Collection<Pool> pools = new ArrayList<>(); for (Entry<String, Collection<String>> pool : manualPooling.groupings.entrySet()) { Pool.Builder poolBuilder = aDevicePool().withName(pool.getKey()); for (String pattern : pool.getValue()) { Collection<Device> matchedDevices = devices.findDevices(pattern); for (Device matchedDevice : matchedDevices) { poolBuilder.addDevice(matchedDevice); } } pools.add(poolBuilder.build()); } return pools; } SerialBasedDevicePoolLoader(ManualPooling manualPooling); Collection<Pool> loadPools(Devices devices); }
SerialBasedDevicePoolLoader implements DevicePoolLoader { public Collection<Pool> loadPools(Devices devices) { Collection<Pool> pools = new ArrayList<>(); for (Entry<String, Collection<String>> pool : manualPooling.groupings.entrySet()) { Pool.Builder poolBuilder = aDevicePool().withName(pool.getKey()); for (String pattern : pool.getValue()) { Collection<Device> matchedDevices = devices.findDevices(pattern); for (Device matchedDevice : matchedDevices) { poolBuilder.addDevice(matchedDevice); } } pools.add(poolBuilder.build()); } return pools; } SerialBasedDevicePoolLoader(ManualPooling manualPooling); Collection<Pool> loadPools(Devices devices);  }