Search in sources :

Example 31 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.

the class ConfigurationManagementGraphTest method shouldReindexIfPropertyKeyExists.

@Test
public void shouldReindexIfPropertyKeyExists() {
    final Map<String, Object> map = new HashMap<>();
    map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
    final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
    final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
    final String propertyKeyName = "Created_Using_Template";
    final Class dataType = Boolean.class;
    JanusGraphManagement management = graph.openManagement();
    management.makePropertyKey(propertyKeyName).dataType(dataType).make();
    management.commit();
    // Instantiate the ConfigurationManagementGraph Singleton
    // This is purposefully done after a property key is created to ensure that a REDINDEX is initiated
    new ConfigurationManagementGraph(graph);
    management = graph.openManagement();
    final JanusGraphIndex index = management.getGraphIndex("Created_Using_Template_Index");
    final PropertyKey propertyKey = management.getPropertyKey("Created_Using_Template");
    assertNotNull(index);
    assertNotNull(propertyKey);
    assertEquals(ENABLED, index.getIndexStatus(propertyKey));
    management.commit();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) GraphDatabaseConfigurationBuilder(org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) PropertyKey(org.janusgraph.core.PropertyKey) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) Test(org.junit.jupiter.api.Test)

Example 32 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project bitflyer4j by after-the-sunrise.

the class Bitflyer4jFactoryTest method testGetRealtimeType.

@Test
public void testGetRealtimeType() {
    Map<String, String> map = new HashMap<>();
    MapConfiguration conf = new MapConfiguration(map);
    // Default
    assertSame(SocketServiceImpl.class, target.getRealtimeType(conf));
    // Invalid
    map.put(KeyType.REALTIME_TYPE.getKey(), "foo");
    assertSame(SocketServiceImpl.class, target.getRealtimeType(conf));
}
Also used : HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) Test(org.testng.annotations.Test)

Example 33 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project bitflyer4j by after-the-sunrise.

the class KeyTypeTest method testFetch_Unconfigured.

@Test
public void testFetch_Unconfigured() throws ConfigurationException {
    Configuration c = new MapConfiguration(new HashMap<>());
    for (KeyType type : KeyType.values()) {
        type.fetch(null);
        type.fetch(c);
    }
}
Also used : MapConfiguration(org.apache.commons.configuration2.MapConfiguration) Configuration(org.apache.commons.configuration2.Configuration) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) Test(org.testng.annotations.Test)

Example 34 with MapConfiguration

use of org.apache.commons.configuration2.MapConfiguration in project bitflyer4j by after-the-sunrise.

the class Bitflyer4jFactory method createConfiguration.

/**
 * Create a {@link Configuration} instance,
 * composed of multiple configurations which are enumerated in {@link ConfigurationType}.
 *
 * @return Composite configuration instance.
 */
@VisibleForTesting
AbstractConfiguration createConfiguration(Properties properties) {
    CompositeConfiguration composite = new CompositeConfiguration();
    ConfigurationType[] types = ConfigurationType.values();
    Arrays.stream(types).forEach(s -> s.get().ifPresent(composite::addConfiguration));
    Optional.ofNullable(properties).ifPresent(p -> composite.addConfiguration(new MapConfiguration(p)));
    return composite;
}
Also used : CompositeConfiguration(org.apache.commons.configuration2.CompositeConfiguration) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

MapConfiguration (org.apache.commons.configuration2.MapConfiguration)34 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)25 Test (org.junit.jupiter.api.Test)25 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)16 GraphDatabaseConfigurationBuilder (org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder)16 HashMap (java.util.HashMap)6 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)3 Test (org.testng.annotations.Test)3 Configuration (org.apache.commons.configuration2.Configuration)2 Settings (org.apache.tinkerpop.gremlin.server.Settings)2 AbstractConfiguredGraphFactoryTest (org.janusgraph.core.AbstractConfiguredGraphFactoryTest)2 ManagementSystem (org.janusgraph.graphdb.database.management.ManagementSystem)2 ConfigurationManagementGraph (org.janusgraph.graphdb.management.ConfigurationManagementGraph)2 Session (com.datastax.driver.core.Session)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Bindings (javax.script.Bindings)1 SimpleBindings (javax.script.SimpleBindings)1 CompositeConfiguration (org.apache.commons.configuration2.CompositeConfiguration)1 JanusGraphException (org.janusgraph.core.JanusGraphException)1 PropertyKey (org.janusgraph.core.PropertyKey)1