@Nullable
    public <T extends DeviceConfig> T getDeviceConfig(String name) {
        return (T) deviceConfigs.get(name);
    }
@Test
    public void testGetDeviceConfig() {
        String deviceName = randomName();
        DeviceConfig deviceConfig = new LocalDeviceConfig().setName(deviceName);
        config.addDeviceConfig(deviceConfig);

        assertNull(config.getDeviceConfig(randomName()));
        assertEquals(deviceConfig, config.getDeviceConfig(deviceName));
        assertEquals(deviceConfig, config.getDeviceConfig(LocalDeviceConfig.class, deviceName));

        deviceConfig = new DeviceConfig() {
            @Override
            public boolean isLocal() {
                return false;
            }

            @Override
            public Capacity getCapacity() {
                return LocalDeviceConfig.DEFAULT_CAPACITY;
            }

            @Override
            public NamedConfig setName(String name) {
                return this;
            }

            @Override
            public String getName() {
                return deviceName;
            }
        };

        config.addDeviceConfig(deviceConfig);
        assertEquals(deviceConfig, config.getDeviceConfig(deviceName));
        assertEquals(deviceConfig, config.getDeviceConfig(DeviceConfig.class, deviceName));

        assertThrows(ClassCastException.class, () -> config.getDeviceConfig(LocalDeviceConfig.class, deviceName));
    }