    @Test
    public void testDijkstraDirection3()
    {
        Relationship r1 = graph.makeEdge( "start", "b" );
        Relationship r2 = graph.makeEdge( "c", "b" );
        Relationship r3 = graph.makeEdge( "c", "d" );
        Relationship r4 = graph.makeEdge( "e", "d" );
        Relationship r5 = graph.makeEdge( "e", "f" );
        Relationship r6 = graph.makeEdge( "g", "f" );
        Relationship r7 = graph.makeEdge( "g", "end" );
        HashMap<Relationship, Direction> dirs = new HashMap<>();
        Dijkstra<Double> dijkstra = new Dijkstra<>( (double) 0, graph.getNode( "start" ), graph.getNode( "end" ), new directionSavingCostEvaluator( dirs ),
                new org.neo4j.graphalgo.impl.util.DoubleAdder(), new org.neo4j.graphalgo.impl.util.DoubleComparator(),
                Direction.BOTH, MyRelTypes.R1 );
        dijkstra.getCost();
        assertEquals( Direction.OUTGOING, dirs.get( r1 ) );
        assertEquals( Direction.INCOMING, dirs.get( r2 ) );
        assertEquals( Direction.OUTGOING, dirs.get( r3 ) );
        assertEquals( Direction.INCOMING, dirs.get( r4 ) );
        assertEquals( Direction.OUTGOING, dirs.get( r5 ) );
        assertEquals( Direction.INCOMING, dirs.get( r6 ) );
        assertEquals( Direction.OUTGOING, dirs.get( r7 ) );
    }

    @Test
    public void testDijkstraDirection3()
    {
        Relationship r1 = graph.makeEdge( "start", "b" );
        Relationship r2 = graph.makeEdge( "c", "b" );
        Relationship r3 = graph.makeEdge( "c", "d" );
        Relationship r4 = graph.makeEdge( "e", "d" );
        Relationship r5 = graph.makeEdge( "e", "f" );
        Relationship r6 = graph.makeEdge( "g", "f" );
        Relationship r7 = graph.makeEdge( "g", "end" );
        HashMap<Relationship, Direction> dirs = new HashMap<Relationship, Direction>();
        Dijkstra<Double> dijkstra = new Dijkstra<Double>( (double) 0, graph
            .getNode( "start" ), graph.getNode( "end" ),
            new directionSavingCostEvaluator( dirs ),
            new org.neo4j.graphalgo.impl.util.DoubleAdder(),
            new org.neo4j.graphalgo.impl.util.DoubleComparator(),
            Direction.BOTH, MyRelTypes.R1 );
        dijkstra.getCost();
        assertEquals( Direction.OUTGOING, dirs.get( r1 ) );
        assertEquals( Direction.INCOMING, dirs.get( r2 ) );
        assertEquals( Direction.OUTGOING, dirs.get( r3 ) );
        assertEquals( Direction.INCOMING, dirs.get( r4 ) );
        assertEquals( Direction.OUTGOING, dirs.get( r5 ) );
        assertEquals( Direction.INCOMING, dirs.get( r6 ) );
        assertEquals( Direction.OUTGOING, dirs.get( r7 ) );
    }

Replace Generic With Diamond Dijkstra<Double> with Dijkstra<> in method public testDijkstraDirection3() : void from class org.neo4j.graphalgo.shortestpath.DijkstraDirectionTest


    protected Dijkstra<Double> getDijkstra( SimpleGraphBuilder graph,
        Double startCost, String startNode, String endNode )
    {
        return new Dijkstra<>( startCost, graph.getNode( startNode ), graph.getNode( endNode ), CommonEvaluators.doubleCostEvaluator( "cost" ),
                new org.neo4j.graphalgo.impl.util.DoubleAdder(), new org.neo4j.graphalgo.impl.util.DoubleComparator(),
                Direction.BOTH, MyRelTypes.R1 );
    }

    protected Dijkstra<Double> getDijkstra( SimpleGraphBuilder graph,
        Double startCost, String startNode, String endNode )
    {
        return new Dijkstra<Double>( startCost, graph.getNode( startNode ),
            graph.getNode( endNode ),
            CommonEvaluators.doubleCostEvaluator( "cost" ),
            new org.neo4j.graphalgo.impl.util.DoubleAdder(),
            new org.neo4j.graphalgo.impl.util.DoubleComparator(),
            Direction.BOTH, MyRelTypes.R1 );
    }

Replace Generic With Diamond Dijkstra<Double> with Dijkstra<> in method protected getDijkstra(graph SimpleGraphBuilder, startCost Double, startNode String, endNode String) : Dijkstra<Double> from class org.neo4j.graphalgo.shortestpath.DijkstraMultiplePathsTest


    @Test
    public void test6()
    {
        graph.makeEdgeChain( "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,z", "cost",
            (double) 1 );
        graph.makeEdge( "a", "b2", "cost", (double) 4 );
        graph.makeEdge( "b2", "c", "cost", -2 );
        Dijkstra<Double> dijkstra = new Dijkstra<>( 0.0, graph.getNode( "a" ), graph.getNode( "z" ),
                CommonEvaluators.doubleCostEvaluator( "cost" ), new org.neo4j.graphalgo.impl.util.DoubleAdder(),
                new org.neo4j.graphalgo.impl.util.DoubleComparator(), Direction.OUTGOING, MyRelTypes.R1 );
        List<List<Node>> paths = dijkstra.getPathsAsNodes();
        assertTrue( paths.size() == 2 );
    }

    @Test
    public void test6()
    {
        graph.makeEdgeChain( "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,z", "cost",
            (double) 1 );
        graph.makeEdge( "a", "b2", "cost", (double) 4 );
        graph.makeEdge( "b2", "c", "cost", -2 );
        Dijkstra<Double> dijkstra = new Dijkstra<Double>( 0.0, graph
            .getNode( "a" ), graph.getNode( "z" ),
            CommonEvaluators.doubleCostEvaluator( "cost" ),
            new org.neo4j.graphalgo.impl.util.DoubleAdder(),
            new org.neo4j.graphalgo.impl.util.DoubleComparator(),
            Direction.OUTGOING, MyRelTypes.R1 );
        List<List<Node>> paths = dijkstra.getPathsAsNodes();
        assertTrue( paths.size() == 2 );
    }

Replace Generic With Diamond Dijkstra<Double> with Dijkstra<> in method public test6() : void from class org.neo4j.graphalgo.shortestpath.DijkstraMultiplePathsTest


    /**
     * Test case for paths of length 0 and 1, and an impossible path
     */
    @Test
    public void testMinimal()
    {
        graph.makeEdge( "a", "b", "cost", (double) 1 );
        graph.makeEdge( "a", "c", "cost", (float) 1 );
        graph.makeEdge( "a", "d", "cost", (long) 1 );
        graph.makeEdge( "a", "e", "cost", 1 );
        graph.makeEdge( "b", "c", "cost", (double) 1 );
        graph.makeEdge( "c", "d", "cost", (byte) 1 );
        graph.makeEdge( "d", "e", "cost", (short) 1 );
        graph.makeEdge( "e", "b", "cost", (byte) 1 );
        FloydWarshall<Double> floydWarshall = new FloydWarshall<>( 0.0, Double.MAX_VALUE, Direction.OUTGOING,
                CommonEvaluators.doubleCostEvaluator( "cost" ), new org.neo4j.graphalgo.impl.util.DoubleAdder(),
                new org.neo4j.graphalgo.impl.util.DoubleComparator(), graph.getAllNodes(), graph.getAllEdges() );
        assertTrue( floydWarshall.getCost( graph.getNode( "a" ), graph
            .getNode( "a" ) ) == 0.0 );
        assertTrue( floydWarshall.getCost( graph.getNode( "a" ), graph
            .getNode( "b" ) ) == 1.0 );
        assertTrue( floydWarshall.getCost( graph.getNode( "b" ), graph
            .getNode( "a" ) ) == Double.MAX_VALUE );
    }

    /**
     * Test case for paths of length 0 and 1, and an impossible path
     */
    @Test
    public void testMinimal()
    {
        graph.makeEdge( "a", "b", "cost", (double) 1 );
        graph.makeEdge( "a", "c", "cost", (float) 1 );
        graph.makeEdge( "a", "d", "cost", (long) 1 );
        graph.makeEdge( "a", "e", "cost", 1 );
        graph.makeEdge( "b", "c", "cost", (double) 1 );
        graph.makeEdge( "c", "d", "cost", (byte) 1 );
        graph.makeEdge( "d", "e", "cost", (short) 1 );
        graph.makeEdge( "e", "b", "cost", (byte) 1 );
        FloydWarshall<Double> floydWarshall = new FloydWarshall<Double>( 0.0,
            Double.MAX_VALUE, Direction.OUTGOING,
            CommonEvaluators.doubleCostEvaluator( "cost" ),
            new org.neo4j.graphalgo.impl.util.DoubleAdder(),
            new org.neo4j.graphalgo.impl.util.DoubleComparator(), graph
                .getAllNodes(), graph.getAllEdges() );
        assertTrue( floydWarshall.getCost( graph.getNode( "a" ), graph
            .getNode( "a" ) ) == 0.0 );
        assertTrue( floydWarshall.getCost( graph.getNode( "a" ), graph
            .getNode( "b" ) ) == 1.0 );
        assertTrue( floydWarshall.getCost( graph.getNode( "b" ), graph
            .getNode( "a" ) ) == Double.MAX_VALUE );
    }

