use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class ColumnFamilyManagerFactoryProducer method gettColumnFamilyManagerFactory.
private <T extends ColumnFamilyManager> ColumnFamilyManagerFactory<T> gettColumnFamilyManagerFactory(InjectionPoint injectionPoint) {
Annotated annotated = injectionPoint.getAnnotated();
ConfigurationUnit annotation = getConfigurationUnit(injectionPoint, annotated).orElseThrow(() -> new IllegalStateException("The @ConfigurationUnit does not found"));
ConfigurationSettingsUnit unit = configurationReader.get().read(annotation, ColumnConfiguration.class);
Class<ColumnConfiguration> configurationClass = unit.<ColumnConfiguration>getProvider().orElseThrow(() -> new IllegalStateException("The ColumnConfiguration provider is required in the configuration"));
ColumnConfiguration columnConfiguration = reflections.newInstance(configurationClass);
return columnConfiguration.get(unit.getSettings());
}
use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class DefaultJSONConfigurationreaderTest method shouldReadConfiguration.
@Test
public void shouldReadConfiguration() {
ConfigurationUnit annotation = mock(ConfigurationUnit.class);
when(annotation.fileName()).thenReturn("jnosql.json");
when(annotation.name()).thenReturn("name");
ConfigurationSettingsUnit unit = configurationReader.read(annotation, MockConfiguration.class);
Map<String, Object> settings = new HashMap<>();
settings.put("key", "value");
settings.put("key2", "value2");
assertEquals("name", unit.getName().get());
assertEquals("that is the description", unit.getDescription().get());
assertEquals(Settings.of(settings), unit.getSettings());
assertEquals(DefaultMockConfiguration.class, unit.getProvider().get());
}
use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class DefaultJSONConfigurationreaderTest method shouldReadAnnotationDefaultFile.
@Test
public void shouldReadAnnotationDefaultFile() {
ConfigurationUnit annotation = mock(ConfigurationUnit.class);
when(annotation.name()).thenReturn("name-2");
when(annotation.fileName()).thenReturn("jnosql.json");
ConfigurationSettingsUnit unit = configurationReader.read(annotation);
Map<String, Object> settings = new HashMap<>();
settings.put("key", "value");
settings.put("key2", "value2");
settings.put("key3", "value3");
assertEquals("name-2", unit.getName().get());
assertEquals("that is the description", unit.getDescription().get());
assertEquals(Settings.of(settings), unit.getSettings());
assertFalse(unit.getProvider().isPresent());
}
use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class DefaultXMLConfigurationReaderTest method shouldReadDefaultNameXML.
@Test
public void shouldReadDefaultNameXML() {
ConfigurationUnit annotation = mock(ConfigurationUnit.class);
when(annotation.fileName()).thenReturn("jnosql.xml");
when(annotation.name()).thenReturn("name");
ConfigurationSettingsUnit unit = configurationReader.read(annotation, MockConfiguration.class);
Map<String, Object> settings = new HashMap<>();
settings.put("key", "value");
settings.put("key2", "value2");
assertEquals("name", unit.getName().get());
assertEquals("that is the description", unit.getDescription().get());
assertEquals(Settings.of(settings), unit.getSettings());
assertEquals(DefaultMockConfiguration.class, unit.getProvider().get());
}
use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class DefaultYAMLConfigurationReaderTest method shouldReadDefaultAnnotationNameYAML.
@Test
public void shouldReadDefaultAnnotationNameYAML() {
ConfigurationUnit annotation = mock(ConfigurationUnit.class);
when(annotation.fileName()).thenReturn("jnosql.yaml");
when(annotation.name()).thenReturn("name");
ConfigurationSettingsUnit unit = configurationReader.read(annotation);
Map<String, Object> settings = new HashMap<>();
settings.put("key", "value");
settings.put("key2", "value2");
assertEquals("name", unit.getName().get());
assertEquals("that is the description", unit.getDescription().get());
assertEquals(Settings.of(settings), unit.getSettings());
assertFalse(unit.getProvider().isPresent());
}
Aggregations