    private Iterable<Node> nodeIterator( final Node start, final Iterable<Relationship> relationships )
    {
        return () -> new Iterator<>()
        {
            Node current = start;
            int index;
            Iterator<Relationship> relationshipIterator = relationships.iterator();

            @Override
            public boolean hasNext()
            {
                return index <= path.length;
            }

            @Override
            public Node next()
            {
                if ( current == null )
                {
                    throw new NoSuchElementException();
                }
                Node next = null;
                if ( index < path.length )
                {
                    if ( !relationshipIterator.hasNext() )
                    {
                        throw new IllegalStateException( String.format( "Number of relationships: %d does not" + " match with path length: %d.", index, path.length ) );
                    }
                    next = relationshipIterator.next().getOtherNode( current );
                }
                index += 1;
                try
                {
                    return current;
                }
                finally
                {
                    current = next;
                }
            }

            @Override
            public void remove()
            {
                throw new UnsupportedOperationException();
            }
        };
    }

    private Iterable<Node> nodeIterator( final Node start, final Iterable<Relationship> relationships )
    {
        return () -> new Iterator<Node>()
        {
            Node current = start;
            int index;
            Iterator<Relationship> relationshipIterator = relationships.iterator();

            @Override
            public boolean hasNext()
            {
                return index <= path.length;
            }

            @Override
            public Node next()
            {
                if ( current == null )
                {
                    throw new NoSuchElementException();
                }
                Node next = null;
                if ( index < path.length )
                {
                    if ( !relationshipIterator.hasNext() )
                    {
                        throw new IllegalStateException( String.format( "Number of relationships: %d does not" +
                                              " match with path length: %d.", index, path.length ) );
                    }
                    next = relationshipIterator.next().getOtherNode( current );
                }
                index += 1;
                try
                {
                    return current;
                }
                finally
                {
                    current = next;
                }
            }

            @Override
            public void remove()
            {
                throw new UnsupportedOperationException();
            }
        };
    }

Replace Generic With Diamond Iterator<Node> with Iterator<> in method private nodeIterator(start Node, relationships Iterable<Relationship>) : Iterable<Node> from class org.neo4j.graphalgo.impl.util.PathImpl


    @Override
    public Iterator<PropertyContainer> iterator()
    {
        return new Iterator<>()
        {
            Iterator<? extends PropertyContainer> current = nodes().iterator();
            Iterator<? extends PropertyContainer> next = relationships().iterator();

            @Override
            public boolean hasNext()
            {
                return current.hasNext();
            }

            @Override
            public PropertyContainer next()
            {
                try
                {
                    return current.next();
                }
                finally
                {
                    Iterator<? extends PropertyContainer> temp = current;
                    current = next;
                    next = temp;
                }
            }

            @Override
            public void remove()
            {
                next.remove();
            }
        };
    }

    @Override
    public Iterator<PropertyContainer> iterator()
    {
        return new Iterator<PropertyContainer>()
        {
            Iterator<? extends PropertyContainer> current = nodes().iterator();
            Iterator<? extends PropertyContainer> next = relationships().iterator();

            @Override
            public boolean hasNext()
            {
                return current.hasNext();
            }

            @Override
            public PropertyContainer next()
            {
                try
                {
                    return current.next();
                }
                finally
                {
                    Iterator<? extends PropertyContainer> temp = current;
                    current = next;
                    next = temp;
                }
            }

            @Override
            public void remove()
            {
                next.remove();
            }
        };
    }

Replace Generic With Diamond Iterator<PropertyContainer> with Iterator<> in method public iterator() : Iterator<PropertyContainer> from class org.neo4j.graphalgo.impl.util.PathImpl


    @Override
    ResourceIterator<Relationship> doExpand( final Path path, BranchState state )
    {
        final Node node = path.endNode();
        return new NestingResourceIterator<>( orderedTypes.iterator() )
        {
            @Override
            protected ResourceIterator<Relationship> createNestedIterator( Pair<RelationshipType,Direction> entry )
            {
                RelationshipType type = entry.first();
                Direction dir = entry.other();
                Iterable<Relationship> relationshipsIterable = (dir == Direction.BOTH) ? node.getRelationships( type ) : node.getRelationships( type, dir );
                return Iterables.asResourceIterable( relationshipsIterable ).iterator();
            }
        };
    }

    @Override
    ResourceIterator<Relationship> doExpand( final Path path, BranchState state )
    {
        final Node node = path.endNode();
        return new NestingResourceIterator<Relationship, Pair<RelationshipType, Direction>>(
                orderedTypes.iterator() )
        {
            @Override
            protected ResourceIterator<Relationship> createNestedIterator(
                    Pair<RelationshipType, Direction> entry )
            {
                RelationshipType type = entry.first();
                Direction dir = entry.other();
                Iterable<Relationship> relationshipsIterable =
                        (dir == Direction.BOTH) ? node.getRelationships( type ) : node.getRelationships( type, dir );
                return Iterables.asResourceIterable( relationshipsIterable ).iterator();
            }
        };
    }

Replace Generic With Diamond NestingResourceIterator<Relationship,Pair<RelationshipType,Direction>> with NestingResourceIterator<> in method package doExpand(path Path, state BranchState) : ResourceIterator<Relationship> from class org.neo4j.graphdb.impl.OrderedByTypeExpander


        @Override
        public ResourceIterator<Node> iterator()
        {
            final Node node = path.endNode();

            return new MappingResourceIterator<>( expander.doExpand( path, state ) )
            {
                @Override
                protected Node map( Relationship rel )
                {
                    return rel.getOtherNode( node );
                }
            };
        }

        @Override
        public ResourceIterator<Node> iterator()
        {
            final Node node = path.endNode();

            return new MappingResourceIterator<Node, Relationship>( expander.doExpand( path, state ) )
            {
                @Override
                protected Node map( Relationship rel )
                {
                    return rel.getOtherNode( node );
                }
            };
        }

Replace Generic With Diamond MappingResourceIterator<Node,Relationship> with MappingResourceIterator<> in method public iterator() : ResourceIterator<Node> from class org.neo4j.graphdb.impl.StandardExpander.NodeExpansion


        @Override
        ResourceIterator<Relationship> doExpand( Path path, BranchState state )
        {
            final Node node = path.endNode();
            if ( directions.length == 1 )
            {
                DirectionAndTypes direction = directions[0];
                return asResourceIterator( node.getRelationships( direction.direction, direction.types ).iterator() );
            }
            else
            {
                return new NestingResourceIterator<>( new ArrayIterator<>( directions ) )
                {
                    @Override
                    protected ResourceIterator<Relationship> createNestedIterator( DirectionAndTypes item )
                    {
                        return asResourceIterator( node.getRelationships( item.direction, item.types ).iterator() );
                    }
                };
            }
        }

        @Override
        ResourceIterator<Relationship> doExpand( Path path, BranchState state )
        {
            final Node node = path.endNode();
            if ( directions.length == 1 )
            {
                DirectionAndTypes direction = directions[0];
                return asResourceIterator( node.getRelationships( direction.direction, direction.types ).iterator() );
            }
            else
            {
                return new NestingResourceIterator<Relationship, DirectionAndTypes>( new ArrayIterator<>( directions ) )
                {
                    @Override
                    protected ResourceIterator<Relationship> createNestedIterator( DirectionAndTypes item )
                    {
                        return asResourceIterator( node.getRelationships( item.direction, item.types ).iterator() );
                    }
                };
            }
        }

