Search in sources :

Example 16 with Settings

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

the class DefaultSettingsTest method shouldContainsKeys.

@Test
public void shouldContainsKeys() {
    Settings settings = Settings.of(singletonMap("key", "value"));
    assertTrue(settings.containsKey("key"));
    assertFalse(settings.containsKey("key2"));
}
Also used : Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 17 with Settings

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

the class ColumnFamilyManagerFactoryConverterTest 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", ColumnConfigurationMock.class.getName());
    final ColumnFamilyManagerFactory managerFactory = config.getValue(prefix, ColumnFamilyManagerFactory.class);
    final ColumnConfigurationMock.ColumnFamilyManagerFactoryMock factoryMock = ColumnConfigurationMock.ColumnFamilyManagerFactoryMock.class.cast(managerFactory);
    final Settings settings = factoryMock.getSettings();
    assertEquals(2, settings.size());
    assertEquals(settings.get("key").get(), "value");
    assertEquals(settings.get("key2").get(), "value2");
    assertNotNull(managerFactory);
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
}
Also used : ColumnFamilyManagerFactory(jakarta.nosql.column.ColumnFamilyManagerFactory) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 18 with Settings

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

the class DocumentCollectionFactoryConverterTest 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", DocumentConfigurationMock.class.getName());
    final DocumentCollectionManagerFactory managerFactory = config.getValue(prefix, DocumentCollectionManagerFactory.class);
    final DocumentCollectionManagerFactoryMock factoryMock = DocumentCollectionManagerFactoryMock.class.cast(managerFactory);
    final Settings settings = factoryMock.getSettings();
    assertEquals(2, settings.size());
    assertEquals(settings.get("key").get(), "value");
    assertEquals(settings.get("key2").get(), "value2");
    assertNotNull(managerFactory);
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
}
Also used : DocumentCollectionManagerFactory(jakarta.nosql.document.DocumentCollectionManagerFactory) DocumentCollectionManagerFactoryMock(org.eclipse.jnosql.mapping.document.configuration.DocumentConfigurationMock.DocumentCollectionManagerFactoryMock) Settings(jakarta.nosql.Settings) Test(org.junit.jupiter.api.Test)

Example 19 with Settings

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

the class BucketManagerFactoryConverterTest 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", KeyValueConfigurationMock.class.getName());
    final BucketManagerFactory managerFactory = config.getValue(prefix, BucketManagerFactory.class);
    final BucketManagerFactoryMock factoryMock = BucketManagerFactoryMock.class.cast(managerFactory);
    final Settings settings = factoryMock.getSettings();
    assertEquals(2, settings.size());
    assertEquals(settings.get("key").get(), "value");
    assertEquals(settings.get("key2").get(), "value2");
    assertNotNull(managerFactory);
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
}
Also used : BucketManagerFactoryMock(org.eclipse.jnosql.mapping.keyvalue.configuration.KeyValueConfigurationMock.BucketManagerFactoryMock) Settings(jakarta.nosql.Settings) BucketManagerFactory(jakarta.nosql.keyvalue.BucketManagerFactory) Test(org.junit.jupiter.api.Test)

Example 20 with Settings

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

the class CassandraConfigurationTest method shouldCreateDocumentEntityManagerFactoryFromSettings.

@Test
public void shouldCreateDocumentEntityManagerFactoryFromSettings() {
    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)

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