ConfigurationFactoryImpl implements ConfigurationFactory { @Override public ConfigItem<String> newConfigItem(final String name, final String valueType) { final ConfigItem<String> stringConfigItem = new ConfigItem<String>(); stringConfigItem.setName(name); stringConfigItem.setValue(valueType); return stringConfigItem; } ConfigurationFactoryImpl(); @Inject  ConfigurationFactoryImpl(final PasswordService secureService); @Override ConfigGroup newConfigGroup(final ConfigType type,
                                      final String name,
                                      final String description); @Override ConfigGroup newConfigGroup(final ConfigType type,
                                      final String namespace,
                                      final String name,
                                      final String description); @Override ConfigItem<String> newConfigItem(final String name,
                                            final String valueType); @Override ConfigItem<Boolean> newConfigItem(final String name,
                                             final boolean valueType); @Override SecureConfigItem newSecuredConfigItem(final String name,
                                                 final String valueType); @Override ConfigItem<List> newConfigItem(String name,
                                          List valueType); @Override ConfigItem<Object> newConfigItem(String name,
                                            Object valueType);  }
@Test public void newStringConfigItemTest() { final ConfigItem<String> stringConfigItem = configurationFactory.newConfigItem("my-item", "my-value"); assertEquals("my-item", stringConfigItem.getName()); assertEquals("my-value", stringConfigItem.getValue()); }
@Test public void newBooleanConfigItemTest() { final ConfigItem<Boolean> booleanConfigItem = configurationFactory.newConfigItem("my-item", true); assertEquals("my-item", booleanConfigItem.getName()); assertTrue(booleanConfigItem.getValue()); }
@Test public void newListConfigItemTest() { final List<String> values = new ArrayList<>(); values.add("value1"); values.add("value2"); final ConfigItem<List> listConfigItem = configurationFactory.newConfigItem("my-item", values); assertEquals("my-item", listConfigItem.getName()); assertEquals(2, listConfigItem.getValue().size()); assertEquals("value1", listConfigItem.getValue().get(0)); assertEquals("value2", listConfigItem.getValue().get(1)); }
@Test public void newLongConfigItemTest() { final ConfigItem<Object> longConfigItem = configurationFactory.newConfigItem("my-item", 2L); assertEquals("my-item", longConfigItem.getName()); assertEquals(2L, longConfigItem.getValue()); }