Replace Generic With Diamond NestingResourceIterator<Relationship,DirectionAndTypes> with NestingResourceIterator<> in method package doExpand(path Path, state BranchState) : ResourceIterator<Relationship> from class org.neo4j.graphdb.impl.StandardExpander.RegularExpander


        @Override
        public ResourceIterator<T> iterator()
        {
            final ResourceIterator<Path> iterator = pathIterator();
            return new PrefetchingResourceIterator<>()
            {
                @Override
                public void close()
                {
                    iterator.close();
                }

                @Override
                protected T fetchNextOrNull()
                {
                    return iterator.hasNext() ? convert( iterator.next() ) : null;
                }
            };
        }

        @Override
        public ResourceIterator<T> iterator()
        {
            final ResourceIterator<Path> iterator = pathIterator();
            return new PrefetchingResourceIterator<T>()
            {
                @Override
                public void close()
                {
                    iterator.close();
                }

                @Override
                protected T fetchNextOrNull()
                {
                    return iterator.hasNext() ? convert( iterator.next() ) : null;
                }
            };
        }

Replace Generic With Diamond PrefetchingResourceIterator<T> with PrefetchingResourceIterator<> in method public iterator() : ResourceIterator<T> from class org.neo4j.kernel.impl.traversal.DefaultTraverser.ResourcePathIterableWrapper


    @Override
    public ResourceIterable<Node> nodes()
    {
        return new ResourcePathIterableWrapper<>( this )
        {
            @Override
            protected Node convert( Path path )
            {
                return path.endNode();
            }
        };
    }

    @Override
    public ResourceIterable<Node> nodes()
    {
        return new ResourcePathIterableWrapper<Node>( this )
        {
            @Override
            protected Node convert( Path path )
            {
                return path.endNode();
            }
        };
    }

Replace Generic With Diamond ResourcePathIterableWrapper<Node> with ResourcePathIterableWrapper<> in method public nodes() : ResourceIterable<Node> from class org.neo4j.kernel.impl.traversal.DefaultTraverser


            @Override
            public ResourceIterator<Relationship> iterator()
            {
                final ResourceIterator<Path> pathIterator = pathIterator();
                return new PrefetchingResourceIterator<>()
                {
                    @Override
                    public void close()
                    {
                        pathIterator.close();
                    }

                    @Override
                    protected Relationship fetchNextOrNull()
                    {
                        while ( pathIterator.hasNext() )
                        {
                            Path path = pathIterator.next();
                            if ( path.length() > 0 )
                            {
                                return path.lastRelationship();
                            }
                        }
                        return null;
                    }
                };
            }

            @Override
            public ResourceIterator<Relationship> iterator()
            {
                final ResourceIterator<Path> pathIterator = pathIterator();
                return new PrefetchingResourceIterator<Relationship>()
                {
                    @Override
                    public void close()
                    {
                        pathIterator.close();
                    }

                    @Override
                    protected Relationship fetchNextOrNull()
                    {
                        while ( pathIterator.hasNext() )
                        {
                            Path path = pathIterator.next();
                            if ( path.length() > 0 )
                            {
                                return path.lastRelationship();
                            }
                        }
                        return null;
                    }
                };
            }

Replace Generic With Diamond PrefetchingResourceIterator<Relationship> with PrefetchingResourceIterator<> in method public iterator() : ResourceIterator<Relationship> from class org.neo4j.kernel.impl.traversal.DefaultTraverser.relationships.new ResourcePathIterableWrapper<>


    @Override
    public ResourceIterable<Relationship> relationships()
    {
        return new ResourcePathIterableWrapper<>( this )
        {
            @Override
            public ResourceIterator<Relationship> iterator()
            {
                final ResourceIterator<Path> pathIterator = pathIterator();
                return new PrefetchingResourceIterator<>()
                {
                    @Override
                    public void close()
                    {
                        pathIterator.close();
                    }

                    @Override
                    protected Relationship fetchNextOrNull()
                    {
                        while ( pathIterator.hasNext() )
                        {
                            Path path = pathIterator.next();
                            if ( path.length() > 0 )
                            {
                                return path.lastRelationship();
                            }
                        }
                        return null;
                    }
                };
            }

            @Override
            protected Relationship convert( Path path )
            {
                return path.lastRelationship();
            }
        };
    }

    @Override
    public ResourceIterable<Relationship> relationships()
    {
        return new ResourcePathIterableWrapper<Relationship>( this )
        {
            @Override
            public ResourceIterator<Relationship> iterator()
            {
                final ResourceIterator<Path> pathIterator = pathIterator();
                return new PrefetchingResourceIterator<Relationship>()
                {
                    @Override
                    public void close()
                    {
                        pathIterator.close();
                    }

                    @Override
                    protected Relationship fetchNextOrNull()
                    {
                        while ( pathIterator.hasNext() )
                        {
                            Path path = pathIterator.next();
                            if ( path.length() > 0 )
                            {
                                return path.lastRelationship();
                            }
                        }
                        return null;
                    }
                };
            }

            @Override
            protected Relationship convert( Path path )
            {
                return path.lastRelationship();
            }
        };
    }

Replace Generic With Diamond PrefetchingResourceIterator<Relationship> with PrefetchingResourceIterator<> in method public relationships() : ResourceIterable<Relationship> from class org.neo4j.kernel.impl.traversal.DefaultTraverser


    default <R> ResourceIterator<R> map( Function<T,R> map )
    {
        return new ResourceIterator<>()
        {
            @Override
            public void close()
            {
                ResourceIterator.this.close();
            }

            @Override
            public boolean hasNext()
            {
                return ResourceIterator.this.hasNext();
            }

            @Override
            public R next()
            {
                return map.apply( ResourceIterator.this.next() );
            }
        };
    }

    default <R> ResourceIterator<R> map( Function<T,R> map )
    {
        return new ResourceIterator<R>()
        {
            @Override
            public void close()
            {
                ResourceIterator.this.close();
            }

            @Override
            public boolean hasNext()
            {
                return ResourceIterator.this.hasNext();
            }

            @Override
            public R next()
            {
                return map.apply( ResourceIterator.this.next() );
            }
        };
    }

Replace Generic With Diamond ResourceIterator<R> with ResourceIterator<> in method public map(map Function<T,R>) : ResourceIterator<R> from class org.neo4j.graphdb.ResourceIterator


    private static <T> ResourceIterator<T> inUse( KernelTransaction transaction, TokenAccess<T> access )
    {
        SchemaReadCore schemaReadCore = transaction.schemaRead().snapshot();
        return new TokenIterator<>( transaction, access )
        {
            @Override
            protected T fetchNextOrNull()
            {
                while ( tokens.hasNext() )
                {
                    NamedToken token = tokens.next();
                    if ( this.access.inUse( transaction, schemaReadCore, token.id() ) )
                    {
                        return this.access.token( token );
                    }
                }
                close();
                return null;
            }
        };
    }

        static <T> ResourceIterator<T> inUse( KernelTransaction transaction, TokenAccess<T> access )
        {
            SchemaReadCore schemaReadCore = transaction.schemaRead().snapshot();
            return new TokenIterator<T>( transaction, access )
            {
                @Override
                protected T fetchNextOrNull()
                {
                    while ( tokens.hasNext() )
                    {
                        NamedToken token = tokens.next();
                        if ( this.access.inUse( transaction, schemaReadCore, token.id() ) )
                        {
                            return this.access.token( token );
                        }
                    }
                    close();
                    return null;
                }
            };
        }

