Skip to content

Commit

Permalink
Remove option to list hidden config and add option to show only some
Browse files Browse the repository at this point in the history
  • Loading branch information
spacecowboy committed Jan 12, 2017
1 parent 587de6a commit 1fe2c6f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 40 deletions.
Expand Up @@ -43,14 +43,13 @@ public class BuiltInDbmsProcedures

@Description( "List the currently active config of Neo4j." )
@Procedure( name = "dbms.listConfig", mode = DBMS )
public Stream<ConfigResult> listConfig( @Name( value = "showHidden", defaultValue = "false" ) boolean showHidden,
@Name( value = "name", defaultValue = ".*" ) String namePattern )
public Stream<ConfigResult> listConfig( @Name( value = "namePrefix", defaultValue = "" ) String namePrefix )
{
Config config = graph.getDependencyResolver().resolveDependency( Config.class );
return config.getConfigValues().values().stream()
.map( ConfigResult::new )
.filter( c -> showHidden || !c.name.startsWith( "unsupported" ) )
.filter( c -> c.name.matches( namePattern ) )
.filter( c -> !c.name.startsWith( "unsupported" ) )
.filter( c -> c.name.startsWith( namePrefix ) )
.sorted( Comparator.comparing( c -> c.name ) );
}

Expand Down
Expand Up @@ -47,7 +47,7 @@ public void listConfig() throws Exception
// When
RawIterator<Object[],ProcedureException> stream =
dbmsOperations().procedureCallDbms( procedureName( "dbms", "listConfig" ),
Arrays.asList( false, ".*" ).toArray(),
Arrays.asList( "" ).toArray(),
AnonymousContext.none() );

// Then
Expand All @@ -67,43 +67,13 @@ public void listConfig() throws Exception
.count(), 0 );
}

@Test
public void listConfigWithUnsupported() throws Exception
{
// When
RawIterator<Object[],ProcedureException> stream =
dbmsOperations().procedureCallDbms( procedureName( "dbms", "listConfig" ),
Arrays.asList( true, ".*" ).toArray(),
AnonymousContext.none() );

// Then
List<Object[]> config = asList( stream );
List<String> names = config.stream()
.map( o -> o[0].toString() )
.collect( Collectors.toList() );

// The size of the config is not fixed so just make sure it's the right magnitude
assertTrue( names.size() > 10 );

assertThat( names, hasItem( GraphDatabaseSettings.record_format.name() ) );

// Should contain "unsupported.*" configs, again the number is not fixed
assertTrue( names.stream()
.filter( n -> n.startsWith( "unsupported" ) )
.count() > 10 );

// Check a specific unsupported one
assertTrue( GraphDatabaseSettings.cypher_runtime.name().startsWith( "unsupported" ) );
assertThat( names, hasItem( GraphDatabaseSettings.cypher_runtime.name() ) );
}

@Test
public void listConfigWithASpecificConfigName() throws Exception
{
// When
RawIterator<Object[],ProcedureException> stream =
dbmsOperations().procedureCallDbms( procedureName( "dbms", "listConfig" ),
Arrays.asList( true, GraphDatabaseSettings.strict_config_validation.name() ).toArray(),
Arrays.asList( GraphDatabaseSettings.strict_config_validation.name() ).toArray(),
AnonymousContext.none() );

// Then
Expand Down
Expand Up @@ -181,8 +181,8 @@ public void shouldListCorrectBuiltinProcedures() throws Throwable
// When/Then
assertThat( call( "dbms.procedures" ), containsInAnyOrder(
record( "dbms.listConfig",
"dbms.listConfig(showHidden = false :: BOOLEAN?, name = .* :: STRING?) :: (name :: STRING?, " +
"description :: STRING?, value :: STRING?)",
"dbms.listConfig(namePrefix = :: STRING?) :: (name :: STRING?, description :: STRING?, value" +
" :: STRING?)",
"List the currently active config of Neo4j." ),
record( "db.awaitIndex", "db.awaitIndex(index :: STRING?, timeOutSeconds = 300 :: INTEGER?) :: VOID", "Wait for an index to come online (for example: CALL db.awaitIndex(\":Person(name)\"))." ),
record( "db.constraints", "db.constraints() :: (description :: STRING?)", "List all constraints in the database." ),
Expand Down
Expand Up @@ -107,8 +107,8 @@ public void listProcedures() throws Throwable
// Then
assertThat( asList( stream ), containsInAnyOrder(
equalTo( new Object[]{ "dbms.listConfig",
"dbms.listConfig(showHidden = false :: BOOLEAN?, name = .* :: STRING?) :: (name :: STRING?, " +
"description :: STRING?, value :: STRING?)",
"dbms.listConfig(namePrefix = :: STRING?) :: (name :: STRING?, description :: STRING?, value" +
" :: STRING?)",
"List the currently active config of Neo4j." } ),
equalTo( new Object[]{"db.constraints", "db.constraints() :: (description :: STRING?)", "List all constraints in the database."} ),
equalTo( new Object[]{"db.indexes", "db.indexes() :: (description :: STRING?, state :: STRING?, type :: STRING?)", "List all indexes in the database."} ),
Expand Down

0 comments on commit 1fe2c6f

Please sign in to comment.