use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class DefaultYAMLConfigurationReaderTest method shouldReadDefaultNameYAML.
@Test
public void shouldReadDefaultNameYAML() {
ConfigurationUnit annotation = mock(ConfigurationUnit.class);
when(annotation.fileName()).thenReturn("jnosql.yaml");
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 DocumentCollectionFactoryProducer method getDocumentCollection.
private <T extends DocumentCollectionManager> DocumentCollectionManagerFactory<T> getDocumentCollection(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, DocumentConfiguration.class);
Class<DocumentConfiguration> configurationClass = unit.<DocumentConfiguration>getProvider().orElseThrow(() -> new IllegalStateException("The DocumentConfiguration provider is required in the configuration"));
DocumentConfiguration configuration = reflections.newInstance(configurationClass);
return configuration.get(unit.getSettings());
}
use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class BucketManagerFactoryProducer method getBuckerManagerFactocy.
private <T extends BucketManager> BucketManagerFactory<T> getBuckerManagerFactocy(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, KeyValueConfiguration.class);
Class<KeyValueConfiguration> configurationClass = unit.<KeyValueConfiguration>getProvider().orElseThrow(() -> new IllegalStateException("The ColumnConfiguration provider is required in the configuration"));
KeyValueConfiguration columnConfiguration = reflections.newInstance(configurationClass);
return columnConfiguration.get(unit.getSettings());
}
use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class DocumentCollectionFactoryProducer method getDocumentCollectionAsync.
private <T extends DocumentCollectionManagerAsync> DocumentCollectionManagerAsyncFactory<T> getDocumentCollectionAsync(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, DocumentConfigurationAsync.class);
Class<DocumentConfigurationAsync> configurationClass = unit.<DocumentConfigurationAsync>getProvider().orElseThrow(() -> new IllegalStateException("The DocumentConfiguration provider is required in the configuration"));
DocumentConfigurationAsync documentConfiguration = reflections.newInstance(configurationClass);
return documentConfiguration.getAsync(unit.getSettings());
}
use of org.jnosql.artemis.ConfigurationSettingsUnit in project jnosql-artemis by eclipse.
the class ColumnFamilyManagerFactoryProducer method gettColumnFamilyManagerAsyncFactory.
private <T extends ColumnFamilyManagerAsync> ColumnFamilyManagerAsyncFactory<T> gettColumnFamilyManagerAsyncFactory(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, ColumnConfigurationAsync.class);
Class<ColumnConfigurationAsync> configurationClass = unit.<ColumnConfigurationAsync>getProvider().orElseThrow(() -> new IllegalStateException("The ColumnConfiguration provider is required in the configuration"));
ColumnConfigurationAsync columnConfiguration = reflections.newInstance(configurationClass);
return columnConfiguration.getAsync(unit.getSettings());
}
Aggregations