@Override
    public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
        checkPermission(CONFIG_WRITE);
        checkNotNull(subject, NULL_SUBJECT_MSG);
        checkNotNull(configClass, NULL_CCLASS_MSG);
        return store.createConfig(subject, configClass);
    }
@Test
    public void testAddConfig() {

        assertThat(configService.getSubjectFactory(String.class), nullValue());
        assertThat(configService.getSubjectFactory("key"), nullValue());

        registry.registerConfigFactory(config1Factory);
        registry.registerConfigFactory(config2Factory);
        configService.addConfig("configKey", BasicConfig1.class);

        Config newConfig = configService.getConfig("configKey", BasicConfig1.class);
        assertThat(newConfig, notNullValue());

        assertThat(configService.getSubjectFactory(String.class), notNullValue());
        assertThat(configService.getSubjectFactory("key1"), notNullValue());

        Set<Class> classes = configService.getSubjectClasses();
        assertThat(classes, hasSize(1));

        Set<String> subjectsForClass =
                configService.getSubjects(String.class);
        assertThat(subjectsForClass, hasSize(1));

        Set<String> subjectsForConfig =
                configService.getSubjects(String.class, BasicConfig1.class);
        assertThat(subjectsForConfig, hasSize(1));

        Class queriedConfigClass = configService.getConfigClass("key1", "config1");
        assertThat(queriedConfigClass == BasicConfig1.class, is(true));

        Set<? extends Config> configs = configService.getConfigs("configKey");
        assertThat(configs.size(), is(1));
        configs.forEach(c -> assertThat(c, instanceOf(BasicConfig1.class)));

        configService.removeConfig("configKey", BasicConfig1.class);
        Config newConfigAfterRemove = configService.getConfig("configKey", BasicConfig1.class);
        assertThat(newConfigAfterRemove, nullValue());
    }