Replace Generic With Diamond TokenIterator<T> with TokenIterator<> in method private inUse(transaction KernelTransaction, access TokenAccess<T>) : ResourceIterator<T> from class org.neo4j.kernel.impl.api.TokenAccess


    private static <T> ResourceIterator<T> all( KernelTransaction transaction, TokenAccess<T> access )
    {
        return new TokenIterator<>( transaction, access )
        {
            @Override
            protected T fetchNextOrNull()
            {
                if ( tokens.hasNext() )
                {
                    return access.token( tokens.next() );
                }
                else
                {
                    close();
                    return null;
                }
            }
        };
    }

        static <T> ResourceIterator<T> all( KernelTransaction transaction, TokenAccess<T> access )
        {
            return new TokenIterator<T>( transaction, access )
            {
                @Override
                protected T fetchNextOrNull()
                {
                    if ( tokens.hasNext() )
                    {
                        return access.token( tokens.next() );
                    }
                    else
                    {
                        close();
                        return null;
                    }
                }
            };
        }

Replace Generic With Diamond TokenIterator<T> with TokenIterator<> in method private all(transaction KernelTransaction, access TokenAccess<T>) : ResourceIterator<T> from class org.neo4j.kernel.impl.api.TokenAccess


    public static Matcher<List<ResponseMessage>> equalsMessages( final Matcher<ResponseMessage>... messageMatchers )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( List<ResponseMessage> messages )
            {
                if ( messageMatchers.length != messages.size() )
                {
                    return false;
                }
                for ( int i = 0; i < messageMatchers.length; i++ )
                {
                    if ( !messageMatchers[i].matches( messages.get( i ) ) )
                    {
                        return false;
                    }
                }
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendList( "MessageList[", ", ", "]", Arrays.asList( messageMatchers ) );
            }
        };
    }

    public static Matcher<List<ResponseMessage>> equalsMessages( final Matcher<ResponseMessage>... messageMatchers )
    {
        return new TypeSafeMatcher<List<ResponseMessage>>()
        {
            @Override
            protected boolean matchesSafely( List<ResponseMessage> messages )
            {
                if ( messageMatchers.length != messages.size() )
                {
                    return false;
                }
                for ( int i = 0; i < messageMatchers.length; i++ )
                {
                    if ( !messageMatchers[i].matches( messages.get( i ) ) )
                    {
                        return false;
                    }
                }
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendList( "MessageList[", ", ", "]", Arrays.asList( messageMatchers
                ) );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<List<ResponseMessage>> with TypeSafeMatcher<> in method public equalsMessages(messageMatchers Matcher<ResponseMessage>...) : Matcher<List<ResponseMessage>> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    public static Matcher<ResponseMessage> hasNotification( Notification notification )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                Map<String,Object> meta = toRawMap( ((SuccessMessage) t).meta() );

                assertThat( meta.containsKey( "notifications" ), is( true ) );
                Set<Notification> notifications =
                        ((List<Map<String,Object>>) meta.get( "notifications" )).stream().map( TestNotification::fromMap ).collect( Collectors.toSet() );

                assertThat( notifications, Matchers.contains( notification ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

    public static Matcher<ResponseMessage> hasNotification( Notification notification )
    {
        return new TypeSafeMatcher<ResponseMessage>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                Map<String,Object> meta = toRawMap( ((SuccessMessage) t).meta() );

                assertThat( meta.containsKey( "notifications" ), is( true ) );
                Set<Notification> notifications =
                        ((List<Map<String,Object>>) meta.get( "notifications" ))
                                .stream()
                                .map( TestNotification::fromMap )
                                .collect( Collectors.toSet() );

                assertThat( notifications, Matchers.contains( notification ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<ResponseMessage> with TypeSafeMatcher<> in method public hasNotification(notification Notification) : Matcher<ResponseMessage> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    public static Matcher<ResponseMessage> msgSuccess( final Map<String,Object> metadata )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                assertThat( toRawMap( ((SuccessMessage) t).meta() ), equalTo( metadata ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

    public static Matcher<ResponseMessage> msgSuccess( final Map<String,Object> metadata )
    {
        return new TypeSafeMatcher<ResponseMessage>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                assertThat( toRawMap( ((SuccessMessage) t).meta() ), equalTo( metadata ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<ResponseMessage> with TypeSafeMatcher<> in method public msgSuccess(metadata Map<String,Object>) : Matcher<ResponseMessage> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    public static Matcher<ResponseMessage> msgSuccess( final Matcher<Map<String,?>> matcher )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                Map<String,Object> actual = toRawMap( ((SuccessMessage) t).meta() );
                assertThat( actual, matcher );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

    public static Matcher<ResponseMessage> msgSuccess( final Matcher<Map<String,?>> matcher )
    {
        return new TypeSafeMatcher<ResponseMessage>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                Map<String,Object> actual = toRawMap( ((SuccessMessage) t).meta() );
                assertThat( actual, matcher );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<ResponseMessage> with TypeSafeMatcher<> in method public msgSuccess(matcher Matcher<Map<String,?>>) : Matcher<ResponseMessage> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    public static Matcher<ResponseMessage> msgSuccess()
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

    public static Matcher<ResponseMessage> msgSuccess()
    {
        return new TypeSafeMatcher<ResponseMessage>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( SuccessMessage.class ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "SUCCESS" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<ResponseMessage> with TypeSafeMatcher<> in method public msgSuccess() : Matcher<ResponseMessage> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    public static Matcher<ResponseMessage> msgIgnored()
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( IgnoredMessage.class ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "IGNORED" );
            }
        };
    }

    public static Matcher<ResponseMessage> msgIgnored()
    {
        return new TypeSafeMatcher<ResponseMessage>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( IgnoredMessage.class ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "IGNORED" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<ResponseMessage> with TypeSafeMatcher<> in method public msgIgnored() : Matcher<ResponseMessage> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    public static Matcher<ResponseMessage> msgFailure( final Status status, final String message )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( FailureMessage.class ) );
                FailureMessage msg = (FailureMessage) t;
                assertThat( msg.status(), equalTo( status ) );
                assertThat( msg.message(), containsString( message ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "FAILURE" );
            }
        };
    }

    public static Matcher<ResponseMessage> msgFailure( final Status status, final String message )
    {
        return new TypeSafeMatcher<ResponseMessage>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( FailureMessage.class ) );
                FailureMessage msg = (FailureMessage) t;
                assertThat( msg.status(), equalTo( status ) );
                assertThat( msg.message(), containsString( message ) );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "FAILURE" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<ResponseMessage> with TypeSafeMatcher<> in method public msgFailure(status Status, message String) : Matcher<ResponseMessage> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    public static Matcher<ResponseMessage> msgRecord( final Matcher<AnyValue[]> matcher )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( RecordMessage.class ) );

                RecordMessage msg = (RecordMessage) t;
                assertThat( msg.fields(), matcher );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "RECORD " );
                description.appendDescriptionOf( matcher );
            }
        };
    }

    public static Matcher<ResponseMessage> msgRecord( final Matcher<AnyValue[]> matcher )
    {
        return new TypeSafeMatcher<ResponseMessage>()
        {
            @Override
            protected boolean matchesSafely( ResponseMessage t )
            {
                assertThat( t, instanceOf( RecordMessage.class ) );

                RecordMessage msg = (RecordMessage) t;
                assertThat( msg.fields(), matcher );
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "RECORD " );
                description.appendDescriptionOf( matcher );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<ResponseMessage> with TypeSafeMatcher<> in method public msgRecord(matcher Matcher<AnyValue[]>) : Matcher<ResponseMessage> from class org.neo4j.bolt.v1.messaging.util.MessageMatchers


    private void executeInThread( final String query, Map<String,Object> params )
    {
        executorService.execute( () ->
        {
            try
            {
                try ( Transaction transaction = db.beginTx() )
                {
                    db.execute( query, params ).resultAsString();
                    transaction.commit();
                }
            }
            catch ( Exception e )
            {
                hasFailed.set( true );
            }
        } );
    }

    private void executeInThread( final String query, Map<String,Object> params )
    {
        executorService.execute( () ->
        {
            try
            {
                db.execute( query, params ).resultAsString();
            }
            catch ( Exception e )
            {
                hasFailed.set( true );
            }
        } );
    }

Try With Resources try(Transaction transaction=db.beginTx()) in method private executeInThread(query String, params Map<String,Object>) : void from class org.neo4j.cypher.CreateIndexStressIT


    @Test
    void shouldThrowAppropriateException()
    {
        try
        {
            try ( Transaction transaction = db.beginTx() )
            {
                db.execute( "RETURN rand()/0" ).next();
            }
        }
        catch ( QueryExecutionException ex )
        {
            assertThat( ex.getCause(), instanceOf( QueryExecutionKernelException.class ) );
            assertThat( ex.getCause().getCause(), instanceOf( ArithmeticException.class ) );
        }
    }

    @Test
    void shouldThrowAppropriateException()
    {
        try
        {
            db.execute( "RETURN rand()/0" ).next();
        }
        catch ( QueryExecutionException ex )
        {
            assertThat( ex.getCause(), instanceOf( QueryExecutionKernelException.class ) );
            assertThat( ex.getCause().getCause(), instanceOf( ArithmeticException.class ) );
        }
    }

Try With Resources try(Transaction transaction=db.beginTx()) in method package shouldThrowAppropriateException() : void from class org.neo4j.cypher.internal.javacompat.ExecutionResultTest


    @Test
    void shouldThrowAppropriateExceptionAlsoWhenVisiting()
    {
        try
        {
            try ( Transaction transaction = db.beginTx() )
            {
                db.execute( "RETURN rand()/0" ).accept( row -> true );
            }
        }
        catch ( QueryExecutionException ex )
        {
            assertThat( ex.getCause(), instanceOf( QueryExecutionKernelException.class ) );
            assertThat( ex.getCause().getCause(), instanceOf( ArithmeticException.class ) );
        }
    }

    @Test
    void shouldThrowAppropriateExceptionAlsoWhenVisiting()
    {
        try
        {
            db.execute( "RETURN rand()/0" ).accept( row -> true );
        }
        catch ( QueryExecutionException ex )
        {
            assertThat( ex.getCause(), instanceOf( QueryExecutionKernelException.class ) );
            assertThat( ex.getCause().getCause(), instanceOf( ArithmeticException.class ) );
        }
    }

Try With Resources try(Transaction transaction=db.beginTx()) in method package shouldThrowAppropriateExceptionAlsoWhenVisiting() : void from class org.neo4j.cypher.internal.javacompat.ExecutionResultTest


    public static TestData.Producer<Map<String, Node>> createGraphFor( final GraphHolder holder, final boolean destroy )
    {
        return new TestData.Producer<>()
        {
            @Override
            public Map<String,Node> create( GraphDefinition graph, String title, String documentation )
            {
                return graph.create( holder.graphdb() );
            }

            @Override
            public void destroy( Map<String,Node> product, boolean successful )
            {
                if ( destroy )
                {
                    GraphDescription.destroy( product );
                }
            }
        };
    }

    public static TestData.Producer<Map<String, Node>> createGraphFor( final GraphHolder holder, final boolean destroy )
    {
        return new TestData.Producer<Map<String, Node>>()
        {
            @Override
            public Map<String, Node> create( GraphDefinition graph, String title, String documentation )
            {
                return graph.create( holder.graphdb() );
            }

            @Override
            public void destroy( Map<String, Node> product, boolean successful )
            {
                if ( destroy )
                {
                    GraphDescription.destroy( product );
                }
            }
        };
    }

Replace Generic With Diamond TestData.Producer<Map<String,Node>> with TestData.Producer<> in method public createGraphFor(holder GraphHolder, destroy boolean) : TestData.Producer<Map<String,Node>> from class org.neo4j.test.GraphDescription


    @Test
    void shouldRunBuilderOnExistingStoreDir()
    {
        // When
        // create graph db with one node upfront
        File existingStoreDir = directory.directory( "existingStore" );
        Config config = Config.defaults( data_directory, existingStoreDir.toPath() );
        File rootDirectory = config.get( databases_root_path ).toFile();
        DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder( rootDirectory )
                .setConfig( transaction_logs_root_path, new File( existingStoreDir, DEFAULT_TX_LOGS_ROOT_DIR_NAME ).toPath().toAbsolutePath() ).build();
        GraphDatabaseService db = managementService.database( DEFAULT_DATABASE_NAME );
        try ( Transaction transaction = db.beginTx() )
        {
            db.execute( "create ()" );
            transaction.commit();
        }
        finally
        {
            managementService.shutdown();
        }

        try ( InProcessNeo4j neo4j = getTestBuilder( directory.storeDir() ).copyFrom( existingStoreDir ).build() )
        {
            // Then
            GraphDatabaseService graphDatabaseService = neo4j.defaultDatabaseService();
            try ( Transaction tx = graphDatabaseService.beginTx() )
            {
                ResourceIterable<Node> allNodes = Iterables.asResourceIterable( graphDatabaseService.getAllNodes() );

                assertTrue( Iterables.count( allNodes ) > 0 );

                // When: create another node
                graphDatabaseService.createNode();
                tx.commit();
            }
        }

        // Then: we still only have one node since the server is supposed to work on a copy
        managementService = new TestDatabaseManagementServiceBuilder( rootDirectory )
                .setConfig( transaction_logs_root_path, new File( existingStoreDir, DEFAULT_TX_LOGS_ROOT_DIR_NAME ).toPath().toAbsolutePath() ).build();
        db = managementService.database( DEFAULT_DATABASE_NAME );
        try
        {
            try ( Transaction tx = db.beginTx() )
            {
                assertEquals( 1, Iterables.count( db.getAllNodes() ) );
                tx.commit();
            }
        }
        finally
        {
            managementService.shutdown();
        }
    }

    @Test
    void shouldRunBuilderOnExistingStoreDir()
    {
        // When
        // create graph db with one node upfront
        File existingStoreDir = directory.directory( "existingStore" );
        Config config = Config.defaults( data_directory, existingStoreDir.toPath() );
        File rootDirectory = config.get( databases_root_path ).toFile();
        DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder( rootDirectory )
                .setConfig( transaction_logs_root_path, new File( existingStoreDir, DEFAULT_TX_LOGS_ROOT_DIR_NAME ).toPath().toAbsolutePath() ).build();
        GraphDatabaseService db = managementService.database( DEFAULT_DATABASE_NAME );
        try
        {
            db.execute( "create ()" );
        }
        finally
        {
            managementService.shutdown();
        }

        try ( InProcessNeo4j neo4j = getTestBuilder( directory.storeDir() ).copyFrom( existingStoreDir ).build() )
        {
            // Then
            GraphDatabaseService graphDatabaseService = neo4j.defaultDatabaseService();
            try ( Transaction tx = graphDatabaseService.beginTx() )
            {
                ResourceIterable<Node> allNodes = Iterables.asResourceIterable( graphDatabaseService.getAllNodes() );

                assertTrue( Iterables.count( allNodes ) > 0 );

                // When: create another node
                graphDatabaseService.createNode();
                tx.commit();
            }
        }

        // Then: we still only have one node since the server is supposed to work on a copy
        managementService = new TestDatabaseManagementServiceBuilder( rootDirectory )
                .setConfig( transaction_logs_root_path, new File( existingStoreDir, DEFAULT_TX_LOGS_ROOT_DIR_NAME ).toPath().toAbsolutePath() ).build();
        db = managementService.database( DEFAULT_DATABASE_NAME );
        try
        {
            try ( Transaction tx = db.beginTx() )
            {
                assertEquals( 1, Iterables.count( db.getAllNodes() ) );
                tx.commit();
            }
        }
        finally
        {
            managementService.shutdown();
        }
    }

Try With Resources try(Transaction transaction=db.beginTx()) in method package shouldRunBuilderOnExistingStoreDir() : void from class org.neo4j.harness.InProcessServerBuilderIT


    static Matcher<String> isValidRFCTimestamp()
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( String item )
            {
                try
                {
                    ZonedDateTime.parse( item, DateTimeFormatter.RFC_1123_DATE_TIME );
                    return true;
                }
                catch ( Exception e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "valid RFC1134 timestamp" );
            }
        };
    }

    static Matcher<String> isValidRFCTimestamp()
    {
        return new TypeSafeMatcher<String>()
        {
            @Override
            protected boolean matchesSafely( String item )
            {
                try
                {
                    ZonedDateTime.parse( item, DateTimeFormatter.RFC_1123_DATE_TIME );
                    return true;
                }
                catch ( Exception e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "valid RFC1134 timestamp" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<String> with TypeSafeMatcher<> in method package isValidRFCTimestamp() : Matcher<String> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    static Matcher<String> matches( final String pattern )
    {
        final Pattern regex = Pattern.compile( pattern );

        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( String item )
            {
                return regex.matcher( item ).matches();
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "matching regex: " ).appendValue( pattern );
            }
        };
    }

    static Matcher<String> matches( final String pattern )
    {
        final Pattern regex = Pattern.compile( pattern );

        return new TypeSafeMatcher<String>()
        {
            @Override
            protected boolean matchesSafely( String item )
            {
                return regex.matcher( item ).matches();
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "matching regex: " ).appendValue( pattern );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<String> with TypeSafeMatcher<> in method package matches(pattern String) : Matcher<String> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> hasErrors( final Status... expectedErrors )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> errors = response.get( "errors" ).iterator();
                    Iterator<Status> expected = iterator( expectedErrors );

                    while ( expected.hasNext() )
                    {
                        assertTrue( errors.hasNext() );
                        assertThat( errors.next().get( "code" ).asText(), equalTo( expected.next().code().serialize() ) );
                    }
                    if ( errors.hasNext() )
                    {
                        JsonNode error = errors.next();
                        fail( "Expected no more errors, but got " + error.get( "code" ) + " - '" + error.get( "message" ) + "'." );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> hasErrors( final Status... expectedErrors )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> errors = response.get( "errors" ).iterator();
                    Iterator<Status> expected = iterator( expectedErrors );

                    while ( expected.hasNext() )
                    {
                        assertTrue( errors.hasNext() );
                        assertThat( errors.next().get( "code" ).asText(), equalTo( expected.next().code().serialize() ) );
                    }
                    if ( errors.hasNext() )
                    {
                        JsonNode error = errors.next();
                        fail( "Expected no more errors, but got " + error.get( "code" ) + " - '" + error.get( "message" ) + "'." );
                    }
                    return true;

                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public hasErrors(expectedErrors Status...) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> rowContainsDeletedEntities( final int nodes, final int rels )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

                    int nodeCounter = 0;
                    int relCounter = 0;
                    for ( int i = 0; i < nodes + rels; ++i )
                    {
                        assertTrue( meta.hasNext() );
                        JsonNode node = meta.next();
                        assertThat( node.get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
                        String type = node.get( "type" ).getTextValue();
                        switch ( type )
                        {
                        case "node":
                            ++nodeCounter;
                            break;
                        case "relationship":
                            ++relCounter;
                            break;
                        default:
                            fail( "Unexpected type: " + type );
                            break;
                        }
                    }
                    assertEquals( nodes, nodeCounter );
                    assertEquals( rels, relCounter );
                    while ( meta.hasNext() )
                    {
                        JsonNode node = meta.next();
                        assertThat( node.get( "deleted" ).asBoolean(), equalTo( Boolean.FALSE ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> rowContainsDeletedEntities( final int nodes, final int rels )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

                    int nodeCounter = 0;
                    int relCounter = 0;
                    for ( int i = 0; i < nodes + rels; ++i )
                    {
                        assertTrue( meta.hasNext() );
                        JsonNode node = meta.next();
                        assertThat( node.get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
                        String type = node.get( "type" ).getTextValue();
                        switch ( type )
                        {
                        case "node":
                            ++nodeCounter;
                            break;
                        case "relationship":
                            ++relCounter;
                            break;
                        default:
                            fail( "Unexpected type: " + type );
                            break;
                        }
                    }
                    assertEquals( nodes, nodeCounter );
                    assertEquals( rels, relCounter );
                    while ( meta.hasNext() )
                    {
                        JsonNode node = meta.next();
                        assertThat( node.get( "deleted" ).asBoolean(), equalTo( Boolean.FALSE ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public rowContainsDeletedEntities(nodes int, rels int) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> rowContainsDeletedEntitiesInPath( final int nodes, final int rels )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

                    int nodeCounter = 0;
                    int relCounter = 0;
                    assertTrue( "Expected to find a JSON node, but there was none", meta.hasNext() );
                    JsonNode node = meta.next();
                    assertTrue( "Expected the node to be a list (for a path)", node.isArray() );
                    for ( JsonNode inner : node )
                    {
                        String type = inner.get( "type" ).getTextValue();
                        switch ( type )
                        {
                        case "node":
                            if ( inner.get( "deleted" ).asBoolean() )
                            {
                                ++nodeCounter;
                            }
                            break;
                        case "relationship":
                            if ( inner.get( "deleted" ).asBoolean() )
                            {
                                ++relCounter;
                            }
                            break;
                        default:
                            fail( "Unexpected type: " + type );
                            break;
                        }
                    }
                    assertEquals( nodes, nodeCounter );
                    assertEquals( rels, relCounter );
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> rowContainsDeletedEntitiesInPath( final int nodes, final int rels )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

                    int nodeCounter = 0;
                    int relCounter = 0;
                    assertTrue( "Expected to find a JSON node, but there was none", meta.hasNext() );
                    JsonNode node = meta.next();
                    assertTrue( "Expected the node to be a list (for a path)", node.isArray() );
                    for ( JsonNode inner : node )
                    {
                        String type = inner.get( "type" ).getTextValue();
                        switch ( type )
                        {
                        case "node":
                            if ( inner.get( "deleted" ).asBoolean() )
                            {
                                ++nodeCounter;
                            }
                            break;
                        case "relationship":
                            if ( inner.get( "deleted" ).asBoolean() )
                            {
                                ++relCounter;
                            }
                            break;
                        default:
                            fail( "Unexpected type: " + type );
                            break;
                        }
                    }
                    assertEquals( nodes, nodeCounter );
                    assertEquals( rels, relCounter );
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public rowContainsDeletedEntitiesInPath(nodes int, rels int) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> rowContainsMetaNodesAtIndex( int... indexes )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                return assertElementAtMetaIndex( response, indexes, "node" );
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> rowContainsMetaNodesAtIndex( int... indexes )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                return assertElementAtMetaIndex( response, indexes, "node" );
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public rowContainsMetaNodesAtIndex(indexes int...) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> rowContainsMetaRelsAtIndex( int... indexes )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                return assertElementAtMetaIndex( response, indexes, "relationship" );
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> rowContainsMetaRelsAtIndex( int... indexes )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                return assertElementAtMetaIndex( response, indexes, "relationship" );
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public rowContainsMetaRelsAtIndex(indexes int...) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> rowContainsAMetaListAtIndex( int index )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

                    for ( int metaIndex = 0; meta.hasNext(); metaIndex++ )
                    {
                        JsonNode node = meta.next();
                        if ( metaIndex == index )
                        {
                            assertTrue( node.isArray() );
                        }
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> rowContainsAMetaListAtIndex( int index )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

                    for ( int metaIndex = 0; meta.hasNext(); metaIndex++ )
                    {
                        JsonNode node = meta.next();
                        if ( metaIndex == index )
                        {
                            assertTrue( node.isArray() );
                        }
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public rowContainsAMetaListAtIndex(index int) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> restContainsDeletedEntities( final int amount )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> entities = getJsonNodeWithName( response, "rest" ).iterator();

                    for ( int i = 0; i < amount; ++i )
                    {
                        assertTrue( entities.hasNext() );
                        JsonNode node = entities.next();
                        assertThat( node.get( "metadata" ).get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
                    }
                    if ( entities.hasNext() )
                    {
                        fail( "Expected no more entities" );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> restContainsDeletedEntities( final int amount )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> entities = getJsonNodeWithName( response, "rest" ).iterator();

                    for ( int i = 0; i < amount; ++i )
                    {
                        assertTrue( entities.hasNext() );
                        JsonNode node = entities.next();
                        assertThat( node.get( "metadata" ).get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
                    }
                    if ( entities.hasNext() )
                    {
                        fail( "Expected no more entities" );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public restContainsDeletedEntities(amount int) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> graphContainsDeletedNodes( final int amount )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> nodes = getJsonNodeWithName( response, "graph" ).get( "nodes" ).iterator();
                    int deleted = 0;
                    while ( nodes.hasNext() )
                    {
                        JsonNode node = nodes.next();
                        if ( node.get( "deleted" ) != null )
                        {
                            assertTrue( node.get( "deleted" ).asBoolean() );
                            deleted++;
                        }
                    }
                    assertEquals( format( "Expected to see %d deleted elements but %d was encountered.", amount, deleted ), amount, deleted );
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> graphContainsDeletedNodes( final int amount )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> nodes = getJsonNodeWithName( response, "graph" ).get( "nodes" ).iterator();
                    int deleted = 0;
                    while ( nodes.hasNext() )
                    {
                        JsonNode node = nodes.next();
                        if ( node.get( "deleted" ) != null )
                        {
                            assertTrue( node.get( "deleted" ).asBoolean() );
                            deleted++;
                        }
                    }
                    assertEquals( format( "Expected to see %d deleted elements but %d was encountered.", amount, deleted ),
                            amount, deleted );
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public graphContainsDeletedNodes(amount int) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> graphContainsNoDeletedEntities()
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    for ( JsonNode node : getJsonNodeWithName( response, "graph" ).get( "nodes" ) )
                    {
                        assertNull( node.get( "deleted" ) );
                    }
                    for ( JsonNode node : getJsonNodeWithName( response, "graph" ).get( "relationships" ) )
                    {
                        assertNull( node.get( "deleted" ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> graphContainsNoDeletedEntities()
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    for ( JsonNode node : getJsonNodeWithName( response, "graph" ).get( "nodes" ) )
                    {
                        assertNull( node.get( "deleted" ) );
                    }
                    for ( JsonNode node : getJsonNodeWithName( response, "graph" ).get( "relationships" ) )
                    {
                        assertNull( node.get( "deleted" ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public graphContainsNoDeletedEntities() : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> rowContainsNoDeletedEntities()
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    for ( JsonNode node : getJsonNodeWithName( response, "meta" ) )
                    {
                        assertFalse( node.get( "deleted" ).asBoolean() );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> rowContainsNoDeletedEntities()
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    for ( JsonNode node : getJsonNodeWithName( response, "meta" ) )
                    {
                        assertFalse( node.get( "deleted" ).asBoolean() );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public rowContainsNoDeletedEntities() : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> restContainsNoDeletedEntities()
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    for ( JsonNode node : getJsonNodeWithName( response, "rest" ) )
                    {
                        assertNull( node.get( "metadata" ).get( "deleted" ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> restContainsNoDeletedEntities()
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    for ( JsonNode node : getJsonNodeWithName( response, "rest" ) )
                    {
                        assertNull( node.get( "metadata" ).get( "deleted" ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public restContainsNoDeletedEntities() : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> graphContainsDeletedRelationships( final int amount )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> relationships = getJsonNodeWithName( response, "graph" ).get( "relationships" ).iterator();

                    for ( int i = 0; i < amount; ++i )
                    {
                        assertTrue( relationships.hasNext() );
                        JsonNode node = relationships.next();
                        assertThat( node.get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
                    }
                    if ( relationships.hasNext() )
                    {
                        JsonNode node = relationships.next();
                        fail( "Expected no more nodes, but got a node with id " + node.get( "id" ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

    public static Matcher<? super HTTP.Response> graphContainsDeletedRelationships( final int amount )
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                try
                {
                    Iterator<JsonNode> relationships = getJsonNodeWithName( response, "graph" ).get( "relationships" ).iterator();

                    for ( int i = 0; i < amount; ++i )
                    {
                        assertTrue( relationships.hasNext() );
                        JsonNode node = relationships.next();
                        assertThat( node.get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
                    }
                    if ( relationships.hasNext() )
                    {
                        JsonNode node = relationships.next();
                        fail( "Expected no more nodes, but got a node with id " + node.get( "id" ) );
                    }
                    return true;
                }
                catch ( JsonParseException e )
                {
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public graphContainsDeletedRelationships(amount int) : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    public static Matcher<? super HTTP.Response> containsNoStackTraces()
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                Map<String,Object> content = response.content();
                @SuppressWarnings( "unchecked" ) List<Map<String,Object>> errors = (List<Map<String,Object>>) content.get( "errors" );

                for ( Map<String,Object> error : errors )
                {
                    if ( error.containsKey( "stackTrace" ) )
                    {
                        return false;
                    }
                }

                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "contains stack traces" );
            }
        };
    }

    public static Matcher<? super HTTP.Response> containsNoStackTraces()
    {
        return new TypeSafeMatcher<HTTP.Response>()
        {
            @Override
            protected boolean matchesSafely( HTTP.Response response )
            {
                Map<String, Object> content = response.content();
                @SuppressWarnings( "unchecked" )
                List<Map<String, Object>> errors = (List<Map<String, Object>>) content.get( "errors" );

                for ( Map<String, Object> error : errors )
                {
                    if ( error.containsKey( "stackTrace" ) )
                    {
                        return false;
                    }
                }

                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "contains stack traces" );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<HTTP.Response> with TypeSafeMatcher<> in method public containsNoStackTraces() : Matcher<? super HTTP.Response> from class org.neo4j.server.http.cypher.integration.TransactionMatchers


    @Override
    public OwningRecordCheck<NodeRecord, NodeConsistencyReport> decorateNodeChecker(
            OwningRecordCheck<NodeRecord, NodeConsistencyReport> checker )
    {
        if ( owners == null )
        {
            return checker;
        }
        return new PrimitiveCheckerDecorator<>( checker )
        {
            @Override
            PropertyOwner owner( NodeRecord record )
            {
                return new PropertyOwner.OwningNode( record );
            }
        };
    }

    @Override
    public OwningRecordCheck<NodeRecord, NodeConsistencyReport> decorateNodeChecker(
            OwningRecordCheck<NodeRecord, NodeConsistencyReport> checker )
    {
        if ( owners == null )
        {
            return checker;
        }
        return new PrimitiveCheckerDecorator<NodeRecord, NodeConsistencyReport>( checker )
        {
            @Override
            PropertyOwner owner( NodeRecord record )
            {
                return new PropertyOwner.OwningNode( record );
            }
        };
    }

Replace Generic With Diamond PrimitiveCheckerDecorator<NodeRecord,NodeConsistencyReport> with PrimitiveCheckerDecorator<> in method public decorateNodeChecker(checker OwningRecordCheck<NodeRecord,NodeConsistencyReport>) : OwningRecordCheck<NodeRecord,NodeConsistencyReport> from class org.neo4j.consistency.checking.full.OwnerCheck


    @Override
    public OwningRecordCheck<RelationshipRecord, RelationshipConsistencyReport> decorateRelationshipChecker(
            OwningRecordCheck<RelationshipRecord, RelationshipConsistencyReport> checker )
    {
        if ( owners == null )
        {
            return checker;
        }
        return new PrimitiveCheckerDecorator<>( checker )
        {
            @Override
            PropertyOwner owner( RelationshipRecord record )
            {
                return new PropertyOwner.OwningRelationship( record );
            }
        };
    }

    @Override
    public OwningRecordCheck<RelationshipRecord, RelationshipConsistencyReport> decorateRelationshipChecker(
            OwningRecordCheck<RelationshipRecord, RelationshipConsistencyReport> checker )
    {
        if ( owners == null )
        {
            return checker;
        }
        return new PrimitiveCheckerDecorator<RelationshipRecord, RelationshipConsistencyReport>(
                checker )
        {
            @Override
            PropertyOwner owner( RelationshipRecord record )
            {
                return new PropertyOwner.OwningRelationship( record );
            }
        };
    }

Replace Generic With Diamond PrimitiveCheckerDecorator<RelationshipRecord,RelationshipConsistencyReport> with PrimitiveCheckerDecorator<> in method public decorateRelationshipChecker(checker OwningRecordCheck<RelationshipRecord,RelationshipConsistencyReport>) : OwningRecordCheck<RelationshipRecord,RelationshipConsistencyReport> from class org.neo4j.consistency.checking.full.OwnerCheck


    @Override
    public RecordCheck<PropertyKeyTokenRecord, PropertyKeyTokenConsistencyReport> decoratePropertyKeyTokenChecker(
            RecordCheck<PropertyKeyTokenRecord, PropertyKeyTokenConsistencyReport> checker )
    {
        ConcurrentMap<Long, DynamicOwner> dynamicOwners = dynamicOwners( PROPERTY_KEY_NAME );
        if ( dynamicOwners == null )
        {
            return checker;
        }
        return new NameCheckerDecorator<>( checker, dynamicOwners )
        {
            @Override
            DynamicOwner.NameOwner owner( PropertyKeyTokenRecord record )
            {
                return new DynamicOwner.PropertyKey( record );
            }
        };
    }

    @Override
    public RecordCheck<PropertyKeyTokenRecord, PropertyKeyTokenConsistencyReport> decoratePropertyKeyTokenChecker(
            RecordCheck<PropertyKeyTokenRecord, PropertyKeyTokenConsistencyReport> checker )
    {
        ConcurrentMap<Long, DynamicOwner> dynamicOwners = dynamicOwners( PROPERTY_KEY_NAME );
        if ( dynamicOwners == null )
        {
            return checker;
        }
        return new NameCheckerDecorator
                <PropertyKeyTokenRecord, PropertyKeyTokenConsistencyReport>( checker, dynamicOwners )
        {
            @Override
            DynamicOwner.NameOwner owner( PropertyKeyTokenRecord record )
            {
                return new DynamicOwner.PropertyKey( record );
            }
        };
    }

Replace Generic With Diamond NameCheckerDecorator<PropertyKeyTokenRecord,PropertyKeyTokenConsistencyReport> with NameCheckerDecorator<> in method public decoratePropertyKeyTokenChecker(checker RecordCheck<PropertyKeyTokenRecord,PropertyKeyTokenConsistencyReport>) : RecordCheck<PropertyKeyTokenRecord,PropertyKeyTokenConsistencyReport> from class org.neo4j.consistency.checking.full.OwnerCheck


    @Override
    public RecordCheck<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport> decorateRelationshipTypeTokenChecker(
            RecordCheck<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport> checker )
    {
        ConcurrentMap<Long,DynamicOwner> dynamicOwners = dynamicOwners( RELATIONSHIP_TYPE_NAME );
        if ( dynamicOwners == null )
        {
            return checker;
        }
        return new NameCheckerDecorator<>( checker, dynamicOwners )
        {
            @Override
            DynamicOwner.NameOwner owner( RelationshipTypeTokenRecord record )
            {
                return new DynamicOwner.RelationshipTypeToken( record );
            }
        };
    }

    @Override
    public RecordCheck<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport> decorateRelationshipTypeTokenChecker(
            RecordCheck<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport> checker )
    {
        ConcurrentMap<Long,DynamicOwner> dynamicOwners = dynamicOwners( RELATIONSHIP_TYPE_NAME );
        if ( dynamicOwners == null )
        {
            return checker;
        }
        return new NameCheckerDecorator<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport>(
                checker, dynamicOwners )
        {
            @Override
            DynamicOwner.NameOwner owner( RelationshipTypeTokenRecord record )
            {
                return new DynamicOwner.RelationshipTypeToken( record );
            }
        };
    }

Replace Generic With Diamond NameCheckerDecorator<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport> with NameCheckerDecorator<> in method public decorateRelationshipTypeTokenChecker(checker RecordCheck<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport>) : RecordCheck<RelationshipTypeTokenRecord,RelationshipTypeConsistencyReport> from class org.neo4j.consistency.checking.full.OwnerCheck


    @Override
    public RecordCheck<LabelTokenRecord, LabelTokenConsistencyReport> decorateLabelTokenChecker(
            RecordCheck<LabelTokenRecord, LabelTokenConsistencyReport> checker )
    {
        ConcurrentMap<Long, DynamicOwner> dynamicOwners = dynamicOwners( RELATIONSHIP_TYPE_NAME );
        if ( dynamicOwners == null )
        {
            return checker;
        }
        return new NameCheckerDecorator<>( checker, dynamicOwners )
        {
            @Override
            DynamicOwner.NameOwner owner( LabelTokenRecord record )
            {
                return new DynamicOwner.LabelToken( record );
            }
        };
    }

    @Override
    public RecordCheck<LabelTokenRecord, LabelTokenConsistencyReport> decorateLabelTokenChecker(
            RecordCheck<LabelTokenRecord, LabelTokenConsistencyReport> checker )
    {
        ConcurrentMap<Long, DynamicOwner> dynamicOwners = dynamicOwners( RELATIONSHIP_TYPE_NAME );
        if ( dynamicOwners == null )
        {
            return checker;
        }
        return new NameCheckerDecorator<LabelTokenRecord, LabelTokenConsistencyReport>( checker, dynamicOwners )
        {
            @Override
            DynamicOwner.NameOwner owner( LabelTokenRecord record )
            {
                return new DynamicOwner.LabelToken( record );
            }
        };
    }

Replace Generic With Diamond NameCheckerDecorator<LabelTokenRecord,LabelTokenConsistencyReport> with NameCheckerDecorator<> in method public decorateLabelTokenChecker(checker RecordCheck<LabelTokenRecord,LabelTokenConsistencyReport>) : RecordCheck<LabelTokenRecord,LabelTokenConsistencyReport> from class org.neo4j.consistency.checking.full.OwnerCheck


    public static <T> Matcher<? super T> inTx( final GraphDatabaseService db, final Matcher<T> inner,
            final boolean successful )
    {
        return new DiagnosingMatcher<>()
        {
            @Override
            protected boolean matches( Object item, Description mismatchDescription )
            {
                try ( Transaction ignored = db.beginTx() )
                {
                    if ( inner.matches( item ) )
                    {
                        if ( successful )
                        {
                            ignored.commit();
                        }
                        return true;
                    }

                    inner.describeMismatch( item, mismatchDescription );

                    if ( successful )
                    {
                        ignored.commit();
                    }
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
                inner.describeTo( description );
            }
        };
    }

    public static <T> Matcher<? super T> inTx( final GraphDatabaseService db, final Matcher<T> inner,
            final boolean successful )
    {
        return new DiagnosingMatcher<T>()
        {
            @Override
            protected boolean matches( Object item, Description mismatchDescription )
            {
                try ( Transaction ignored = db.beginTx() )
                {
                    if ( inner.matches( item ) )
                    {
                        if ( successful )
                        {
                            ignored.success();
                        }
                        return true;
                    }

                    inner.describeMismatch( item, mismatchDescription );

                    if ( successful )
                    {
                        ignored.success();
                    }
                    return false;
                }
            }

            @Override
            public void describeTo( Description description )
            {
                inner.describeTo( description );
            }
        };
    }

Replace Generic With Diamond DiagnosingMatcher<T> with DiagnosingMatcher<> in method public inTx(db GraphDatabaseService, inner Matcher<T>, successful boolean) : Matcher<? super T> from class org.neo4j.test.mockito.matcher.Neo4jMatchers


    public static TypeSafeDiagnosingMatcher<Node> hasLabel( final Label myLabel )
    {
        return new TypeSafeDiagnosingMatcher<>()
        {
            @Override
            public void describeTo( Description description )
            {
                description.appendValue( myLabel );
            }

            @Override
            protected boolean matchesSafely( Node item, Description mismatchDescription )
            {
                boolean result = item.hasLabel( myLabel );
                if ( !result )
                {
                    Set<String> labels = asLabelNameSet( item.getLabels() );
                    mismatchDescription.appendText( labels.toString() );
                }
                return result;
            }
        };
    }

    public static TypeSafeDiagnosingMatcher<Node> hasLabel( final Label myLabel )
    {
        return new TypeSafeDiagnosingMatcher<Node>()
        {
            @Override
            public void describeTo( Description description )
            {
                description.appendValue( myLabel );
            }

            @Override
            protected boolean matchesSafely( Node item, Description mismatchDescription )
            {
                boolean result = item.hasLabel( myLabel );
                if ( !result )
                {
                    Set<String> labels = asLabelNameSet( item.getLabels() );
                    mismatchDescription.appendText( labels.toString() );
                }
                return result;
            }
        };
    }

Replace Generic With Diamond TypeSafeDiagnosingMatcher<Node> with TypeSafeDiagnosingMatcher<> in method public hasLabel(myLabel Label) : TypeSafeDiagnosingMatcher<Node> from class org.neo4j.test.mockito.matcher.Neo4jMatchers


    public static TypeSafeDiagnosingMatcher<Node> hasLabels( final Set<String> expectedLabels )
    {
        return new TypeSafeDiagnosingMatcher<>()
        {
            private Set<String> foundLabels;

            @Override
            public void describeTo( Description description )
            {
                description.appendText( expectedLabels.toString() );
            }

            @Override
            protected boolean matchesSafely( Node item, Description mismatchDescription )
            {
                foundLabels = asLabelNameSet( item.getLabels() );

                if ( foundLabels.size() == expectedLabels.size() && foundLabels.containsAll( expectedLabels ) )
                {
                    return true;
                }

                mismatchDescription.appendText( "was " + foundLabels.toString() );
                return false;
            }
        };
    }

    public static TypeSafeDiagnosingMatcher<Node> hasLabels( final Set<String> expectedLabels )
    {
        return new TypeSafeDiagnosingMatcher<Node>()
        {
            private Set<String> foundLabels;

            @Override
            public void describeTo( Description description )
            {
                description.appendText( expectedLabels.toString() );
            }

            @Override
            protected boolean matchesSafely( Node item, Description mismatchDescription )
            {
                foundLabels = asLabelNameSet( item.getLabels() );

                if ( foundLabels.size() == expectedLabels.size() && foundLabels.containsAll( expectedLabels ) )
                {
                    return true;
                }

                mismatchDescription.appendText( "was " + foundLabels.toString() );
                return false;
            }
        };
    }

Replace Generic With Diamond TypeSafeDiagnosingMatcher<Node> with TypeSafeDiagnosingMatcher<> in method public hasLabels(expectedLabels Set<String>) : TypeSafeDiagnosingMatcher<Node> from class org.neo4j.test.mockito.matcher.Neo4jMatchers


    public static TypeSafeDiagnosingMatcher<GraphDatabaseService> hasNoNodes( final Label withLabel )
    {
        return new TypeSafeDiagnosingMatcher<>()
        {
            @Override
            protected boolean matchesSafely( GraphDatabaseService db, Description mismatchDescription )
            {
                Set<Node> found = asSet( db.findNodes( withLabel ) );
                if ( !found.isEmpty() )
                {
                    mismatchDescription.appendText( "found " + found.toString() );
                    return false;
                }
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "no nodes with label " + withLabel );
            }
        };
    }

    public static TypeSafeDiagnosingMatcher<GraphDatabaseService> hasNoNodes( final Label withLabel )
    {
        return new TypeSafeDiagnosingMatcher<GraphDatabaseService>()
        {
            @Override
            protected boolean matchesSafely( GraphDatabaseService db, Description mismatchDescription )
            {
                Set<Node> found = asSet( db.findNodes( withLabel ) );
                if ( !found.isEmpty() )
                {
                    mismatchDescription.appendText( "found " + found.toString() );
                    return false;
                }
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "no nodes with label " + withLabel );
            }
        };
    }

Replace Generic With Diamond TypeSafeDiagnosingMatcher<GraphDatabaseService> with TypeSafeDiagnosingMatcher<> in method public hasNoNodes(withLabel Label) : TypeSafeDiagnosingMatcher<GraphDatabaseService> from class org.neo4j.test.mockito.matcher.Neo4jMatchers


    public static TypeSafeDiagnosingMatcher<GraphDatabaseService> hasNodes( final Label withLabel, final Node... expectedNodes )
    {
        return new TypeSafeDiagnosingMatcher<>()
        {
            @Override
            protected boolean matchesSafely( GraphDatabaseService db, Description mismatchDescription )
            {
                Set<Node> expected = asSet( expectedNodes );
                Set<Node> found = asSet( db.findNodes( withLabel ) );
                if ( !expected.equals( found ) )
                {
                    mismatchDescription.appendText( "found " + found.toString() );
                    return false;
                }
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( asSet( expectedNodes ).toString() + " with label " + withLabel );
            }
        };
    }

    public static TypeSafeDiagnosingMatcher<GraphDatabaseService> hasNodes( final Label withLabel, final Node... expectedNodes )
    {
        return new TypeSafeDiagnosingMatcher<GraphDatabaseService>()
        {
            @Override
            protected boolean matchesSafely( GraphDatabaseService db, Description mismatchDescription )
            {
                Set<Node> expected = asSet( expectedNodes );
                Set<Node> found = asSet( db.findNodes( withLabel ) );
                if ( !expected.equals( found ) )
                {
                    mismatchDescription.appendText( "found " + found.toString() );
                    return false;
                }
                return true;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( asSet( expectedNodes ).toString() + " with label " + withLabel );
            }
        };
    }

Replace Generic With Diamond TypeSafeDiagnosingMatcher<GraphDatabaseService> with TypeSafeDiagnosingMatcher<> in method public hasNodes(withLabel Label, expectedNodes Node...) : TypeSafeDiagnosingMatcher<GraphDatabaseService> from class org.neo4j.test.mockito.matcher.Neo4jMatchers