Search in sources :

Example 6 with ConfigurationSettingsUnit

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());
}
Also used : ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) HashMap(java.util.HashMap) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) Test(org.junit.jupiter.api.Test)

Example 7 with ConfigurationSettingsUnit

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());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) DocumentConfiguration(org.jnosql.diana.api.document.DocumentConfiguration)

Example 8 with ConfigurationSettingsUnit

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());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) KeyValueConfiguration(org.jnosql.diana.api.key.KeyValueConfiguration) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit)

Example 9 with ConfigurationSettingsUnit

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());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) DocumentConfigurationAsync(org.jnosql.diana.api.document.DocumentConfigurationAsync) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit)

Example 10 with ConfigurationSettingsUnit

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());
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) ColumnConfigurationAsync(org.jnosql.diana.api.column.ColumnConfigurationAsync)

Aggregations

ConfigurationSettingsUnit (org.jnosql.artemis.ConfigurationSettingsUnit)12 ConfigurationUnit (org.jnosql.artemis.ConfigurationUnit)12 HashMap (java.util.HashMap)7 Test (org.junit.jupiter.api.Test)7 Annotated (javax.enterprise.inject.spi.Annotated)5 ColumnConfiguration (org.jnosql.diana.api.column.ColumnConfiguration)1 ColumnConfigurationAsync (org.jnosql.diana.api.column.ColumnConfigurationAsync)1 DocumentConfiguration (org.jnosql.diana.api.document.DocumentConfiguration)1 DocumentConfigurationAsync (org.jnosql.diana.api.document.DocumentConfigurationAsync)1 KeyValueConfiguration (org.jnosql.diana.api.key.KeyValueConfiguration)1