Search in sources :

Example 36 with Settings

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

the class DefaultSettingsTest method shouldReturnNewInstance.

@Test
public void shouldReturnNewInstance() {
    Settings settings = Settings.of();
    assertTrue(settings.isEmpty());
    assertEquals(0, settings.size());
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 37 with Settings

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

the class DefaultSettingsTest method shouldGetValueClass.

@Test
public void shouldGetValueClass() {
    Settings settings = Settings.of(singletonMap("key", "12"));
    Integer value = settings.get("key", Integer.class).get();
    assertEquals(Integer.valueOf(12), value);
    assertFalse(settings.get("key2", Integer.class).isPresent());
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 38 with Settings

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

the class DefaultSettingsTest method shouldCreateFromMap.

@Test
public void shouldCreateFromMap() {
    Settings settings = Settings.of(singletonMap("key", "value"));
    assertFalse(settings.isEmpty());
    assertEquals(1, settings.size());
    assertEquals("value", settings.get("key").get());
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 39 with Settings

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

the class DefaultSettingsTest method shouldGetKeys.

@Test
public void shouldGetKeys() {
    Settings settings = Settings.of(singletonMap("key", "value"));
    assertThat(settings.keySet(), contains("key"));
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 40 with Settings

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

the class DefaultSettingsTest method shouldFindPrefix.

@Test
public void shouldFindPrefix() {
    Settings settings = Settings.builder().put("host", "host").put("host-1", "host-1").put("host-2", "host-2").put("host-3", "host-3").build();
    List<Object> hosts = settings.prefix("host");
    Assertions.assertEquals(4, hosts.size());
    assertThat(hosts, containsInAnyOrder("host", "host-1", "host-2", "host-3"));
}
Also used : 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