@Description( "List all labels in the database." ) @Procedure( name = "db.labels", mode = READ ) public Stream<LabelResult> listLabels() { List<LabelResult> labelResults = asList( TokenAccess.LABELS.inUse( tx ).map( LabelResult::new ) ); return labelResults.stream(); }
@Description( "List all property keys in the database." ) @Procedure( name = "db.propertyKeys", mode = READ ) public Stream<PropertyKeyResult> listPropertyKeys() { List<PropertyKeyResult> propertyKeys = asList( TokenAccess.PROPERTY_KEYS.inUse( tx ).map( PropertyKeyResult::new ) ); return propertyKeys.stream(); }
private List<String> asFileInsidePartitionNames( ResourceIterator<File> resources ) { int testDirectoryPathLength = testDir.directory().getAbsolutePath().length(); return asList( resources ).stream() .map( file -> file.getAbsolutePath().substring( testDirectoryPathLength ) ) .collect( Collectors.toList() ); }
@Description( "List all relationship types in the database." ) @Procedure( name = "db.relationshipTypes", mode = READ ) public Stream<RelationshipTypeResult> listRelationshipTypes() { List<RelationshipTypeResult> relationshipTypes = asList( TokenAccess.RELATIONSHIP_TYPES.inUse( tx ).map( RelationshipTypeResult::new ) ); return relationshipTypes.stream(); }
@Description( "List all constraints in the database." ) @Procedure( name = "db.constraints", mode = READ ) public Stream<ConstraintResult> listConstraints() { SchemaRead schemaRead = tx.schemaRead(); TokenNameLookup tokens = new SilentTokenNameLookup( tx.tokenRead() ); return asList( schemaRead.constraintsGetAll() ) .stream() .map( constraint -> constraint.prettyPrint( tokens ) ) .sorted() .map( ConstraintResult::new ); }
@Override public void loadSchemaCache() { List<SchemaRule> schemaRules = Iterators.asList( neoStores.getSchemaStore().loadAllSchemaRules() ); schemaCache.load( schemaRules ); }
private void assertRels( Iterator<Long> it, long ... rels ) { List<Matcher<? super Iterable<Long>>> all = new ArrayList<>( rels.length ); for ( long element : rels ) { all.add(hasItem(element)); } List<Long> list = Iterators.asList( it ); assertThat( list, allOf(all)); } }
@Test public void shouldCompileAndRunProcedure() throws Throwable { // Given CallableProcedure proc = compiler.compileProcedure( ProcedureWithInjectedAPI.class, null, true ).get( 0 ); // Then List<Object[]> out = Iterators.asList( proc.apply( new BasicContext(), new Object[0], resourceTracker ) ); // Then assertThat( out.get( 0 ), equalTo( new Object[]{"Bonnie"} ) ); assertThat( out.get( 1 ), equalTo( new Object[]{"Clyde"} ) ); }
@Test public void shouldRunSimpleProcedure() throws Throwable { // Given CallableProcedure procedure = compile( ClassWithProcedureWithSimpleArgs.class ).get( 0 ); // When RawIterator<Object[],ProcedureException> out = procedure.apply( new BasicContext(), new Object[]{"Pontus", 35L}, resourceTracker ); // Then List<Object[]> collect = asList( out ); assertThat( collect.get( 0 )[0], equalTo( "Pontus is 35 years old." ) ); }
@Test public void testEmptyGraph() throws Throwable { // Given the database is empty // When Procedures procs = procs(); RawIterator<Object[],ProcedureException> stream = procs.procedureCallRead( procs.procedureGet( procedureName( "db", "schema" ) ).id(), new Object[0] ); // Then assertThat( asList( stream ), contains( equalTo( new Object[]{new ArrayList<>(), new ArrayList<>()} ) ) ); commit(); }
@Override public Collection<Injectable<?>> start( GraphDatabaseService graphDatabaseService, Configuration config ) { return Iterators.asList( Iterators.map( new StringToInjectableFunction(), config.getKeys() ) ); }
@Override public void evaluate() { // Then the database is not empty Result result = ruleWithDirectory.getGraphDatabaseService().execute( "MATCH (n) RETURN count(n) AS " + "count" ); List<Object> column = Iterators.asList( result.columnAs( "count" ) ); assertEquals( 1, column.size() ); assertEquals( 1L, column.get( 0 ) ); } }, null );
@Test public void shouldRunSimpleReadOnlyProcedure() throws Throwable { // Given CallableProcedure proc = compile( SingleReadOnlyProcedure.class ).get( 0 ); // When RawIterator<Object[],ProcedureException> out = proc.apply( new BasicContext(), new Object[0], resourceTracker ); // Then assertThat( asList( out ), contains( new Object[]{"Bonnie"}, new Object[]{"Clyde"} ) ); }
@Test void shouldHandleSingleItemIterators() { // Given ResourceIterator<Long> it1 = asResourceIterator( iterator( 1L ) ); ResourceIterator<Long> it2 = asResourceIterator( iterator( 5L, 6L, 7L ) ); CombiningResourceIterator<Long> combingIterator = new CombiningResourceIterator<>( iterator(it1, it2) ); // When I iterate through it, things come back in the right order assertThat( Iterators.asList( combingIterator ), equalTo(asList( 1L, 5L, 6L, 7L )) ); } }
@Test public void shouldCallRegisteredProcedure() throws Throwable { // Given procs.register( procedure ); // When RawIterator<Object[], ProcedureException> result = procs.callProcedure( new BasicContext(), signature.name(), new Object[]{1337}, resourceTracker ); // Then assertThat( asList( result ), contains( equalTo( new Object[]{1337} ) ) ); }
@Test public void listAllComponents() throws Throwable { // Given a running database // When RawIterator<Object[],ProcedureException> stream = procs().procedureCallRead( procs().procedureGet( procedureName( "dbms", "components" ) ).id(), new Object[0] ); // Then assertThat( asList( stream ), contains( equalTo( new Object[]{"Neo4j Kernel", singletonList( Version.getNeo4jVersion() ), "community"} ) ) ); commit(); }
private List<Object[]> callListConfig( String seatchString ) throws ProcedureException { QualifiedName procedureName = procedureName( "dbms", "listConfig" ); RawIterator<Object[],ProcedureException> callResult = dbmsOperations().procedureCallDbms( procedureName, toArray( seatchString ), dependencyResolver, AUTH_DISABLED, resourceTracker ); return asList( callResult ); } }
@Test void readAllDocuments() { LuceneAllDocumentsReader allDocumentsReader = createAllDocumentsReader(); List<Document> documents = Iterators.asList( allDocumentsReader.iterator() ); assertEquals( 3, documents.size(), "Should have 1 document from first partition and 2 from second one." ); assertEquals( "1", documents.get( 0 ).getField( "value" ).stringValue() ); assertEquals( "3", documents.get( 1 ).getField( "value" ).stringValue() ); assertEquals( "4", documents.get( 2 ).getField( "value" ).stringValue() ); }
@Test public void snapshotReadOnlyLabelScanStore() throws IOException { prepareIndex(); createAndStartReadOnly(); try ( ResourceIterator<File> indexFiles = store.snapshotStoreFiles() ) { List<File> files = Iterators.asList( indexFiles ); assertThat( "Should have at least index segment file.", files, hasLabelScanStore() ); } }