Replace Generic With Diamond FloydWarshall<Double> with FloydWarshall<> in method public testMinimal() : void from class org.neo4j.graphalgo.shortestpath.FloydWarshallTest


    /**
     * Test case for extracting paths
     */
    @Test
    public void testPath()
    {
        graph.makeEdge( "a", "b", "cost", (double) 1 );
        graph.makeEdge( "b", "c", "cost", (float) 1 );
        graph.makeEdge( "c", "d", "cost", 1 );
        graph.makeEdge( "d", "e", "cost", (long) 1 );
        graph.makeEdge( "e", "f", "cost", (byte) 1 );
        FloydWarshall<Double> floydWarshall = new FloydWarshall<>( 0.0, Double.MAX_VALUE, Direction.OUTGOING,
                CommonEvaluators.doubleCostEvaluator( "cost" ), new org.neo4j.graphalgo.impl.util.DoubleAdder(),
                new org.neo4j.graphalgo.impl.util.DoubleComparator(), graph.getAllNodes(), graph.getAllEdges() );
        List<Node> path = floydWarshall.getPath( graph.getNode( "a" ), graph
            .getNode( "f" ) );
        assertTrue( path.size() == 6 );
        assertTrue( path.get( 0 ).equals( graph.getNode( "a" ) ) );
        assertTrue( path.get( 1 ).equals( graph.getNode( "b" ) ) );
        assertTrue( path.get( 2 ).equals( graph.getNode( "c" ) ) );
        assertTrue( path.get( 3 ).equals( graph.getNode( "d" ) ) );
        assertTrue( path.get( 4 ).equals( graph.getNode( "e" ) ) );
        assertTrue( path.get( 5 ).equals( graph.getNode( "f" ) ) );
    }

    /**
     * Test case for extracting paths
     */
    @Test
    public void testPath()
    {
        graph.makeEdge( "a", "b", "cost", (double) 1 );
        graph.makeEdge( "b", "c", "cost", (float) 1 );
        graph.makeEdge( "c", "d", "cost", 1 );
        graph.makeEdge( "d", "e", "cost", (long) 1 );
        graph.makeEdge( "e", "f", "cost", (byte) 1 );
        FloydWarshall<Double> floydWarshall = new FloydWarshall<Double>( 0.0,
            Double.MAX_VALUE, Direction.OUTGOING,
            CommonEvaluators.doubleCostEvaluator( "cost" ),
            new org.neo4j.graphalgo.impl.util.DoubleAdder(),
            new org.neo4j.graphalgo.impl.util.DoubleComparator(), graph
                .getAllNodes(), graph.getAllEdges() );
        List<Node> path = floydWarshall.getPath( graph.getNode( "a" ), graph
            .getNode( "f" ) );
        assertTrue( path.size() == 6 );
        assertTrue( path.get( 0 ).equals( graph.getNode( "a" ) ) );
        assertTrue( path.get( 1 ).equals( graph.getNode( "b" ) ) );
        assertTrue( path.get( 2 ).equals( graph.getNode( "c" ) ) );
        assertTrue( path.get( 3 ).equals( graph.getNode( "d" ) ) );
        assertTrue( path.get( 4 ).equals( graph.getNode( "e" ) ) );
        assertTrue( path.get( 5 ).equals( graph.getNode( "f" ) ) );
    }

Replace Generic With Diamond FloydWarshall<Double> with FloydWarshall<> in method public testPath() : void from class org.neo4j.graphalgo.shortestpath.FloydWarshallTest


    @Override
    protected SingleSourceShortestPath<Integer> getSingleSourceAlgorithm(
        Node startNode )
    {
        return new SingleSourceShortestPathDijkstra<>( 0, startNode, ( relationship, direction ) -> 1, new IntegerAdder(),
                new org.neo4j.graphalgo.impl.util.IntegerComparator(), Direction.BOTH, MyRelTypes.R1 );
    }

    @Override
    protected SingleSourceShortestPath<Integer> getSingleSourceAlgorithm(
        Node startNode )
    {
        return new SingleSourceShortestPathDijkstra<Integer>( 0, startNode,
                ( relationship, direction ) -> 1, new org.neo4j.graphalgo.impl.util.IntegerAdder(),
            new org.neo4j.graphalgo.impl.util.IntegerComparator(),
            Direction.BOTH, MyRelTypes.R1 );
    }

Replace Generic With Diamond SingleSourceShortestPathDijkstra<Integer> with SingleSourceShortestPathDijkstra<> in method protected getSingleSourceAlgorithm(startNode Node) : SingleSourceShortestPath<Integer> from class org.neo4j.graphalgo.shortestpath.SingleSourceShortestPathDijkstraTest


    @Override
    protected SingleSourceShortestPath<Integer> getSingleSourceAlgorithm(
        Node startNode, Direction direction, RelationshipType... relTypes )
    {
        return new SingleSourceShortestPathDijkstra<>( 0, startNode, ( relationship, direction1 ) -> 1, new IntegerAdder(),
                new org.neo4j.graphalgo.impl.util.IntegerComparator(), direction, relTypes );
    }

    @Override
    protected SingleSourceShortestPath<Integer> getSingleSourceAlgorithm(
        Node startNode, Direction direction, RelationshipType... relTypes )
    {
        return new SingleSourceShortestPathDijkstra<Integer>( 0, startNode,
                ( relationship, direction1 ) -> 1, new org.neo4j.graphalgo.impl.util.IntegerAdder(),
            new org.neo4j.graphalgo.impl.util.IntegerComparator(), direction,
            relTypes );
    }

Replace Generic With Diamond SingleSourceShortestPathDijkstra<Integer> with SingleSourceShortestPathDijkstra<> in method protected getSingleSourceAlgorithm(startNode Node, direction Direction, relTypes RelationshipType...) : SingleSourceShortestPath<Integer> from class org.neo4j.graphalgo.shortestpath.SingleSourceShortestPathDijkstraTest


    @Override
    public StandardExpander add( RelationshipType type, Direction direction )
    {
        Collection<Pair<RelationshipType, Direction>> newTypes = new ArrayList<>( orderedTypes );
        newTypes.add( Pair.of( type, direction ) );
        return new OrderedByTypeExpander( newTypes );
    }

    @Override
    public StandardExpander add( RelationshipType type, Direction direction )
    {
        Collection<Pair<RelationshipType, Direction>> newTypes = new ArrayList<Pair<RelationshipType,Direction>>( orderedTypes );
        newTypes.add( Pair.of( type, direction ) );
        return new OrderedByTypeExpander( newTypes );
    }

Replace Generic With Diamond ArrayList<Pair<RelationshipType,Direction>> with ArrayList<> in method public add(type RelationshipType, direction Direction) : StandardExpander from class org.neo4j.graphdb.impl.OrderedByTypeExpander


    @Override
    public StandardExpander remove( RelationshipType type )
    {
        Collection<Pair<RelationshipType, Direction>> newTypes = new ArrayList<>();
        for ( Pair<RelationshipType,Direction> pair : orderedTypes )
        {
            if ( !type.name().equals( pair.first().name() ) )
            {
                newTypes.add( pair );
            }
        }
        return new OrderedByTypeExpander( newTypes );
    }

    @Override
    public StandardExpander remove( RelationshipType type )
    {
        Collection<Pair<RelationshipType, Direction>> newTypes = new ArrayList<Pair<RelationshipType,Direction>>();
        for ( Pair<RelationshipType,Direction> pair : orderedTypes )
        {
            if ( !type.name().equals( pair.first().name() ) )
            {
                newTypes.add( pair );
            }
        }
        return new OrderedByTypeExpander( newTypes );
    }

Replace Generic With Diamond ArrayList<Pair<RelationshipType,Direction>> with ArrayList<> in method public remove(type RelationshipType) : StandardExpander from class org.neo4j.graphdb.impl.OrderedByTypeExpander


    @Override
    public StandardExpander reverse()
    {
        Collection<Pair<RelationshipType, Direction>> newTypes = new ArrayList<>();
        for ( Pair<RelationshipType,Direction> pair : orderedTypes )
        {
            newTypes.add( Pair.of( pair.first(), pair.other().reverse() ) );
        }
        return new OrderedByTypeExpander( newTypes );
    }

    @Override
    public StandardExpander reverse()
    {
        Collection<Pair<RelationshipType, Direction>> newTypes = new ArrayList<Pair<RelationshipType,Direction>>();
        for ( Pair<RelationshipType,Direction> pair : orderedTypes )
        {
            newTypes.add( Pair.of( pair.first(), pair.other().reverse() ) );
        }
        return new OrderedByTypeExpander( newTypes );
    }

Replace Generic With Diamond ArrayList<Pair<RelationshipType,Direction>> with ArrayList<> in method public reverse() : StandardExpander from class org.neo4j.graphdb.impl.OrderedByTypeExpander


        @Override
        public InitialBranchState<STATE> reverse()
        {
            return new State<>( reversedInitialState, initialState );
        }

        @Override
        public InitialBranchState<STATE> reverse()
        {
            return new State<STATE>( reversedInitialState, initialState );
        }

Replace Generic With Diamond State<STATE> with State<> in method public reverse() : InitialBranchState<STATE> from class org.neo4j.graphdb.traversal.InitialBranchState.State


    private void consume( String name, InputIterator entities, Header header, Deserializer deserializer ) throws IOException
    {
        try ( PrintStream out = file( name + "header.csv" ) )
        {
            serialize( out, header );
        }

        try
        {
            int threads = Runtime.getRuntime().availableProcessors();
            ExecutorService executor = Executors.newFixedThreadPool( threads );
            for ( int i = 0; i < threads; i++ )
            {
                int id = i;
                executor.submit( (Callable<Void>) () -> {
                    StringDeserialization deserialization = new StringDeserialization( config );
                    try ( PrintStream out = file( name + "-" + id + ".csv" );
                          InputChunk chunk = entities.newChunk() )
                    {
                        InputEntity entity = new InputEntity();
                        while ( entities.next( chunk ) )
                        {
                            while ( chunk.next( entity ) )
                            {
                                out.println( deserializer.apply( entity, deserialization, header ) );
                            }
                        }
                    }
                    return null;
                } );
            }
            executor.shutdown();
            executor.awaitTermination( 10, TimeUnit.MINUTES );
        }
        catch ( InterruptedException e )
        {
            Thread.currentThread().interrupt();
            throw new IOException( e );
        }
    }

    private void consume( String name, InputIterator entities, Header header, Deserializer deserializer ) throws IOException
    {
        try ( PrintStream out = file( name + "header.csv" ) )
        {
            serialize( out, header );
        }

        try
        {
            int threads = Runtime.getRuntime().availableProcessors();
            ExecutorService executor = Executors.newFixedThreadPool( threads );
            for ( int i = 0; i < threads; i++ )
            {
                int id = i;
                executor.submit( new Callable<Void>()
                {
                    @Override
                    public Void call() throws Exception
                    {
                        StringDeserialization deserialization = new StringDeserialization( config );
                        try ( PrintStream out = file( name + "-" + id + ".csv" );
                              InputChunk chunk = entities.newChunk() )
                        {
                            InputEntity entity = new InputEntity();
                            while ( entities.next( chunk ) )
                            {
                                while ( chunk.next( entity ) )
                                {
                                    out.println( deserializer.apply( entity, deserialization, header ) );
                                }
                            }
                        }
                        return null;
                    }
                } );
            }
            executor.shutdown();
            executor.awaitTermination( 10, TimeUnit.MINUTES );
        }
        catch ( InterruptedException e )
        {
            Thread.currentThread().interrupt();
            throw new IOException( e );
        }
    }

