Search in sources :

Example 21 with ConfigurationUnit

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

the class DefaultJSONConfigurationreaderTest method shouldReadDefaultFile.

@Test
public void shouldReadDefaultFile() {
    ConfigurationUnit annotation = mock(ConfigurationUnit.class);
    when(annotation.name()).thenReturn("name-2");
    when(annotation.fileName()).thenReturn("jnosql.json");
    ConfigurationSettingsUnit unit = configurationReader.read(annotation, MockConfiguration.class);
    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());
    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 22 with ConfigurationUnit

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

the class DefaultXMLConfigurationReaderTest method shouldReturnErrorWhenFileIsInvalid.

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

Example 23 with ConfigurationUnit

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

the class DefaultXMLConfigurationReaderTest method shouldReadDefaultAnnotationNameXML.

@Test
public void shouldReadDefaultAnnotationNameXML() {
    ConfigurationUnit annotation = mock(ConfigurationUnit.class);
    when(annotation.fileName()).thenReturn("jnosql.xml");
    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());
}
Also used : ConfigurationSettingsUnit(org.jnosql.artemis.ConfigurationSettingsUnit) HashMap(java.util.HashMap) ConfigurationUnit(org.jnosql.artemis.ConfigurationUnit) Test(org.junit.jupiter.api.Test)

Example 24 with ConfigurationUnit

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

the class DefaultYAMLConfigurationReaderTest method shouldReturnErrorWhenFileIsInvalid.

@Test
public void shouldReturnErrorWhenFileIsInvalid() {
    Assertions.assertThrows(ConfigurationException.class, () -> {
        ConfigurationUnit annotation = mock(ConfigurationUnit.class);
        when(annotation.fileName()).thenReturn("invalid.yaml");
        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