Search in sources :

Example 1 with ConfigurationUnit

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

Example 2 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class DefaultConfigurationReaderTest method shouldReturnErrorWhenThereIsAmbiguous.

@Test
public void shouldReturnErrorWhenThereIsAmbiguous() {
    Assertions.assertThrows(ConfigurationException.class, () -> {
        ConfigurationUnit annotation = mock(ConfigurationUnit.class);
        when(annotation.fileName()).thenReturn("jnosql.json");
        configurationReader.read(annotation, MockConfiguration.class);
    });
}
Also used : ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class DefaultConfigurationReaderTest method shouldReturnErrorWhenThereIsNotDefaultConstructor.

@Test
public void shouldReturnErrorWhenThereIsNotDefaultConstructor() {
    Assertions.assertThrows(ConfigurationException.class, () -> {
        ConfigurationUnit annotation = mock(ConfigurationUnit.class);
        when(annotation.fileName()).thenReturn("invalid-class.json");
        when(annotation.name()).thenReturn("name-2");
        configurationReader.read(annotation, MockConfiguration.class);
    });
}
Also used : ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class DefaultConfigurationReaderTest method shouldReturnAnErrorWhenTheExtensionDoesNotSupport.

@Test
public void shouldReturnAnErrorWhenTheExtensionDoesNotSupport() {
    Assertions.assertThrows(ConfigurationException.class, () -> {
        ConfigurationUnit annotation = mock(ConfigurationUnit.class);
        when(annotation.fileName()).thenReturn("invalid.invalid");
        configurationReader.read(annotation, MockConfiguration.class);
    });
}
Also used : ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) Test(org.junit.jupiter.api.Test)

Example 5 with ConfigurationUnit

use of org.jnosql.artemis.ConfigurationUnit in project jnosql-artemis by eclipse.

the class DefaultConfigurationReaderTest method shouldReturnErrorWhenFileDoesNotExist.

@Test
public void shouldReturnErrorWhenFileDoesNotExist() {
    Assertions.assertThrows(ConfigurationException.class, () -> {
        ConfigurationUnit annotation = mock(ConfigurationUnit.class);
        when(annotation.fileName()).thenReturn("unknown.json");
        configurationReader.read(annotation, MockConfiguration.class);
    });
}
Also used : ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationUnit (org.jnosql.artemis.ConfigurationUnit)24 Test (org.junit.jupiter.api.Test)19 ConfigurationSettingsUnit (org.jnosql.artemis.ConfigurationSettingsUnit)12 HashMap (java.util.HashMap)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