Search in sources :

Example 11 with Settings

use of jakarta.nosql.Settings in project jnosql-diana by eclipse.

the class DefaultSettingsTest method shouldReturnErrorWhenPrefixIsNull.

@Test
public void shouldReturnErrorWhenPrefixIsNull() {
    Settings settings = Settings.builder().put("host", "host").put("host-1", "host-1").put("host-2", "host-2").put("host-3", "host-3").build();
    assertThrows(NullPointerException.class, () -> settings.prefix((String) null));
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 12 with Settings

use of jakarta.nosql.Settings in project jnosql-diana by eclipse.

the class DefaultSettingsTest method shouldGetOrDefault.

@Test
public void shouldGetOrDefault() {
    Settings settings = Settings.of(singletonMap("key", "12"));
    assertEquals("12", settings.getOrDefault("key", "13"));
    assertEquals("13", settings.getOrDefault("key-1", "13"));
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 13 with Settings

use of jakarta.nosql.Settings in project jnosql-diana by eclipse.

the class DefaultSettingsTest method shouldReturnErrorWhenPrefixesIsNull.

@Test
public void shouldReturnErrorWhenPrefixesIsNull() {
    Settings settings = Settings.builder().put("host", "host").put("host-1", "host-1").put("host-2", "host-2").put("host-3", "host-3").build();
    assertThrows(NullPointerException.class, () -> settings.prefix((Collection<String>) null));
}
Also used : Collection(java.util.Collection) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 14 with Settings

use of jakarta.nosql.Settings in project jnosql-diana by eclipse.

the class SettingsBuilderTest method shouldCreateSettingsBuilder.

@Test
public void shouldCreateSettingsBuilder() {
    Settings settings = Settings.builder().put("key", "value").build();
    assertNotNull(settings);
    assertEquals("value", settings.get("key").get());
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 15 with Settings

use of jakarta.nosql.Settings in project jnosql-diana by eclipse.

the class DefaultSettingsTest method shouldIterateUsingForEach.

@Test
public void shouldIterateUsingForEach() {
    Settings settings = Settings.of(singletonMap("key", "12"));
    List<Map.Entry<String, Object>> references = new ArrayList<>();
    settings.forEach((k, v) -> references.add(new AbstractMap.SimpleEntry<>(k, v)));
    assertFalse(references.isEmpty());
    Map.Entry<String, Object> entry = references.get(0);
    Assertions.assertEquals("key", entry.getKey());
    Assertions.assertEquals("12", entry.getValue());
}
Also used : ArrayList(java.util.ArrayList) AbstractMap(java.util.AbstractMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Aggregations

Settings (jakarta.nosql.Settings)42 Test (org.junit.jupiter.api.Test)34 MongoCredential (com.mongodb.MongoCredential)6 Config (org.eclipse.microprofile.config.Config)5 Map (java.util.Map)4 ConfigurationException (org.eclipse.jnosql.mapping.configuration.ConfigurationException)4 SettingsConverter (org.eclipse.jnosql.mapping.configuration.SettingsConverter)4 Reflections (org.eclipse.jnosql.mapping.reflection.Reflections)4 SettingsBuilder (jakarta.nosql.Settings.SettingsBuilder)3 ColumnFamilyManagerFactory (jakarta.nosql.column.ColumnFamilyManagerFactory)3 DocumentConfiguration (jakarta.nosql.document.DocumentConfiguration)2 AbstractMap (java.util.AbstractMap)2 ArrayList (java.util.ArrayList)2 Collections.singletonMap (java.util.Collections.singletonMap)2 ConnectionString (com.mongodb.ConnectionString)1 MongoClientSettings (com.mongodb.MongoClientSettings)1 ServerAddress (com.mongodb.ServerAddress)1 MongoClient (com.mongodb.client.MongoClient)1 MongoClients (com.mongodb.client.MongoClients)1 Configurations (jakarta.nosql.Configurations)1