Replace Anonymous With Lambda org.neo4j.tooling.CsvOutput.consume.submit.new Callable<Void> with () -> {StringDeserialization deserialization=new StringDeserialization(config); in method private consume(name String, entities InputIterator, header Header, deserializer Deserializer) : void from class org.neo4j.tooling.CsvOutput


    public static <T> Future<T> forkFuture( Callable<T> callable )
    {
        FutureTask<T> task = new FutureTask<>( callable );
        fork( task );
        return task;
    }

    public static <T> Future<T> forkFuture( Callable<T> callable )
    {
        FutureTask<T> task = new FutureTask<T>( callable );
        fork( task );
        return task;
    }

Replace Generic With Diamond FutureTask<T> with FutureTask<> in method public forkFuture(callable Callable<T>) : Future<T> from class org.neo4j.test.ThreadTestUtils


    public <T> Collection<T> getManagementBeans( Class<T> beanInterface )
    {
        Collection<T> result = null;
        if ( support.getClass() != ManagementSupport.class && beans.size() > 0 && beans.get( 0 ) instanceof KernelBean )
        {
            try
            {
                result = support.getProxiesFor( beanInterface, (KernelBean) beans.get( 0 ) );
            }
            catch ( UnsupportedOperationException ignore )
            {
                result = null; // go to fall back
            }
        }
        if ( result == null )
        {
            // Fall back: if we cannot create proxy, we can search for instances
            result = new ArrayList<>();
            for ( Neo4jMBean bean : beans )
            {
                if ( beanInterface.isInstance( bean ) )
                {
                    result.add( beanInterface.cast( bean ) );
                }
            }
        }
        return result;
    }

    public <T> Collection<T> getManagementBeans( Class<T> beanInterface )
    {
        Collection<T> result = null;
        if ( support.getClass() != ManagementSupport.class && beans.size() > 0 && beans.get( 0 ) instanceof KernelBean )
        {
            try
            {
                result = support.getProxiesFor( beanInterface, (KernelBean) beans.get( 0 ) );
            }
            catch ( UnsupportedOperationException ignore )
            {
                result = null; // go to fall back
            }
        }
        if ( result == null )
        {
            // Fall back: if we cannot create proxy, we can search for instances
            result = new ArrayList<T>();
            for ( Neo4jMBean bean : beans )
            {
                if ( beanInterface.isInstance( bean ) )
                {
                    result.add( beanInterface.cast( bean ) );
                }
            }
        }
        return result;
    }

Replace Generic With Diamond ArrayList<T> with ArrayList<> in method public getManagementBeans(beanInterface Class<T>) : Collection<T> from class org.neo4j.jmx.impl.JmxKernelExtension


    /**
     * Useful when combining multiple {@link SchemaIndexProvider} into one.
     *
     * @param parentStructure {@link IndexDirectoryStructure} of the parent.
     * @return {@link Factory} creating {@link IndexDirectoryStructure} looking something like:
     *
     * <pre>
     * <db>/schema/index/.../<indexId>/<childProviderKey>-<childProviderVersion>/
     * </pre>
     */
    public static Factory directoriesBySubProvider( IndexDirectoryStructure parentStructure )
    {
        return descriptor -> new IndexDirectoryStructure()
        {
            @Override
            public File rootDirectory()
            {
                return parentStructure.rootDirectory();
            }

            @Override
            public File directoryForIndex( long indexId )
            {
                return path( parentStructure.directoryForIndex( indexId ), fileNameFriendly( descriptor ) );
            }
        };
    }

    /**
     * Useful when combining multiple {@link SchemaIndexProvider} into one.
     *
     * @param parentStructure {@link IndexDirectoryStructure} of the parent.
     * @return {@link Factory} creating {@link IndexDirectoryStructure} looking something like:
     *
     * <pre>
     * <db>/schema/index/.../<indexId>/<childProviderKey>-<childProviderVersion>/
     * </pre>
     */
    public static Factory directoriesBySubProvider( IndexDirectoryStructure parentStructure )
    {
        return new Factory()
        {
            @Override
            public IndexDirectoryStructure forProvider( Descriptor descriptor )
            {
                return new IndexDirectoryStructure()
                {
                    @Override
                    public File rootDirectory()
                    {
                        return parentStructure.rootDirectory();
                    }

                    @Override
                    public File directoryForIndex( long indexId )
                    {
                        return path( parentStructure.directoryForIndex( indexId ), fileNameFriendly( descriptor ) );
                    }
                };
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.api.index.IndexDirectoryStructure.directoriesBySubProvider.new Factory with descriptor -> new IndexDirectoryStructure(){ in method public directoriesBySubProvider(parentStructure IndexDirectoryStructure) : Factory from class org.neo4j.kernel.api.index.IndexDirectoryStructure


    private GraphResult getGraphResult( final Map<String,VirtualNodeHack> nodeMap,
            final Map<String,Set<VirtualRelationshipHack>> relationshipMap )
    {
        List<Relationship> relationships = new LinkedList<>();
        for ( Set<VirtualRelationshipHack> relationship : relationshipMap.values() )
        {
            relationships.addAll( relationship );
        }

        GraphResult graphResult;
        graphResult = new GraphResult( new ArrayList<>( nodeMap.values() ), relationships );

        return graphResult;
    }

    private GraphResult getGraphResult( final Map<String,VirtualNodeHack> nodeMap,
            final Map<String,Set<VirtualRelationshipHack>> relationshipMap )
    {
        List<Relationship> relationships = new LinkedList<>();
        for ( Set<VirtualRelationshipHack> relationship : relationshipMap.values() )
        {
            relationships.addAll( relationship );
        }

        GraphResult graphResult;
        graphResult = new GraphResult( new ArrayList<Node>( nodeMap.values() ), relationships );

        return graphResult;
    }

Replace Generic With Diamond GraphResult with GraphResult in method private getGraphResult(nodeMap Map<String,VirtualNodeHack>, relationshipMap Map<String,Set<VirtualRelationshipHack>>) : GraphResult from class org.neo4j.kernel.builtinprocs.SchemaProcedure


        private Pair<File, KeyValueStoreFile> initialState( DataInitializer<EntryUpdater<Key>> initializer )
                throws IOException
        {
            long version = initializer.initialVersion();
            try ( ActiveState<Key> creation = stateFactory.open( ReadableState.empty( keyFormat(), version ), null ) )
            {
                try ( EntryUpdater<Key> updater = creation.resetter( new ReentrantLock(), () -> {} ) )
                {
                    initializer.initialize( updater );
                }
                return rotation.create( keyFormat().filter( creation.dataProvider() ), initializer.initialVersion() );
            }
        }

        private Pair<File, KeyValueStoreFile> initialState( DataInitializer<EntryUpdater<Key>> initializer )
                throws IOException
        {
            long version = initializer.initialVersion();
            ActiveState<Key> creation = stateFactory.open( ReadableState.empty( keyFormat(), version ), null );
            try
            {
                try ( EntryUpdater<Key> updater = creation.resetter( new ReentrantLock(), () ->
                {
                } ) )
                {
                    initializer.initialize( updater );
                }
                return rotation.create( keyFormat().filter( creation.dataProvider() ), initializer.initialVersion() );
            }
            finally
            {
                creation.close();
            }
        }

Try With Resources try(ActiveState<Key> creation=stateFactory.open(ReadableState.empty(keyFormat(),version),null)) in method private initialState(initializer DataInitializer<EntryUpdater<Key>>) : Pair<File,KeyValueStoreFile> from class org.neo4j.kernel.impl.store.kvstore.DeadState.NeedsCreation


    private Iterator<TraversalBranch> toBranches( Iterable<Node> nodes )
    {
        if ( uniqueness.eagerStartBranches() )
        {
            List<TraversalBranch> result = new ArrayList<>();
            for ( Node node : nodes )
            {
                result.add( new StartNodeTraversalBranch( context, this, node, initialState ) );
            }
            return result.iterator();
        }
        else
        {
            return new TraversalBranchIterator( nodes.iterator() );
        }
    }

    private Iterator<TraversalBranch> toBranches( Iterable<Node> nodes )
    {
        if ( uniqueness.eagerStartBranches() )
        {
            List<TraversalBranch> result = new ArrayList<TraversalBranch>();
            for ( Node node : nodes )
            {
                result.add( new StartNodeTraversalBranch( context, this, node, initialState ) );
            }
            return result.iterator();
        }
        else
        {
            return new TraversalBranchIterator( nodes.iterator() );
        }
    }

Replace Generic With Diamond ArrayList<TraversalBranch> with ArrayList<> in method private toBranches(nodes Iterable<Node>) : Iterator<TraversalBranch> from class org.neo4j.kernel.impl.traversal.AsOneStartBranch


    /**
     * Adds {@code evaluator} to the list of evaluators wrapped by the returned
     * evaluator. A new {@link MultiEvaluator} instance additionally containing
     * the supplied {@code evaluator} is returned and this instance will be
     * left intact.
     *
     * @param evaluator the {@link Evaluator} to add to this multi evaluator.
     * @return a new instance containing the current list of evaluator plus
     * the supplied one.
     */
    public MultiEvaluator<STATE> add( PathEvaluator<STATE> evaluator )
    {
        PathEvaluator[] newArray = new PathEvaluator[this.evaluators.length + 1];
        System.arraycopy( this.evaluators, 0, newArray, 0, this.evaluators.length );
        newArray[newArray.length - 1] = evaluator;
        return new MultiEvaluator<>( newArray );
    }

    /**
     * Adds {@code evaluator} to the list of evaluators wrapped by the returned
     * evaluator. A new {@link MultiEvaluator} instance additionally containing
     * the supplied {@code evaluator} is returned and this instance will be
     * left intact.
     *
     * @param evaluator the {@link Evaluator} to add to this multi evaluator.
     * @return a new instance containing the current list of evaluator plus
     * the supplied one.
     */
    public MultiEvaluator<STATE> add( PathEvaluator<STATE> evaluator )
    {
        PathEvaluator[] newArray = new PathEvaluator[this.evaluators.length + 1];
        System.arraycopy( this.evaluators, 0, newArray, 0, this.evaluators.length );
        newArray[newArray.length - 1] = evaluator;
        return new MultiEvaluator<STATE>( newArray );
    }

Replace Generic With Diamond MultiEvaluator<STATE> with MultiEvaluator<> in method public add(evaluator PathEvaluator<STATE>) : MultiEvaluator<STATE> from class org.neo4j.kernel.impl.traversal.MultiEvaluator


    @Override
    public Iterable<Relationship> relationships()
    {
        LinkedList<Relationship> relationships = new LinkedList<>();
        TraversalBranch branch = this;
        while ( branch.length() > 0 )
        {
            relationships.addFirst( branch.lastRelationship() );
            branch = branch.parent();
        }
        return relationships;
    }

    @Override
    public Iterable<Relationship> relationships()
    {
        LinkedList<Relationship> relationships = new LinkedList<Relationship>();
        TraversalBranch branch = this;
        while ( branch.length() > 0 )
        {
            relationships.addFirst( branch.lastRelationship() );
            branch = branch.parent();
        }
        return relationships;
    }

Replace Generic With Diamond LinkedList<Relationship> with LinkedList<> in method public relationships() : Iterable<Relationship> from class org.neo4j.kernel.impl.traversal.TraversalBranchImpl


    @Override
    public Iterable<Node> nodes()
    {
        LinkedList<Node> nodes = new LinkedList<>();
        TraversalBranch branch = this;
        while ( branch.length() > 0 )
        {
            nodes.addFirst( branch.endNode() );
            branch = branch.parent();
        }
        nodes.addFirst( branch.endNode() );
        return nodes;
    }

    @Override
    public Iterable<Node> nodes()
    {
        LinkedList<Node> nodes = new LinkedList<Node>();
        TraversalBranch branch = this;
        while ( branch.length() > 0 )
        {
            nodes.addFirst( branch.endNode() );
            branch = branch.parent();
        }
        nodes.addFirst( branch.endNode() );
        return nodes;
    }

Replace Generic With Diamond LinkedList<Node> with LinkedList<> in method public nodes() : Iterable<Node> from class org.neo4j.kernel.impl.traversal.TraversalBranchImpl


    @Override
    public Iterator<PropertyContainer> iterator()
    {
        LinkedList<PropertyContainer> entities = new LinkedList<>();
        TraversalBranch branch = this;
        while ( branch.length() > 0 )
        {
            entities.addFirst( branch.endNode() );
            entities.addFirst( branch.lastRelationship() );
            branch = branch.parent();
        }
        entities.addFirst( branch.endNode() );
        return entities.iterator();
    }

    @Override
    public Iterator<PropertyContainer> iterator()
    {
        LinkedList<PropertyContainer> entities = new LinkedList<PropertyContainer>();
        TraversalBranch branch = this;
        while ( branch.length() > 0 )
        {
            entities.addFirst( branch.endNode() );
            entities.addFirst( branch.lastRelationship() );
            branch = branch.parent();
        }
        entities.addFirst( branch.endNode() );
        return entities.iterator();
    }

Replace Generic With Diamond LinkedList<PropertyContainer> with LinkedList<> in method public iterator() : Iterator<PropertyContainer> from class org.neo4j.kernel.impl.traversal.TraversalBranchImpl


    @Override
    public long receive( long ticket, Void nothing )
    {
        new Thread( () -> {
            assertHealthy();
            try
            {
                try
                {
                    lastProcessingTimestamp = nanoTime();
                    process();
                }
                catch ( Throwable e )
                {
                    // we need to update panic state before ending upstream and notifying executor that we completed
                    issuePanic( e );
                }
                finally
                {
                    endOfUpstream();
                }
            }
            catch ( Throwable e )
            {
                // to avoid cases when we hide original panic problem
                // check first if we already in panic state and if so - rethrow original panic cause
                if ( !isPanic() )
                {
                    issuePanic( e );
                }
                else
                {
                    throw e;
                }
            }
        } ).start();
        return 0;
    }

    @Override
    public long receive( long ticket, Void nothing )
    {
        new Thread()
        {
            @Override
            public void run()
            {
                assertHealthy();
                try
                {
                    try
                    {
                        lastProcessingTimestamp = nanoTime();
                        process();
                    }
                    catch ( Throwable e )
                    {
                        // we need to update panic state before ending upstream and notifying executor that we completed
                        issuePanic( e );
                    }
                    finally
                    {
                        endOfUpstream();
                    }
                }
                catch ( Throwable e )
                {
                    // to avoid cases when we hide original panic problem
                    // check first if we already in panic state and if so - rethrow original panic cause
                    if ( !isPanic() )
                    {
                        issuePanic( e );
                    }
                    else
                    {
                        throw e;
                    }
                }
            }
        }.start();
        return 0;
    }

Replace Anonymous With Lambda org.neo4j.unsafe.impl.batchimport.staging.LonelyProcessingStep.receive.start.new Thread with () -> {assertHealthy(); in method public receive(ticket long, nothing Void) : long from class org.neo4j.unsafe.impl.batchimport.staging.LonelyProcessingStep


    @Test
    public void shouldSeeTheSameRecordsAtCheckpointAsAfterReverseRecovery() throws Exception
    {
        // given
        File storeDir = directory.absolutePath();
        EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction();
        GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fs ).newImpermanentDatabase( storeDir );
        produceRandomGraphUpdates( db, 100 );
        checkPoint( db );

        // when
        produceRandomGraphUpdates( db, 100 );
        flush( db );
        EphemeralFileSystemAbstraction crashedFs = fs.snapshot();
        db.shutdown();
        fs.close();
        Monitors monitors = new Monitors();
        AtomicReference<PageCache> pageCache = new AtomicReference<>();
        AtomicReference<EphemeralFileSystemAbstraction> reversedFs = new AtomicReference<>();
        monitors.addMonitorListener( new RecoveryMonitor()
        {
            @Override
            public void reverseStoreRecoveryCompleted( long checkpointTxId )
            {
                try
                {
                    // Flush the page cache which will fished out of the PlatformModule at the point of constructing the database
                    pageCache.get().flushAndForce();
                }
                catch ( IOException e )
                {
                    throw new UncheckedIOException( e );
                }

                // The stores should now be equal in content to the db as it was right after the checkpoint.
                // Grab a snapshot so that we can compare later.
                reversedFs.set( crashedFs.snapshot() );
            }
        } );
        new TestGraphDatabaseFactory()
                {
                    // This nested constructing is done purely to be able to fish out PlatformModule
                    // (and its PageCache inside it). It would be great if this could be done in a prettier way.

                    @Override
                    protected DatabaseCreator createImpermanentDatabaseCreator( File storeDir, TestGraphDatabaseFactoryState state )
                    {
                        return new GraphDatabaseBuilder.DatabaseCreator()
                        {
                            @Override
                            public GraphDatabaseService newDatabase( Map<String,String> config )
                            {
                                return newDatabase( Config.defaults( config ) );
                            }

                            @Override
                            public GraphDatabaseService newDatabase( @Nonnull Config config )
                            {
                                TestGraphDatabaseFacadeFactory factory = new TestGraphDatabaseFacadeFactory( state, true )
                                {
                                    @Override
                                    protected PlatformModule createPlatform( File storeDir, Config config, Dependencies dependencies,
                                            GraphDatabaseFacade graphDatabaseFacade )
                                    {
                                        PlatformModule platform = super.createPlatform( storeDir, config, dependencies, graphDatabaseFacade );
                                        // nice way of getting the page cache dependency before db is created, huh?
                                        pageCache.set( platform.pageCache );
                                        return platform;
                                    }
                                };
                                return factory.newFacade( storeDir, config, newDependencies( state.databaseDependencies() ) );
                            }
                        };
                    }
                }
                .setFileSystem( crashedFs )
                .setMonitors( monitors )
                .newImpermanentDatabase( storeDir )
                .shutdown();

        // then
        fs.close();

        try ( EphemeralFileSystemAbstraction checkPointFs = fs.snapshot() )
        {
            // Here we verify that the neostore contents, record by record are exactly the same when comparing
            // the store as it was right after the checkpoint with the store as it was right after reverse recovery completed.
            assertSameStoreContents( checkPointFs, reversedFs.get(), storeDir );
        }
        finally
        {
            reversedFs.get().close();
        }
    }

    @Test
    public void shouldSeeTheSameRecordsAtCheckpointAsAfterReverseRecovery() throws Exception
    {
        // given
        File storeDir = directory.absolutePath();
        EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction();
        GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fs ).newImpermanentDatabase( storeDir );
        produceRandomGraphUpdates( db, 100 );
        checkPoint( db );
        EphemeralFileSystemAbstraction checkPointFs = fs.snapshot();

        // when
        produceRandomGraphUpdates( db, 100 );
        flush( db );
        EphemeralFileSystemAbstraction crashedFs = fs.snapshot();
        db.shutdown();
        fs.close();
        Monitors monitors = new Monitors();
        AtomicReference<PageCache> pageCache = new AtomicReference<>();
        AtomicReference<EphemeralFileSystemAbstraction> reversedFs = new AtomicReference<>();
        monitors.addMonitorListener( new RecoveryMonitor()
        {
            @Override
            public void reverseStoreRecoveryCompleted( long checkpointTxId )
            {
                try
                {
                    // Flush the page cache which will fished out of the PlatformModule at the point of constructing the database
                    pageCache.get().flushAndForce();
                }
                catch ( IOException e )
                {
                    throw new UncheckedIOException( e );
                }

                // The stores should now be equal in content to the db as it was right after the checkpoint.
                // Grab a snapshot so that we can compare later.
                reversedFs.set( crashedFs.snapshot() );
            }
        } );
        new TestGraphDatabaseFactory()
                {
                    // This nested constructing is done purely to be able to fish out PlatformModule
                    // (and its PageCache inside it). It would be great if this could be done in a prettier way.

                    @Override
                    protected DatabaseCreator createImpermanentDatabaseCreator( File storeDir, TestGraphDatabaseFactoryState state )
                    {
                        return new GraphDatabaseBuilder.DatabaseCreator()
                        {
                            @Override
                            public GraphDatabaseService newDatabase( Map<String,String> config )
                            {
                                return newDatabase( Config.defaults( config ) );
                            }

                            @Override
                            public GraphDatabaseService newDatabase( @Nonnull Config config )
                            {
                                TestGraphDatabaseFacadeFactory factory = new TestGraphDatabaseFacadeFactory( state, true )
                                {
                                    @Override
                                    protected PlatformModule createPlatform( File storeDir, Config config, Dependencies dependencies,
                                            GraphDatabaseFacade graphDatabaseFacade )
                                    {
                                        PlatformModule platform = super.createPlatform( storeDir, config, dependencies, graphDatabaseFacade );
                                        // nice way of getting the page cache dependency before db is created, huh?
                                        pageCache.set( platform.pageCache );
                                        return platform;
                                    }
                                };
                                return factory.newFacade( storeDir, config, newDependencies( state.databaseDependencies() ) );
                            }
                        };
                    }
                }
                .setFileSystem( crashedFs )
                .setMonitors( monitors )
                .newImpermanentDatabase( storeDir )
                .shutdown();

        // then
        fs.close();

        try
        {
            // Here we verify that the neostore contents, record by record are exactly the same when comparing
            // the store as it was right after the checkpoint with the store as it was right after reverse recovery completed.
            assertSameStoreContents( checkPointFs, reversedFs.get(), storeDir );
        }
        finally
        {
            checkPointFs.close();
            reversedFs.get().close();
        }
    }

Try With Resources try(EphemeralFileSystemAbstraction checkPointFs=fs.snapshot()) in method public shouldSeeTheSameRecordsAtCheckpointAsAfterReverseRecovery() : void from class org.neo4j.kernel.RecoveryIT


    @Test
    public void shouldUpdateSizeWhenRemoving() throws Exception
    {
        ClockCache<String, Integer> cache = new ClockCache<>( "foo", 3 );
        cache.put( "bar", 42 );
        cache.put( "baz", 87 );

        cache.remove( "bar" );

        assertThat( cache.size(), is( 1 ) );
    }

    @Test
    public void shouldUpdateSizeWhenRemoving() throws Exception
    {
        ClockCache<String, Integer> cache = new ClockCache<String, Integer>( "foo", 3 );
        cache.put( "bar", 42 );
        cache.put( "baz", 87 );

        cache.remove( "bar" );

        assertThat( cache.size(), is( 1 ) );
    }

Replace Generic With Diamond ClockCache<String,Integer> with ClockCache<> in method public shouldUpdateSizeWhenRemoving() : void from class org.neo4j.kernel.impl.cache.TestClockCache


    private static <T> Collection<T> asSet( Collection<T> collection )
    {
        return new HashSet<>( collection );
    }

    private static <T> Collection<T> asSet( Collection<T> collection )
    {
        return new HashSet<T>( collection );
    }

Replace Generic With Diamond HashSet<T> with HashSet<> in method private asSet(collection Collection<T>) : Collection<T> from class org.neo4j.kernel.impl.core.BigStoreIT


    @Test
    public void tryToReproduceTheIssue() throws Exception
    {
        // GIVEN
        GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
        CountDownLatch startSignal = new CountDownLatch( 1 );
        AtomicBoolean stopSignal = new AtomicBoolean();
        AtomicReference<Exception> failure = new AtomicReference<>();
        Node parentNode = createNode( db );
        Collection<Worker> workers = createWorkers( db, startSignal, stopSignal, failure, parentNode );

        // WHEN
        startSignal.countDown();
        sleep( 500 );
        stopSignal.set( true );
        awaitWorkersToEnd( workers );

        // THEN
        if ( failure.get() != null )
        {
            throw new Exception( "A worker failed", failure.get() );
        }
    }

    @Test
    public void tryToReproduceTheIssue() throws Exception
    {
        // GIVEN
        GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
        CountDownLatch startSignal = new CountDownLatch( 1 );
        AtomicBoolean stopSignal = new AtomicBoolean();
        AtomicReference<Exception> failure = new AtomicReference<Exception>();
        Node parentNode = createNode( db );
        Collection<Worker> workers = createWorkers( db, startSignal, stopSignal, failure, parentNode );

        // WHEN
        startSignal.countDown();
        sleep( 500 );
        stopSignal.set( true );
        awaitWorkersToEnd( workers );

        // THEN
        if ( failure.get() != null )
        {
            throw new Exception( "A worker failed", failure.get() );
        }
    }

Replace Generic With Diamond AtomicReference<Exception> with AtomicReference<> in method public tryToReproduceTheIssue() : void from class org.neo4j.kernel.impl.core.ConcurrentCreateAndGetRelationshipsIT


    private Collection<Worker> createWorkers( GraphDatabaseService db, CountDownLatch startSignal,
            AtomicBoolean stopSignal, AtomicReference<Exception> failure, Node parentNode )
    {
        Collection<Worker> workers = new ArrayList<>();
        for ( int i = 0; i < 2; i++ )
        {
            workers.add( newWorker( db, startSignal, stopSignal, failure, parentNode ) );
        }
        return workers;
    }

    private Collection<Worker> createWorkers( GraphDatabaseService db, CountDownLatch startSignal,
            AtomicBoolean stopSignal, AtomicReference<Exception> failure, Node parentNode )
    {
        Collection<Worker> workers = new ArrayList<Worker>();
        for ( int i = 0; i < 2; i++ )
        {
            workers.add( newWorker( db, startSignal, stopSignal, failure, parentNode ) );
        }
        return workers;
    }

Replace Generic With Diamond ArrayList<Worker> with ArrayList<> in method private createWorkers(db GraphDatabaseService, startSignal CountDownLatch, stopSignal AtomicBoolean, failure AtomicReference<Exception>, parentNode Node) : Collection<Worker> from class org.neo4j.kernel.impl.core.ConcurrentCreateAndGetRelationshipsIT


    @Test
    public void getAllNodesIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() throws Exception
    {
        // GIVEN
        {
            Transaction tx = db.beginTx();
            db.createNode();
            db.createNode();
            tx.success();
            tx.close();
        }

        // WHEN iterator is started
        Transaction transaction = db.beginTx();
        Iterator<Node> allNodes = db.getAllNodes().iterator();
        allNodes.next();

        // and WHEN another node is then added
        Thread thread = new Thread( () ->
        {
            Transaction newTx = db.beginTx();
            assertThat( newTx, not( instanceOf( PlaceboTransaction.class ) ) );
            db.createNode();
            newTx.success();
            newTx.close();
        } );
        thread.start();
        thread.join();

        // THEN the new node is picked up by the iterator
        assertThat( addToCollection( allNodes, new ArrayList<>() ).size(), is( 2 ) );
        transaction.close();
    }

    @Test
    public void getAllNodesIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() throws Exception
    {
        // GIVEN
        {
            Transaction tx = db.beginTx();
            db.createNode();
            db.createNode();
            tx.success();
            tx.close();
        }

        // WHEN iterator is started
        Transaction transaction = db.beginTx();
        Iterator<Node> allNodes = db.getAllNodes().iterator();
        allNodes.next();

        // and WHEN another node is then added
        Thread thread = new Thread( () ->
        {
            Transaction newTx = db.beginTx();
            assertThat( newTx, not( instanceOf( PlaceboTransaction.class ) ) );
            db.createNode();
            newTx.success();
            newTx.close();
        } );
        thread.start();
        thread.join();

        // THEN the new node is picked up by the iterator
        assertThat( addToCollection( allNodes, new ArrayList<Node>() ).size(), is( 2 ) );
        transaction.close();
    }

Replace Generic With Diamond ArrayList<Node> with ArrayList<> in method public getAllNodesIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() : void from class org.neo4j.kernel.impl.core.NodeManagerTest


    @Test
    public void getAllRelationshipsIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() throws Exception
    {
        // GIVEN
        Transaction tx = db.beginTx();
        createRelationshipAssumingTxWith( "key", 1 );
        createRelationshipAssumingTxWith( "key", 2 );
        tx.success();
        tx.close();

        // WHEN
        tx = db.beginTx();
        Iterator<Relationship> allRelationships = db.getAllRelationships().iterator();

        Thread thread = new Thread( () ->
        {
            Transaction newTx = db.beginTx();
            assertThat( newTx, not( instanceOf( PlaceboTransaction.class ) ) );
            createRelationshipAssumingTxWith( "key", 3 );
            newTx.success();
            newTx.close();
        } );
        thread.start();
        thread.join();

        // THEN
        assertThat( addToCollection( allRelationships, new ArrayList<>() ).size(), is(3) );
        tx.success();
        tx.close();
    }

    @Test
    public void getAllRelationshipsIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() throws Exception
    {
        // GIVEN
        Transaction tx = db.beginTx();
        createRelationshipAssumingTxWith( "key", 1 );
        createRelationshipAssumingTxWith( "key", 2 );
        tx.success();
        tx.close();

        // WHEN
        tx = db.beginTx();
        Iterator<Relationship> allRelationships = db.getAllRelationships().iterator();

        Thread thread = new Thread( () ->
        {
            Transaction newTx = db.beginTx();
            assertThat( newTx, not( instanceOf( PlaceboTransaction.class ) ) );
            createRelationshipAssumingTxWith( "key", 3 );
            newTx.success();
            newTx.close();
        } );
        thread.start();
        thread.join();

        // THEN
        assertThat( addToCollection( allRelationships, new ArrayList<Relationship>() ).size(), is(3) );
        tx.success();
        tx.close();
    }

Replace Generic With Diamond ArrayList<Relationship> with ArrayList<> in method public getAllRelationshipsIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() : void from class org.neo4j.kernel.impl.core.NodeManagerTest


    private void verifyRelationships( String message, Node root,
            boolean[] loop, Relationship... relationships )
    {
        for ( Direction dir : Direction.values() )
        {
            Set<Relationship> expected = new HashSet<>();
            for ( int i = 0; i < relationships.length; i++ )
            {
                if ( relationships[i] != null
                        && (dir != Direction.INCOMING || loop[i]) )
                {
                    expected.add( relationships[i] );
                }
            }

            for ( Relationship rel : root.getRelationships( dir ) )
            {
                assertTrue( message + ": unexpected relationship: " + rel,
                        expected.remove( rel ) );
            }
            assertTrue( message + ": expected relationships not seen "
                            + expected,
                    expected.isEmpty() );
        }
    }

    private void verifyRelationships( String message, Node root,
            boolean[] loop, Relationship... relationships )
    {
        for ( Direction dir : Direction.values() )
        {
            Set<Relationship> expected = new HashSet<Relationship>();
            for ( int i = 0; i < relationships.length; i++ )
            {
                if ( relationships[i] != null
                        && (dir != Direction.INCOMING || loop[i]) )
                {
                    expected.add( relationships[i] );
                }
            }

            for ( Relationship rel : root.getRelationships( dir ) )
            {
                assertTrue( message + ": unexpected relationship: " + rel,
                        expected.remove( rel ) );
            }
            assertTrue( message + ": expected relationships not seen "
                            + expected,
                    expected.isEmpty() );
        }
    }

Replace Generic With Diamond HashSet<Relationship> with HashSet<> in method private verifyRelationships(message String, root Node, loop boolean[], relationships Relationship...) : void from class org.neo4j.kernel.impl.core.TestLoopRelationships


    @Test
    public void convertNodeToDense() throws Exception
    {
        Node node = getGraphDb().createNode();
        EnumMap<MyRelTypes,Set<Relationship>> rels = new EnumMap<>( MyRelTypes.class );
        for ( MyRelTypes type : MyRelTypes.values() )
        {
            rels.put( type, new HashSet<>() );
        }
        int expectedRelCount = 0;
        for ( int i = 0; i < 6; i++, expectedRelCount++ )
        {
            MyRelTypes type = MyRelTypes.values()[i % MyRelTypes.values().length];
            Relationship rel = node.createRelationshipTo( getGraphDb().createNode(), type );
            rels.get( type ).add( rel );
        }
        newTransaction();
        for ( int i = 0; i < 1000; i++, expectedRelCount++ )
        {
            node.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST );
        }

        assertEquals( expectedRelCount, node.getDegree() );
        assertEquals( expectedRelCount, node.getDegree( Direction.BOTH ) );
        assertEquals( expectedRelCount, node.getDegree( Direction.OUTGOING ) );
        assertEquals( 0, node.getDegree( Direction.INCOMING ) );
        assertEquals( rels.get( MyRelTypes.TEST2 ), Iterables.asSet( node.getRelationships( MyRelTypes.TEST2 ) ) );
        assertEquals( join( rels.get( MyRelTypes.TEST_TRAVERSAL ), rels.get( MyRelTypes.TEST2 ) ),
                Iterables.asSet( node.getRelationships( MyRelTypes.TEST_TRAVERSAL, MyRelTypes.TEST2 ) ) );
    }

    @Test
    public void convertNodeToDense() throws Exception
    {
        Node node = getGraphDb().createNode();
        EnumMap<MyRelTypes,Set<Relationship>> rels = new EnumMap<>( MyRelTypes.class );
        for ( MyRelTypes type : MyRelTypes.values() )
        {
            rels.put( type, new HashSet<Relationship>() );
        }
        int expectedRelCount = 0;
        for ( int i = 0; i < 6; i++, expectedRelCount++ )
        {
            MyRelTypes type = MyRelTypes.values()[i % MyRelTypes.values().length];
            Relationship rel = node.createRelationshipTo( getGraphDb().createNode(), type );
            rels.get( type ).add( rel );
        }
        newTransaction();
        for ( int i = 0; i < 1000; i++, expectedRelCount++ )
        {
            node.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST );
        }

        assertEquals( expectedRelCount, node.getDegree() );
        assertEquals( expectedRelCount, node.getDegree( Direction.BOTH ) );
        assertEquals( expectedRelCount, node.getDegree( Direction.OUTGOING ) );
        assertEquals( 0, node.getDegree( Direction.INCOMING ) );
        assertEquals( rels.get( MyRelTypes.TEST2 ), Iterables.asSet( node.getRelationships( MyRelTypes.TEST2 ) ) );
        assertEquals( join( rels.get( MyRelTypes.TEST_TRAVERSAL ), rels.get( MyRelTypes.TEST2 ) ),
                Iterables.asSet( node.getRelationships( MyRelTypes.TEST_TRAVERSAL, MyRelTypes.TEST2 ) ) );
    }

Replace Generic With Diamond HashSet<Relationship> with HashSet<> in method public convertNodeToDense() : void from class org.neo4j.kernel.impl.core.TestRelationshipCount


    @Test
    public void shouldHandleWritesProperlyAfterRecovery() throws Exception
    {
        // Given
        EphemeralFileSystemAbstraction fs = fsRule.get();
        GraphDatabaseService db = newDB( fs );

        long node1 = createNode( db );

        // And given the power goes out
        db.shutdown();
        try ( EphemeralFileSystemAbstraction crashedFs = fs.snapshot() )
        {
            db = newDB( crashedFs );

            long node2 = createNode( db );
            db.shutdown();

            // Then the logical log should be in sync
            File logFile = new File( storeDir, TransactionLogFiles.DEFAULT_NAME + ".0" );
            assertThat( logEntries( crashedFs, logFile ), containsExactly(
                    // Tx before recovery
                    startEntry( -1, -1 ), commandEntry( node1, NodeCommand.class ),
                    commandEntry( ReadOperations.ANY_LABEL, NodeCountsCommand.class ), commitEntry( 2 ),

                    // Tx after recovery
                    startEntry( -1, -1 ), commandEntry( node2, NodeCommand.class ),
                    commandEntry( ReadOperations.ANY_LABEL, NodeCountsCommand.class ), commitEntry( 3 ),

                    // checkpoint
                    checkPoint( new LogPosition( 0, 250 ) ) ) );
        }
    }

    @Test
    public void shouldHandleWritesProperlyAfterRecovery() throws Exception
    {
        // Given
        EphemeralFileSystemAbstraction fs = fsRule.get();
        GraphDatabaseService db = newDB( fs );

        long node1 = createNode( db );

        // And given the power goes out
        EphemeralFileSystemAbstraction crashedFs = fs.snapshot();
        db.shutdown();
        try
        {
            db = newDB( crashedFs );

            long node2 = createNode( db );
            db.shutdown();

            // Then the logical log should be in sync
            File logFile = new File( storeDir, TransactionLogFiles.DEFAULT_NAME + ".0" );
            assertThat( logEntries( crashedFs, logFile ), containsExactly(
                    // Tx before recovery
                    startEntry( -1, -1 ), commandEntry( node1, NodeCommand.class ),
                    commandEntry( ReadOperations.ANY_LABEL, NodeCountsCommand.class ), commitEntry( 2 ),

                    // Tx after recovery
                    startEntry( -1, -1 ), commandEntry( node2, NodeCommand.class ),
                    commandEntry( ReadOperations.ANY_LABEL, NodeCountsCommand.class ), commitEntry( 3 ),

                    // checkpoint
                    checkPoint( new LogPosition( 0, 250 ) ) ) );
        }
        finally
        {
            crashedFs.close();
        }
    }

Try With Resources try(EphemeralFileSystemAbstraction crashedFs=fs.snapshot()) in method public shouldHandleWritesProperlyAfterRecovery() : void from class org.neo4j.kernel.impl.recovery.KernelRecoveryTest


    @Test
    public void shouldKeepItsCoolWhenMultipleThreadsAreHammeringIt() throws Exception
    {
        // An interesting note is that during tests the call to sequence#offer made no difference
        // in performance, so there seems to be no visible penalty in using ArrayQueueOutOfOrderSequence.

        // GIVEN a sequence with intentionally low starting queue size
        final AtomicLong numberSource = new AtomicLong();
        final OutOfOrderSequence sequence = new ArrayQueueOutOfOrderSequence( numberSource.get(), 5, new long[1] );
        final AtomicBoolean end = new AtomicBoolean();
        // and a bunch of threads that will start offering numbers at the same time
        final CountDownLatch startSignal = new CountDownLatch( 1 );
        Thread[] threads = new Thread[1];
        for ( int i = 0; i < threads.length; i++ )
        {
            threads[i] = new Thread( () -> {
                await( startSignal );
                while ( !end.get() )
                {
                    long number = numberSource.incrementAndGet();
                    offer( sequence, number, new long[]{number + 2} );
                }
            } );
        }

        // WHEN
        for ( Thread thread : threads )
        {
            thread.start();
        }
        startSignal.countDown();
        while ( numberSource.get() < 10_000_000 )
        {
            sleep( 1 );
            yield();
        }
        end.set( true );
        for ( Thread thread : threads )
        {
            thread.join();
        }

        // THEN
        long lastNumber = numberSource.get();
        assertGet( sequence, lastNumber, new long[]{lastNumber + 2} );
    }

    @Test
    public void shouldKeepItsCoolWhenMultipleThreadsAreHammeringIt() throws Exception
    {
        // An interesting note is that during tests the call to sequence#offer made no difference
        // in performance, so there seems to be no visible penalty in using ArrayQueueOutOfOrderSequence.

        // GIVEN a sequence with intentionally low starting queue size
        final AtomicLong numberSource = new AtomicLong();
        final OutOfOrderSequence sequence = new ArrayQueueOutOfOrderSequence( numberSource.get(), 5, new long[1] );
        final AtomicBoolean end = new AtomicBoolean();
        // and a bunch of threads that will start offering numbers at the same time
        final CountDownLatch startSignal = new CountDownLatch( 1 );
        Thread[] threads = new Thread[1];
        for ( int i = 0; i < threads.length; i++ )
        {
            threads[i] = new Thread()
            {
                @Override
                public void run()
                {
                    await( startSignal );
                    while ( !end.get() )
                    {
                        long number = numberSource.incrementAndGet();
                        offer( sequence, number, new long[]{number + 2} );
                    }
                }
            };
        }

        // WHEN
        for ( Thread thread : threads )
        {
            thread.start();
        }
        startSignal.countDown();
        while ( numberSource.get() < 10_000_000 )
        {
            sleep( 1 );
            yield();
        }
        end.set( true );
        for ( Thread thread : threads )
        {
            thread.join();
        }

        // THEN
        long lastNumber = numberSource.get();
        assertGet( sequence, lastNumber, new long[]{lastNumber + 2} );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.store.ArrayQueueOutOfOrderSequenceTest.shouldKeepItsCoolWhenMultipleThreadsAreHammeringIt.new Thread with () -> {await(startSignal); in method public shouldKeepItsCoolWhenMultipleThreadsAreHammeringIt() : void from class org.neo4j.kernel.impl.store.ArrayQueueOutOfOrderSequenceTest


    @Test
    public void impossibleToGetNotRequestedStore()
    {
        Config config = Config.defaults();
        StoreFactory sf = new StoreFactory( storeDir, config, new DefaultIdGeneratorFactory( fs.get() ), pageCache,
                fs.get(), NullLogProvider.getInstance() );

        exception.expect( IllegalStateException.class );
        exception.expectMessage(
                "Specified store was not initialized. Please specify " + StoreType.META_DATA.name() +
                " as one of the stores types that should be open to be able to use it." );
        try ( NeoStores neoStores = sf.openNeoStores( true, StoreType.NODE_LABEL ) )
        {
            neoStores.getMetaDataStore();
        }
    }

    @Test
    public void impossibleToGetNotRequestedStore()
    {
        Config config = Config.defaults();
        StoreFactory sf = new StoreFactory( storeDir, config, new DefaultIdGeneratorFactory( fs.get() ), pageCache,
                fs.get(), NullLogProvider.getInstance() );
        NeoStores neoStores = sf.openNeoStores( true, StoreType.NODE_LABEL );

        exception.expect( IllegalStateException.class );
        exception.expectMessage(
                "Specified store was not initialized. Please specify " + StoreType.META_DATA.name() +
                " as one of the stores types that should be open to be able to use it." );
        try
        {
            neoStores.getMetaDataStore();
        }
        finally
        {
            neoStores.close();
        }
    }

Try With Resources try(NeoStores neoStores=sf.openNeoStores(true,StoreType.NODE_LABEL)) in method public impossibleToGetNotRequestedStore() : void from class org.neo4j.kernel.impl.store.NeoStoresTest


    private Map<String, Object> mapWithManyProperties( int count )
    {
        Map<String, Object> properties = new HashMap<>();
        for ( int i = 0; i < count; i++ )
        {
            properties.put( "key:" + i, "value" );
        }
        return properties;
    }

    private Map<String, Object> mapWithManyProperties( int count )
    {
        Map<String, Object> properties = new HashMap<String, Object>();
        for ( int i = 0; i < count; i++ )
        {
            properties.put( "key:" + i, "value" );
        }
        return properties;
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method private mapWithManyProperties(count int) : Map<String,Object> from class org.neo4j.kernel.impl.store.PropertyKeyTest


    private void executeTransactionInSeparateThread( final Runnable actionInsideTransaction ) throws InterruptedException
    {
        Thread thread = new Thread( () -> {
            try ( Transaction tx = db.beginTx() )
            {
                actionInsideTransaction.run();
                tx.success();
            }
        } );
        thread.start();
        thread.join();
    }

    private void executeTransactionInSeparateThread( final Runnable actionInsideTransaction ) throws InterruptedException
    {
        Thread thread = new Thread()
        {
            @Override
            public void run()
            {
                try ( Transaction tx = db.beginTx() )
                {
                    actionInsideTransaction.run();
                    tx.success();
                }
            }
        };
        thread.start();
        thread.join();
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.store.RelationshipChainPointerChasingTest.executeTransactionInSeparateThread.thread.new Thread with () -> {try(Transaction tx=db.beginTx())actionInsideTransaction.run(); in method private executeTransactionInSeparateThread(actionInsideTransaction Runnable) : void from class org.neo4j.kernel.impl.store.RelationshipChainPointerChasingTest


    private void testAllUniqueRelationshipPathsAreReturned( TraversalDescription description )
            throws Exception
    {
        Set<String> expected = new HashSet<>( Arrays.asList( NODE_UNIQUE_PATHS ) );
        expected.addAll( Arrays.asList( RELATIONSHIP_UNIQUE_EXTRA_PATHS ) );

        Traverser traverser = description.uniqueness(
                Uniqueness.RELATIONSHIP_PATH ).traverse( node( "1" ) );

        expectPaths( traverser, expected );
    }

    private void testAllUniqueRelationshipPathsAreReturned( TraversalDescription description )
            throws Exception
    {
        Set<String> expected = new HashSet<String>(
                Arrays.asList( NODE_UNIQUE_PATHS ) );
        expected.addAll( Arrays.asList( RELATIONSHIP_UNIQUE_EXTRA_PATHS ) );

        Traverser traverser = description.uniqueness(
                Uniqueness.RELATIONSHIP_PATH ).traverse( node( "1" ) );

        expectPaths( traverser, expected );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method private testAllUniqueRelationshipPathsAreReturned(description TraversalDescription) : void from class org.neo4j.kernel.impl.traversal.DepthPitfallGraphTest


    @Test
    public void testMaxDepthAndCustomPruneEvaluatorCombined()
    {
        Evaluator lessThanThreeRels =
                path -> count( path.endNode().getRelationships( Direction.OUTGOING ).iterator() ) < 3 ?
                        Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE;

        TraversalDescription description = getGraphDb().traversalDescription().evaluator( Evaluators.all() )
                .evaluator( toDepth( 1 ) ).evaluator( lessThanThreeRels );
        Set<String> expectedNodes = new HashSet<>( asList( "a", "b", "c", "d", "e" ) );
        try ( Transaction tx = beginTx() )
        {
            for ( Path position : description.traverse( node( "a" ) ) )
            {
                String name = (String) position.endNode().getProperty( "name" );
                assertTrue( name + " shouldn't have been returned", expectedNodes.remove( name ) );
            }
            tx.success();
        }
        assertTrue( expectedNodes.isEmpty() );
    }

    @Test
    public void testMaxDepthAndCustomPruneEvaluatorCombined()
    {
        Evaluator lessThanThreeRels =
                path -> count( path.endNode().getRelationships( Direction.OUTGOING ).iterator() ) < 3 ?
                        Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE;

        TraversalDescription description = getGraphDb().traversalDescription().evaluator( Evaluators.all() )
                .evaluator( toDepth( 1 ) ).evaluator( lessThanThreeRels );
        Set<String> expectedNodes = new HashSet<String>(
                asList( "a", "b", "c", "d", "e" ) );
        try ( Transaction tx = beginTx() )
        {
            for ( Path position : description.traverse( node( "a" ) ) )
            {
                String name = (String) position.endNode().getProperty( "name" );
                assertTrue( name + " shouldn't have been returned", expectedNodes.remove( name ) );
            }
            tx.success();
        }
        assertTrue( expectedNodes.isEmpty() );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public testMaxDepthAndCustomPruneEvaluatorCombined() : void from class org.neo4j.kernel.impl.traversal.TestMultiPruneEvaluators


    protected <T> void expect( Iterable<? extends T> items,
            Representation<T> representation, String... expected )
    {
        expect( items, representation, new HashSet<>( Arrays.asList( expected ) ) );
    }

    protected <T> void expect( Iterable<? extends T> items,
            Representation<T> representation, String... expected )
    {
        expect( items, representation, new HashSet<String>(
                Arrays.asList( expected ) ) );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method protected expect(items Iterable<? extends T>, representation Representation<T>, expected String...) : void from class org.neo4j.kernel.impl.traversal.TraversalTestBase


    protected <T> void expect( Iterable<? extends T> items,
            Representation<T> representation, Set<String> expected )
    {
        Collection<String> encounteredItems = new ArrayList<>();
        try ( Transaction tx = beginTx() )
        {
            for ( T item : items )
            {
                String repr = representation.represent( item );
                assertTrue( repr + " not expected ", expected.remove( repr ) );
                encounteredItems.add( repr );
            }
            tx.success();
        }

        if ( !expected.isEmpty() )
        {
            fail( "The exepected elements " + expected + " were not returned. Returned were: " + encounteredItems );
        }
    }

    protected <T> void expect( Iterable<? extends T> items,
            Representation<T> representation, Set<String> expected )
    {
        Collection<String> encounteredItems = new ArrayList<String>();
        try ( Transaction tx = beginTx() )
        {
            for ( T item : items )
            {
                String repr = representation.represent( item );
                assertTrue( repr + " not expected ", expected.remove( repr ) );
                encounteredItems.add( repr );
            }
            tx.success();
        }

        if ( !expected.isEmpty() )
        {
            fail( "The exepected elements " + expected + " were not returned. Returned were: " + encounteredItems );
        }
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method protected expect(items Iterable<? extends T>, representation Representation<T>, expected Set<String>) : void from class org.neo4j.kernel.impl.traversal.TraversalTestBase


    protected void expectPaths( Traverser traverser, String... paths )
    {
        expectPaths( traverser, new HashSet<>( Arrays.asList( paths ) ) );
    }

    protected void expectPaths( Traverser traverser, String... paths )
    {
        expectPaths( traverser, new HashSet<String>( Arrays.asList( paths ) ) );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method protected expectPaths(traverser Traverser, paths String...) : void from class org.neo4j.kernel.impl.traversal.TraversalTestBase


    public static <E> void assertContains( Iterable<E> actual, E... expected )
    {
        Set<E> expectation = new HashSet<>( Arrays.asList( expected ) );
        for ( E element : actual )
        {
            if ( !expectation.remove( element ) )
            {
                fail( "unexpected element <" + element + ">" );
            }
        }
        if ( !expectation.isEmpty() )
        {
            fail( "the expected elements <" + expectation
                  + "> were not contained" );
        }
    }

    public static <E> void assertContains( Iterable<E> actual, E... expected )
    {
        Set<E> expectation = new HashSet<E>( Arrays.asList( expected ) );
        for ( E element : actual )
        {
            if ( !expectation.remove( element ) )
            {
                fail( "unexpected element <" + element + ">" );
            }
        }
        if ( !expectation.isEmpty() )
        {
            fail( "the expected elements <" + expectation
                  + "> were not contained" );
        }
    }

Replace Generic With Diamond HashSet<E> with HashSet<> in method public assertContains(actual Iterable<E>, expected E...) : void from class org.neo4j.kernel.impl.traversal.TraversalTestBase


    @Test
    public void testArrayMap()
    {
        ArrayMap<String,Integer> map = new ArrayMap<>();

        assertTrue( map.get( "key1" ) == null );
        map.put( "key1", 0 );
        assertEquals( new Integer( 0 ), map.get( "key1" ) );
        assertEquals( new Integer( 0 ), map.get( "key1" ) );
        map.put( "key1", 1 );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        map.put( "key2", 0 );
        assertEquals( new Integer( 0 ), map.get( "key2" ) );
        map.put( "key2", 2 );
        assertEquals( new Integer( 2 ), map.get( "key2" ) );
        assertEquals( new Integer( 2 ), map.remove( "key2" ) );
        assertTrue( map.get( "key2" ) == null );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        assertEquals( new Integer( 1 ), map.remove( "key1" ) );
        assertTrue( map.get( "key1" ) == null );

        map.put( "key1", 1 );
        map.put( "key2", 2 );
        map.put( "key3", 3 );
        map.put( "key4", 4 );
        map.put( "key5", 5 );
        assertEquals( new Integer( 5 ), map.get( "key5" ) );
        assertEquals( new Integer( 4 ), map.get( "key4" ) );
        assertEquals( new Integer( 3 ), map.get( "key3" ) );
        assertEquals( new Integer( 2 ), map.get( "key2" ) );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        assertEquals( new Integer( 5 ), map.remove( "key5" ) );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        assertEquals( new Integer( 4 ), map.get( "key4" ) );
        assertEquals( new Integer( 3 ), map.get( "key3" ) );
        assertEquals( new Integer( 2 ), map.get( "key2" ) );
        assertEquals( new Integer( 3 ), map.remove( "key3" ) );
        assertEquals( new Integer( 1 ), map.remove( "key1" ) );
        assertEquals( new Integer( 2 ), map.remove( "key2" ) );

        for ( int i = 0; i < 100; i++ )
        {
            map.put( "key" + i, i );
        }
        for ( int i = 0; i < 100; i++ )
        {
            assertEquals( new Integer( i ), map.get( "key" + i ) );
        }
        for ( int i = 0; i < 100; i++ )
        {
            assertEquals( new Integer( i ), map.remove( "key" + i ) );
        }
        for ( int i = 0; i < 100; i++ )
        {
            assertTrue( map.get( "key" + i ) == null );
        }
    }

    @Test
    public void testArrayMap()
    {
        ArrayMap<String,Integer> map = new ArrayMap<String,Integer>();

        assertTrue( map.get( "key1" ) == null );
        map.put( "key1", 0 );
        assertEquals( new Integer( 0 ), map.get( "key1" ) );
        assertEquals( new Integer( 0 ), map.get( "key1" ) );
        map.put( "key1", 1 );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        map.put( "key2", 0 );
        assertEquals( new Integer( 0 ), map.get( "key2" ) );
        map.put( "key2", 2 );
        assertEquals( new Integer( 2 ), map.get( "key2" ) );
        assertEquals( new Integer( 2 ), map.remove( "key2" ) );
        assertTrue( map.get( "key2" ) == null );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        assertEquals( new Integer( 1 ), map.remove( "key1" ) );
        assertTrue( map.get( "key1" ) == null );

        map.put( "key1", 1 );
        map.put( "key2", 2 );
        map.put( "key3", 3 );
        map.put( "key4", 4 );
        map.put( "key5", 5 );
        assertEquals( new Integer( 5 ), map.get( "key5" ) );
        assertEquals( new Integer( 4 ), map.get( "key4" ) );
        assertEquals( new Integer( 3 ), map.get( "key3" ) );
        assertEquals( new Integer( 2 ), map.get( "key2" ) );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        assertEquals( new Integer( 5 ), map.remove( "key5" ) );
        assertEquals( new Integer( 1 ), map.get( "key1" ) );
        assertEquals( new Integer( 4 ), map.get( "key4" ) );
        assertEquals( new Integer( 3 ), map.get( "key3" ) );
        assertEquals( new Integer( 2 ), map.get( "key2" ) );
        assertEquals( new Integer( 3 ), map.remove( "key3" ) );
        assertEquals( new Integer( 1 ), map.remove( "key1" ) );
        assertEquals( new Integer( 2 ), map.remove( "key2" ) );

        for ( int i = 0; i < 100; i++ )
        {
            map.put( "key" + i, i );
        }
        for ( int i = 0; i < 100; i++ )
        {
            assertEquals( new Integer( i ), map.get( "key" + i ) );
        }
        for ( int i = 0; i < 100; i++ )
        {
            assertEquals( new Integer( i ), map.remove( "key" + i ) );
        }
        for ( int i = 0; i < 100; i++ )
        {
            assertTrue( map.get( "key" + i ) == null );
        }
    }

Replace Generic With Diamond ArrayMap<String,Integer> with ArrayMap<> in method public testArrayMap() : void from class org.neo4j.kernel.impl.util.TestArrayMap


    @Test
    public void arraymapIsClearedWhenExpandingToHashMapIfNonShrinkable() throws Exception
    {
        assertDataRepresentationSwitchesWhenAboveThreshold( new ArrayMap<>( (byte) 3, false, false ), false );
    }

    @Test
    public void arraymapIsClearedWhenExpandingToHashMapIfNonShrinkable() throws Exception
    {
        assertDataRepresentationSwitchesWhenAboveThreshold( new ArrayMap<String, Integer>( (byte)3, false,
                false ), false );
    }

Replace Generic With Diamond ArrayMap<String,Integer> with ArrayMap<> in method public arraymapIsClearedWhenExpandingToHashMapIfNonShrinkable() : void from class org.neo4j.kernel.impl.util.TestArrayMap


    @Test
    public void arraymapIsClearedWhenExpandingToHashMapIfShrinkable() throws Exception
    {
        assertDataRepresentationSwitchesWhenAboveThreshold( new ArrayMap<>( (byte) 3, false, true ), true );
    }

    @Test
    public void arraymapIsClearedWhenExpandingToHashMapIfShrinkable() throws Exception
    {
        assertDataRepresentationSwitchesWhenAboveThreshold( new ArrayMap<String, Integer>( (byte)3, false,
                true ), true );
    }

Replace Generic With Diamond ArrayMap<String,Integer> with ArrayMap<> in method public arraymapIsClearedWhenExpandingToHashMapIfShrinkable() : void from class org.neo4j.kernel.impl.util.TestArrayMap


    @Test
    public void arraymapIsClearedWhenExpandingToHashMapIfNonShrinkableAndSynchronized()
            throws Exception
    {
        assertDataRepresentationSwitchesWhenAboveThreshold( new ArrayMap<>( (byte) 3, true, false ), false );
    }

    @Test
    public void arraymapIsClearedWhenExpandingToHashMapIfNonShrinkableAndSynchronized()
            throws Exception
    {
        assertDataRepresentationSwitchesWhenAboveThreshold( new ArrayMap<String, Integer>( (byte)3, true,
                false ), false );
    }

Replace Generic With Diamond ArrayMap<String,Integer> with ArrayMap<> in method public arraymapIsClearedWhenExpandingToHashMapIfNonShrinkableAndSynchronized() : void from class org.neo4j.kernel.impl.util.TestArrayMap


    @Test
    public void canOverwriteThenRemoveElementAcrossDeflation() throws Exception
    {
        ArrayMap<String, Integer> map = new ArrayMap<>( (byte) 3, false, true );

        map.put( "key1", 1 );
        map.put( "key2", 2 );
        map.put( "key3", 3 );
        map.put( "key4", 4 );
        map.put( "key5", 5 );

        map.put( "key1", 6 );

        map.remove( "key1" );
        assertNull( "removed element still found", map.get( "key1" ) );
        map.remove( "key2" );
        assertNull( "removed element still found", map.get( "key1" ) );
        map.remove( "key3" );

        assertNull( "removed element still found", map.get( "key1" ) );
        map.remove( "key4" );
        assertNull( "removed element still found", map.get( "key1" ) );
    }

    @Test
    public void canOverwriteThenRemoveElementAcrossDeflation() throws Exception
    {
        ArrayMap<String, Integer> map = new ArrayMap<String, Integer>( (byte)3, false, true );

        map.put( "key1", 1 );
        map.put( "key2", 2 );
        map.put( "key3", 3 );
        map.put( "key4", 4 );
        map.put( "key5", 5 );

        map.put( "key1", 6 );

        map.remove( "key1" );
        assertNull( "removed element still found", map.get( "key1" ) );
        map.remove( "key2" );
        assertNull( "removed element still found", map.get( "key1" ) );
        map.remove( "key3" );

        assertNull( "removed element still found", map.get( "key1" ) );
        map.remove( "key4" );
        assertNull( "removed element still found", map.get( "key1" ) );
    }

Replace Generic With Diamond ArrayMap<String,Integer> with ArrayMap<> in method public canOverwriteThenRemoveElementAcrossDeflation() : void from class org.neo4j.kernel.impl.util.TestArrayMap


    @Test
    public void keySetUnaffectedByChanges() throws Exception
    {
        Map<Integer, String> map = new CopyOnWriteHashMap<>();
        map.put( 0, "0" );
        map.put( 1, "1" );
        map.put( 2, "2" );

        assertContains( map.keySet(), 0, 1, 2 );

        Iterator<Integer> keys = map.keySet().iterator();
        map.remove( 1 );
        assertContains( keys, 0, 1, 2 );
    }

    @Test
    public void keySetUnaffectedByChanges() throws Exception
    {
        Map<Integer, String> map = new CopyOnWriteHashMap<Integer, String>();
        map.put( 0, "0" );
        map.put( 1, "1" );
        map.put( 2, "2" );

        assertContains( map.keySet(), 0, 1, 2 );

        Iterator<Integer> keys = map.keySet().iterator();
        map.remove( 1 );
        assertContains( keys, 0, 1, 2 );
    }

Replace Generic With Diamond CopyOnWriteHashMap<Integer,String> with CopyOnWriteHashMap<> in method public keySetUnaffectedByChanges() : void from class org.neo4j.kernel.impl.util.TestCopyOnWriteHashMap


    @Test
    public void entrySetUnaffectedByChanges() throws Exception
    {
        Map<Integer, String> map = new CopyOnWriteHashMap<>();
        map.put( 0, "0" );
        map.put( 1, "1" );
        map.put( 2, "2" );
        @SuppressWarnings( "unchecked" )
        Map.Entry<Integer, String>[] allEntries = map.entrySet().toArray( new Map.Entry[0] );

        assertContains( map.entrySet(), allEntries );

        Iterator<Entry<Integer, String>> entries = map.entrySet().iterator();
        map.remove( 1 );
        assertContains( entries, allEntries );
    }

    @Test
    public void entrySetUnaffectedByChanges() throws Exception
    {
        Map<Integer, String> map = new CopyOnWriteHashMap<Integer, String>();
        map.put( 0, "0" );
        map.put( 1, "1" );
        map.put( 2, "2" );
        @SuppressWarnings( "unchecked" )
        Map.Entry<Integer, String>[] allEntries = map.entrySet().toArray( new Map.Entry[0] );

        assertContains( map.entrySet(), allEntries );

        Iterator<Entry<Integer, String>> entries = map.entrySet().iterator();
        map.remove( 1 );
        assertContains( entries, allEntries );
    }

Replace Generic With Diamond CopyOnWriteHashMap<Integer,String> with CopyOnWriteHashMap<> in method public entrySetUnaffectedByChanges() : void from class org.neo4j.kernel.impl.util.TestCopyOnWriteHashMap


            @Override
            public void evaluate() throws Throwable
            {
                product.set( create( graph, title == null ? null : title.value(), doc == null ? null : doc.value(),
                        description.getMethodName() ) );
                try
                {
                    try
                    {
                        base.evaluate();
                    }
                    catch ( Throwable err )
                    {
                        try
                        {
                            destroy( get( false ), false );
                        }
                        catch ( Throwable sub )
                        {
                            List<Throwable> failures = new ArrayList<>();
                            if ( err instanceof MultipleFailureException )
                            {
                                failures.addAll( ( (MultipleFailureException) err ).getFailures() );
                            }
                            else
                            {
                                failures.add( err );
                            }
                            failures.add( sub );
                            throw new MultipleFailureException( failures );
                        }
                        throw err;
                    }
                    destroy( get( false ), false );
                }
                finally
                {
                    product.set( null );
                }
            }

            @Override
            public void evaluate() throws Throwable
            {
                product.set( create( graph, title == null ? null : title.value(), doc == null ? null : doc.value(),
                        description.getMethodName() ) );
                try
                {
                    try
                    {
                        base.evaluate();
                    }
                    catch ( Throwable err )
                    {
                        try
                        {
                            destroy( get( false ), false );
                        }
                        catch ( Throwable sub )
                        {
                            List<Throwable> failures = new ArrayList<Throwable>();
                            if ( err instanceof MultipleFailureException )
                            {
                                failures.addAll( ( (MultipleFailureException) err ).getFailures() );
                            }
                            else
                            {
                                failures.add( err );
                            }
                            failures.add( sub );
                            throw new MultipleFailureException( failures );
                        }
                        throw err;
                    }
                    destroy( get( false ), false );
                }
                finally
                {
                    product.set( null );
                }
            }

Replace Generic With Diamond ArrayList<Throwable> with ArrayList<> in method public evaluate() : void from class org.neo4j.test.TestData.apply.new Statement


    @Override
    public Statement apply( final Statement base, final Description description )
    {
        final Title title = description.getAnnotation( Title.class );
        final Documented doc = description.getAnnotation( Documented.class );
        GraphDescription.Graph g = description.getAnnotation( GraphDescription.Graph.class );
        if ( g == null )
        {
            g = description.getTestClass().getAnnotation( GraphDescription.Graph.class );
        }
        final GraphDescription graph = GraphDescription.create( g );
        return new Statement()
        {
            @Override
            public void evaluate() throws Throwable
            {
                product.set( create( graph, title == null ? null : title.value(), doc == null ? null : doc.value(),
                        description.getMethodName() ) );
                try
                {
                    try
                    {
                        base.evaluate();
                    }
                    catch ( Throwable err )
                    {
                        try
                        {
                            destroy( get( false ), false );
                        }
                        catch ( Throwable sub )
                        {
                            List<Throwable> failures = new ArrayList<>();
                            if ( err instanceof MultipleFailureException )
                            {
                                failures.addAll( ( (MultipleFailureException) err ).getFailures() );
                            }
                            else
                            {
                                failures.add( err );
                            }
                            failures.add( sub );
                            throw new MultipleFailureException( failures );
                        }
                        throw err;
                    }
                    destroy( get( false ), false );
                }
                finally
                {
                    product.set( null );
                }
            }
        };
    }

    @Override
    public Statement apply( final Statement base, final Description description )
    {
        final Title title = description.getAnnotation( Title.class );
        final Documented doc = description.getAnnotation( Documented.class );
        GraphDescription.Graph g = description.getAnnotation( GraphDescription.Graph.class );
        if ( g == null )
        {
            g = description.getTestClass().getAnnotation( GraphDescription.Graph.class );
        }
        final GraphDescription graph = GraphDescription.create( g );
        return new Statement()
        {
            @Override
            public void evaluate() throws Throwable
            {
                product.set( create( graph, title == null ? null : title.value(), doc == null ? null : doc.value(),
                        description.getMethodName() ) );
                try
                {
                    try
                    {
                        base.evaluate();
                    }
                    catch ( Throwable err )
                    {
                        try
                        {
                            destroy( get( false ), false );
                        }
                        catch ( Throwable sub )
                        {
                            List<Throwable> failures = new ArrayList<Throwable>();
                            if ( err instanceof MultipleFailureException )
                            {
                                failures.addAll( ( (MultipleFailureException) err ).getFailures() );
                            }
                            else
                            {
                                failures.add( err );
                            }
                            failures.add( sub );
                            throw new MultipleFailureException( failures );
                        }
                        throw err;
                    }
                    destroy( get( false ), false );
                }
                finally
                {
                    product.set( null );
                }
            }
        };
    }

Replace Generic With Diamond ArrayList<Throwable> with ArrayList<> in method public apply(base Statement, description Description) : Statement from class org.neo4j.test.TestData