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());
}
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());
}
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());
}
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"));
}
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"));
}
Aggregations