Search in sources :

Example 6 with Settings

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

the class DefaultSettingsTest method shouldSize.

@Test
public void shouldSize() {
    Settings settings = Settings.of(singletonMap("key", "value"));
    assertEquals(1, settings.size());
    settings = Settings.of(Collections.emptyMap());
    assertEquals(0, settings.size());
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 7 with Settings

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

the class DefaultSettingsTest method shouldComputeIfPresent.

@Test
public void shouldComputeIfPresent() {
    Settings settings = Settings.of(singletonMap("key", "12"));
    List<Map.Entry<String, Object>> references = new ArrayList<>();
    settings.computeIfPresent("key", (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)

Example 8 with Settings

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

the class DefaultSettingsTest method shouldComputeIAbsent.

@Test
public void shouldComputeIAbsent() {
    Settings settings = Settings.of(singletonMap("key", "12"));
    settings.computeIfAbsent("non", (k) -> "no key");
    assertEquals("no key", settings.get("non").get());
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 9 with Settings

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

the class DefaultSettingsTest method shouldFindPrefixes.

@Test
public void shouldFindPrefixes() {
    Settings settings = Settings.builder().put("host", "host").put("host-1", "host-1").put("server", "server").put("server-1", "server-1").build();
    List<Object> hosts = settings.prefix(Arrays.asList("host", "server"));
    Assertions.assertEquals(4, hosts.size());
    assertThat(hosts, containsInAnyOrder("host", "host-1", "server", "server-1"));
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 10 with Settings

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

the class DefaultSettingsTest method shouldFindPrefixesSort.

@Test
public void shouldFindPrefixesSort() {
    Settings settings = Settings.builder().put("host-1", "host-1").put("host", "host").put("server-1", "server-1").put("server", "server").build();
    List<Object> hosts = settings.prefix(Arrays.asList("host", "server"));
    Assertions.assertEquals(4, hosts.size());
    assertThat(hosts, containsInAnyOrder("host", "host-1", "server", "server-1"));
}
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