Search in sources :

Example 31 with Settings

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

the class CassandraColumnFamilyManagerFactoryTest method setUp.

@BeforeEach
public void setUp() {
    Settings settings = ManagerFactorySupplier.INSTANCE.getSettings();
    SettingsBuilder builder = Settings.builder();
    builder.put("cassandra.host.1", settings.get("cassandra.host-1").get().toString());
    builder.put("cassandra.port", settings.get("cassandra.port").get().toString());
    builder.put("cassandra.query.1", " CREATE KEYSPACE IF NOT EXISTS newKeySpace WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};");
    CassandraConfiguration cassandraConfiguration = new CassandraConfiguration();
    subject = cassandraConfiguration.get(builder.build());
}
Also used : SettingsBuilder(jakarta.nosql.Settings.SettingsBuilder) Settings(jakarta.nosql.Settings) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 32 with Settings

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

the class CassandraConfigurationTest method shouldCreateDocumentEntityManagerFactoryFromFile.

@Test
public void shouldCreateDocumentEntityManagerFactoryFromFile() {
    Settings settings = ManagerFactorySupplier.INSTANCE.getSettings();
    CassandraConfiguration cassandraConfiguration = new CassandraConfiguration();
    ColumnFamilyManagerFactory entityManagerFactory = cassandraConfiguration.get(settings);
    assertNotNull(entityManagerFactory);
}
Also used : ColumnFamilyManagerFactory(jakarta.nosql.column.ColumnFamilyManagerFactory) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 33 with Settings

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

the class BucketManagerFactoryConverter method success.

@Override
public BucketManagerFactory success(String value) {
    final SettingsConverter settingsConverter = BeanManagers.getInstance(SettingsConverter.class);
    Config config = BeanManagers.getInstance(Config.class);
    final Settings settings = settingsConverter.convert(value);
    String provider = value + ".provider";
    final Class<?> configurationClass = config.getValue(provider, Class.class);
    if (KeyValueConfiguration.class.isAssignableFrom(configurationClass)) {
        final Reflections reflections = BeanManagers.getInstance(Reflections.class);
        final KeyValueConfiguration configuration = (KeyValueConfiguration) reflections.newInstance(configurationClass);
        return configuration.get(settings);
    }
    throw new ConfigurationException("The class " + configurationClass + " is not valid to " + KeyValueConfiguration.class);
}
Also used : KeyValueConfiguration(jakarta.nosql.keyvalue.KeyValueConfiguration) SettingsConverter(org.eclipse.jnosql.mapping.configuration.SettingsConverter) ConfigurationException(org.eclipse.jnosql.mapping.configuration.ConfigurationException) Config(org.eclipse.microprofile.config.Config) Settings(jakarta.nosql.Settings) Reflections(org.eclipse.jnosql.mapping.reflection.Reflections)

Example 34 with Settings

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

the class GraphConverterTest method shouldReturnManagerFactory.

@Test
public void shouldReturnManagerFactory() {
    final String prefix = UUID.randomUUID().toString();
    System.setProperty(prefix, prefix);
    System.setProperty(prefix + ".settings.key", "value");
    System.setProperty(prefix + ".settings.key2", "value2");
    System.setProperty(prefix + ".provider", GraphConfigurationMock.class.getName());
    final Graph graph = config.getValue(prefix, Graph.class);
    final GraphMock factoryMock = GraphMock.class.cast(graph);
    final Settings settings = factoryMock.getSettings();
    assertEquals(2, settings.size());
    assertEquals(settings.get("key").get(), "value");
    assertEquals(settings.get("key2").get(), "value2");
    assertNotNull(graph);
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
}
Also used : GraphMock(org.eclipse.jnosql.mapping.graph.configuration.GraphConfigurationMock.GraphMock) Graph(org.apache.tinkerpop.gremlin.structure.Graph) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 35 with Settings

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

the class DefaultSettingsTest method shouldFindPrefixWithOrder.

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