    @DELETE
    @Path( PATH_RELATIONSHIP_PROPERTY )
    public Response deleteRelationshipProperty( @PathParam( "relationshipId" ) long relationshipId,
                                                @PathParam( "key" ) String key )
    {
        try
        {
            actions.removeRelationshipProperty( relationshipId, key );
        }
        catch ( RelationshipNotFoundException | NoSuchPropertyException e )
        {
            return output.notFound( e );
        }
        return nothing();
    }

    @DELETE
    @Path( PATH_RELATIONSHIP_PROPERTY )
    public Response deleteRelationshipProperty( @PathParam( "relationshipId" ) long relationshipId,
                                                @PathParam( "key" ) String key )
    {
        try
        {
            actions.removeRelationshipProperty( relationshipId, key );
        }
        catch ( RelationshipNotFoundException e )
        {
            return output.notFound( e );
        }
        catch ( NoSuchPropertyException e )
        {
            return output.notFound( e );
        }
        return nothing();
    }

Merge Catch [catch(RelationshipNotFoundException e), catch(NoSuchPropertyException e)] to catch(RelationshipNotFoundException|NoSuchPropertyException e) in method public deleteRelationshipProperty(relationshipId long, key String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_NODE_INDEX )
    @Consumes( MediaType.APPLICATION_JSON )
    public Response jsonCreateNodeIndex(  String json )
    {
        try
        {
            return output.created( actions.createNodeIndex( input.readMap( json ) ) );
        }
        catch ( IllegalArgumentException | BadInputException e )
        {
            return output.badRequest( e );
        }
    }

    @POST
    @Path( PATH_NODE_INDEX )
    @Consumes( MediaType.APPLICATION_JSON )
    public Response jsonCreateNodeIndex(  String json )
    {
        try
        {
            return output.created( actions.createNodeIndex( input.readMap( json ) ) );
        }
        catch ( IllegalArgumentException e )
        {
            return output.badRequest( e );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
    }

Merge Catch [catch(IllegalArgumentException e), catch(BadInputException e)] to catch(IllegalArgumentException|BadInputException e) in method public jsonCreateNodeIndex(json String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_RELATIONSHIP_INDEX )
    @Consumes( MediaType.APPLICATION_JSON )
    public Response jsonCreateRelationshipIndex(  String json )
    {
        try
        {
            return output.created( actions.createRelationshipIndex( input.readMap( json ) ) );
        }
        catch ( BadInputException | IllegalArgumentException e )
        {
            return output.badRequest( e );
        }
        catch ( Exception e )
        {
            return output.serverError( e );
        }
    }

    @POST
    @Path( PATH_RELATIONSHIP_INDEX )
    @Consumes( MediaType.APPLICATION_JSON )
    public Response jsonCreateRelationshipIndex(  String json )
    {
        try
        {
            return output.created( actions.createRelationshipIndex( input.readMap( json ) ) );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( IllegalArgumentException e )
        {
            return output.badRequest( e );
        }
        catch ( Exception e )
        {
            return output.serverError( e );
        }
    }

Merge Catch [catch(BadInputException e), catch(IllegalArgumentException e)] to catch(BadInputException|IllegalArgumentException e) in method public jsonCreateRelationshipIndex(json String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_NAMED_NODE_INDEX )
    @Consumes( MediaType.APPLICATION_JSON )
    public Response addToNodeIndex( @PathParam( "indexName" ) String indexName, @QueryParam( "unique" ) String unique,
                                    @QueryParam( "uniqueness" ) String uniqueness, String postBody )
    {
        int otherHeaders = 512;
        int maximumSizeInBytes = config.getInt( ServerSettings.maximum_response_header_size.name() ) - otherHeaders;

        try
        {
            Map<String, Object> entityBody;
            Pair<IndexedEntityRepresentation, Boolean> result;

            switch ( unique( unique, uniqueness ) )
            {
                case GetOrCreate:
                    entityBody = input.readMap( postBody, "key", "value" );

                    String getOrCreateValue = String.valueOf( entityBody.get( "value" ) );
                    if ( getOrCreateValue.length() > maximumSizeInBytes )
                    {
                        return valueTooBig();
                    }

                    result = actions.getOrCreateIndexedNode( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            getOrCreateValue, extractNodeIdOrNull( getStringOrNull(
                            entityBody, "uri" ) ), getMapOrNull( entityBody, "properties" ) );
                    return result.other() ? output.created( result.first() )
                                          : output.okIncludeLocation( result.first() );

                case CreateOrFail:
                    entityBody = input.readMap( postBody, "key", "value" );

                    String createOrFailValue = String.valueOf( entityBody.get( "value" ) );
                    if ( createOrFailValue.length() > maximumSizeInBytes )
                    {
                        return valueTooBig();
                    }

                    result = actions.getOrCreateIndexedNode( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            createOrFailValue, extractNodeIdOrNull( getStringOrNull(
                            entityBody, "uri" ) ), getMapOrNull( entityBody, "properties" ) );
                    if ( result.other() )
                    {
                        return output.created( result.first() );
                    }

                    String uri = getStringOrNull( entityBody, "uri" );

                    if ( uri == null )
                    {
                        return output.conflict( result.first() );
                    }

                    long idOfNodeToBeIndexed = extractNodeId( uri );
                    long idOfNodeAlreadyInIndex = extractNodeId( result.first().getIdentity() );

                    if ( idOfNodeToBeIndexed == idOfNodeAlreadyInIndex )
                    {
                        return output.created( result.first() );
                    }

                    return output.conflict( result.first() );

                default:
                    entityBody = input.readMap( postBody, "key", "value", "uri" );
                    String value = String.valueOf( entityBody.get( "value" ) );

                    if ( value.length() > maximumSizeInBytes )
                    {
                        return valueTooBig();
                    }

                    return output.created( actions.addToNodeIndex( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            value, extractNodeId( entityBody.get( "uri" )
                            .toString() ) ) );

            }
        }
        catch ( UnsupportedOperationException e )
        {
            return output.methodNotAllowed( e );
        }
        catch ( IllegalArgumentException | BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( Exception e )
        {
            return output.serverError( e );
        }
    }

    @POST
    @Path( PATH_NAMED_NODE_INDEX )
    @Consumes( MediaType.APPLICATION_JSON )
    public Response addToNodeIndex( @PathParam( "indexName" ) String indexName, @QueryParam( "unique" ) String unique,
                                    @QueryParam( "uniqueness" ) String uniqueness, String postBody )
    {
        int otherHeaders = 512;
        int maximumSizeInBytes = config.getInt( ServerSettings.maximum_response_header_size.name() ) - otherHeaders;

        try
        {
            Map<String, Object> entityBody;
            Pair<IndexedEntityRepresentation, Boolean> result;

            switch ( unique( unique, uniqueness ) )
            {
                case GetOrCreate:
                    entityBody = input.readMap( postBody, "key", "value" );

                    String getOrCreateValue = String.valueOf( entityBody.get( "value" ) );
                    if ( getOrCreateValue.length() > maximumSizeInBytes )
                    {
                        return valueTooBig();
                    }

                    result = actions.getOrCreateIndexedNode( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            getOrCreateValue, extractNodeIdOrNull( getStringOrNull(
                            entityBody, "uri" ) ), getMapOrNull( entityBody, "properties" ) );
                    return result.other() ? output.created( result.first() )
                                          : output.okIncludeLocation( result.first() );

                case CreateOrFail:
                    entityBody = input.readMap( postBody, "key", "value" );

                    String createOrFailValue = String.valueOf( entityBody.get( "value" ) );
                    if ( createOrFailValue.length() > maximumSizeInBytes )
                    {
                        return valueTooBig();
                    }

                    result = actions.getOrCreateIndexedNode( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            createOrFailValue, extractNodeIdOrNull( getStringOrNull(
                            entityBody, "uri" ) ), getMapOrNull( entityBody, "properties" ) );
                    if ( result.other() )
                    {
                        return output.created( result.first() );
                    }

                    String uri = getStringOrNull( entityBody, "uri" );

                    if ( uri == null )
                    {
                        return output.conflict( result.first() );
                    }

                    long idOfNodeToBeIndexed = extractNodeId( uri );
                    long idOfNodeAlreadyInIndex = extractNodeId( result.first().getIdentity() );

                    if ( idOfNodeToBeIndexed == idOfNodeAlreadyInIndex )
                    {
                        return output.created( result.first() );
                    }

                    return output.conflict( result.first() );

                default:
                    entityBody = input.readMap( postBody, "key", "value", "uri" );
                    String value = String.valueOf( entityBody.get( "value" ) );

                    if ( value.length() > maximumSizeInBytes )
                    {
                        return valueTooBig();
                    }

                    return output.created( actions.addToNodeIndex( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            value, extractNodeId( entityBody.get( "uri" )
                            .toString() ) ) );

            }
        }
        catch ( UnsupportedOperationException e )
        {
            return output.methodNotAllowed( e );
        }
        catch ( IllegalArgumentException e )
        {
            return output.badRequest( e );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( Exception e )
        {
            return output.serverError( e );
        }
    }

Merge Catch [catch(IllegalArgumentException e), catch(BadInputException e)] to catch(IllegalArgumentException|BadInputException e) in method public addToNodeIndex(indexName String, unique String, uniqueness String, postBody String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_NAMED_RELATIONSHIP_INDEX )
    public Response addToRelationshipIndex( @PathParam( "indexName" ) String indexName,
                                            @QueryParam( "unique" ) String unique,
                                            @QueryParam( "uniqueness" ) String uniqueness, String postBody )
    {
        try
        {
            Map<String, Object> entityBody;
            Pair<IndexedEntityRepresentation, Boolean> result;

            switch ( unique( unique, uniqueness ) )
            {
                case GetOrCreate:
                    entityBody = input.readMap( postBody, "key", "value" );
                    result = actions.getOrCreateIndexedRelationship( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            String.valueOf( entityBody.get( "value" ) ),
                            extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ),
                            extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ),
                            getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody,
                            "end" ) ),
                            getMapOrNull( entityBody, "properties" ) );
                    return result.other() ? output.created( result.first() ) : output.ok( result.first() );

                case CreateOrFail:
                    entityBody = input.readMap( postBody, "key", "value" );
                    result = actions.getOrCreateIndexedRelationship( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            String.valueOf( entityBody.get( "value" ) ),
                            extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ),
                            extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ),
                            getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody,
                            "end" ) ),
                            getMapOrNull( entityBody, "properties" ) );
                    if ( result.other() )
                    {
                        return output.created( result.first() );
                    }

                    String uri = getStringOrNull( entityBody, "uri" );

                    if ( uri == null )
                    {
                        return output.conflict( result.first() );
                    }

                    long idOfRelationshipToBeIndexed = extractRelationshipId( uri );
                    long idOfRelationshipAlreadyInIndex = extractRelationshipId( result.first().getIdentity() );

                    if ( idOfRelationshipToBeIndexed == idOfRelationshipAlreadyInIndex )
                    {
                        return output.created( result.first() );
                    }

                    return output.conflict( result.first() );

                default:
                    entityBody = input.readMap( postBody, "key", "value", "uri" );
                    return output.created( actions.addToRelationshipIndex( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            String.valueOf( entityBody.get( "value" ) ), extractRelationshipId( entityBody.get( "uri"
                    ).toString() ) ) );

            }
        }
        catch ( UnsupportedOperationException e )
        {
            return output.methodNotAllowed( e );
        }
        catch ( IllegalArgumentException | BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( Exception e )
        {
            return output.serverError( e );
        }
    }

    @POST
    @Path( PATH_NAMED_RELATIONSHIP_INDEX )
    public Response addToRelationshipIndex( @PathParam( "indexName" ) String indexName,
                                            @QueryParam( "unique" ) String unique,
                                            @QueryParam( "uniqueness" ) String uniqueness, String postBody )
    {
        try
        {
            Map<String, Object> entityBody;
            Pair<IndexedEntityRepresentation, Boolean> result;

            switch ( unique( unique, uniqueness ) )
            {
                case GetOrCreate:
                    entityBody = input.readMap( postBody, "key", "value" );
                    result = actions.getOrCreateIndexedRelationship( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            String.valueOf( entityBody.get( "value" ) ),
                            extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ),
                            extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ),
                            getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody,
                            "end" ) ),
                            getMapOrNull( entityBody, "properties" ) );
                    return result.other() ? output.created( result.first() ) : output.ok( result.first() );

                case CreateOrFail:
                    entityBody = input.readMap( postBody, "key", "value" );
                    result = actions.getOrCreateIndexedRelationship( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            String.valueOf( entityBody.get( "value" ) ),
                            extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ),
                            extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ),
                            getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody,
                            "end" ) ),
                            getMapOrNull( entityBody, "properties" ) );
                    if ( result.other() )
                    {
                        return output.created( result.first() );
                    }

                    String uri = getStringOrNull( entityBody, "uri" );

                    if ( uri == null )
                    {
                        return output.conflict( result.first() );
                    }

                    long idOfRelationshipToBeIndexed = extractRelationshipId( uri );
                    long idOfRelationshipAlreadyInIndex = extractRelationshipId( result.first().getIdentity() );

                    if ( idOfRelationshipToBeIndexed == idOfRelationshipAlreadyInIndex )
                    {
                        return output.created( result.first() );
                    }

                    return output.conflict( result.first() );

                default:
                    entityBody = input.readMap( postBody, "key", "value", "uri" );
                    return output.created( actions.addToRelationshipIndex( indexName,
                            String.valueOf( entityBody.get( "key" ) ),
                            String.valueOf( entityBody.get( "value" ) ), extractRelationshipId( entityBody.get( "uri"
                    ).toString() ) ) );

            }
        }
        catch ( UnsupportedOperationException e )
        {
            return output.methodNotAllowed( e );
        }
        catch ( IllegalArgumentException e )
        {
            return output.badRequest( e );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( Exception e )
        {
            return output.serverError( e );
        }
    }

Merge Catch [catch(IllegalArgumentException e), catch(BadInputException e)] to catch(IllegalArgumentException|BadInputException e) in method public addToRelationshipIndex(indexName String, unique String, uniqueness String, postBody String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_NODE_TRAVERSE )
    public Response traverse( @PathParam( "nodeId" ) long startNode,
                              @PathParam( "returnType" ) TraverserReturnType returnType, String body )
    {
        try
        {
            return output.ok( actions.traverse( startNode, input.readMap( body ), returnType ) );
        }
        catch ( EvaluationException | BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( NotFoundException e )
        {
            return output.notFound( e );
        }
    }

    @POST
    @Path( PATH_NODE_TRAVERSE )
    public Response traverse( @PathParam( "nodeId" ) long startNode,
                              @PathParam( "returnType" ) TraverserReturnType returnType, String body )
    {
        try
        {
            return output.ok( actions.traverse( startNode, input.readMap( body ), returnType ) );
        }
        catch ( EvaluationException e )
        {
            return output.badRequest( e );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( NotFoundException e )
        {
            return output.notFound( e );
        }
    }

Merge Catch [catch(EvaluationException e), catch(BadInputException e)] to catch(EvaluationException|BadInputException e) in method public traverse(startNode long, returnType TraverserReturnType, body String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_TO_CREATE_PAGED_TRAVERSERS )
    public Response createPagedTraverser( @PathParam( "nodeId" ) long startNode,
            @PathParam( "returnType" ) TraverserReturnType returnType,
            @QueryParam( "pageSize" ) @DefaultValue( FIFTY_ENTRIES ) int pageSize,
            @QueryParam( "leaseTime" ) @DefaultValue( SIXTY_SECONDS ) int leaseTimeInSeconds, String body )
    {
        try
        {
            validatePageSize( pageSize );
            validateLeaseTime( leaseTimeInSeconds );

            String traverserId = actions.createPagedTraverser( startNode, input.readMap( body ), pageSize,
                    leaseTimeInSeconds );

            URI uri = new URI( "node/" + startNode + "/paged/traverse/" + returnType + "/" + traverserId );

            return output.created( new ListEntityRepresentation( actions.pagedTraverse( traverserId, returnType ),
                    uri.normalize() ) );
        }
        catch ( EvaluationException | BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( NotFoundException e )
        {
            return output.notFound( e );
        }
        catch ( URISyntaxException e )
        {
            return output.serverError( e );
        }
    }

    @POST
    @Path( PATH_TO_CREATE_PAGED_TRAVERSERS )
    public Response createPagedTraverser( @PathParam( "nodeId" ) long startNode,
            @PathParam( "returnType" ) TraverserReturnType returnType,
            @QueryParam( "pageSize" ) @DefaultValue( FIFTY_ENTRIES ) int pageSize,
            @QueryParam( "leaseTime" ) @DefaultValue( SIXTY_SECONDS ) int leaseTimeInSeconds, String body )
    {
        try
        {
            validatePageSize( pageSize );
            validateLeaseTime( leaseTimeInSeconds );

            String traverserId = actions.createPagedTraverser( startNode, input.readMap( body ), pageSize,
                    leaseTimeInSeconds );

            URI uri = new URI( "node/" + startNode + "/paged/traverse/" + returnType + "/" + traverserId );

            return output.created( new ListEntityRepresentation( actions.pagedTraverse( traverserId, returnType ),
                    uri.normalize() ) );
        }
        catch ( EvaluationException e )
        {
            return output.badRequest( e );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( NotFoundException e )
        {
            return output.notFound( e );
        }
        catch ( URISyntaxException e )
        {
            return output.serverError( e );
        }
    }

Merge Catch [catch(EvaluationException e), catch(BadInputException e)] to catch(EvaluationException|BadInputException e) in method public createPagedTraverser(startNode long, returnType TraverserReturnType, pageSize int, leaseTimeInSeconds int, body String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_NODE_PATH )
    public Response singlePath( @PathParam( "nodeId" ) long startNode, String body )
    {
        final Map<String, Object> description;
        final long endNode;
        try
        {
            description = input.readMap( body );
            endNode = extractNodeId( (String) description.get( "to" ) );
            return output.ok( actions.findSinglePath( startNode, endNode, description ) );
        }
        catch ( BadInputException | ClassCastException e )
        {
            return output.badRequest( e );
        }
        catch ( NotFoundException e )
        {
            return output.notFound( e );
        }

    }

    @POST
    @Path( PATH_NODE_PATH )
    public Response singlePath( @PathParam( "nodeId" ) long startNode, String body )
    {
        final Map<String, Object> description;
        final long endNode;
        try
        {
            description = input.readMap( body );
            endNode = extractNodeId( (String) description.get( "to" ) );
            return output.ok( actions.findSinglePath( startNode, endNode, description ) );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( ClassCastException e )
        {
            return output.badRequest( e );
        }
        catch ( NotFoundException e )
        {
            return output.notFound( e );
        }

    }

Merge Catch [catch(BadInputException e), catch(ClassCastException e)] to catch(BadInputException|ClassCastException e) in method public singlePath(startNode long, body String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_NODE_PATHS )
    public Response allPaths( @PathParam( "nodeId" ) long startNode, String body )
    {
        final Map<String, Object> description;
        final long endNode;
        try
        {
            description = input.readMap( body );
            endNode = extractNodeId( (String) description.get( "to" ) );
            return output.ok( actions.findPaths( startNode, endNode, description ) );
        }
        catch ( BadInputException | ClassCastException e )
        {
            return output.badRequest( e );
        }
    }

    @POST
    @Path( PATH_NODE_PATHS )
    public Response allPaths( @PathParam( "nodeId" ) long startNode, String body )
    {
        final Map<String, Object> description;
        final long endNode;
        try
        {
            description = input.readMap( body );
            endNode = extractNodeId( (String) description.get( "to" ) );
            return output.ok( actions.findPaths( startNode, endNode, description ) );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( ClassCastException e )
        {
            return output.badRequest( e );
        }
    }

Merge Catch [catch(BadInputException e), catch(ClassCastException e)] to catch(BadInputException|ClassCastException e) in method public allPaths(startNode long, body String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_SCHEMA_INDEX_LABEL )
    public Response createSchemaIndex( @PathParam( "label" ) String labelName, String body )
    {
        try
        {
            Map<String, Object> data = input.readMap( body, "property_keys" );
            Iterable<String> singlePropertyKey = singleOrList( data, "property_keys" );
            if ( singlePropertyKey == null )
            {
                return output.badRequest( new IllegalArgumentException(
                        "Supply single property key or list of property keys" ) );
            }
            return output.ok( actions.createSchemaIndex( labelName, singlePropertyKey ) );
        }
        catch ( UnsupportedOperationException | BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( org.neo4j.graphdb.ConstraintViolationException e )
        {
            return output.conflict( e );
        }
    }

    @POST
    @Path( PATH_SCHEMA_INDEX_LABEL )
    public Response createSchemaIndex( @PathParam( "label" ) String labelName, String body )
    {
        try
        {
            Map<String, Object> data = input.readMap( body, "property_keys" );
            Iterable<String> singlePropertyKey = singleOrList( data, "property_keys" );
            if ( singlePropertyKey == null )
            {
                return output.badRequest( new IllegalArgumentException(
                        "Supply single property key or list of property keys" ) );
            }
            return output.ok( actions.createSchemaIndex( labelName, singlePropertyKey ) );
        }
        catch ( UnsupportedOperationException e )
        {
            return output.badRequest( e );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( org.neo4j.graphdb.ConstraintViolationException e )
        {
            return output.conflict( e );
        }
    }

Merge Catch [catch(UnsupportedOperationException e), catch(BadInputException e)] to catch(UnsupportedOperationException|BadInputException e) in method public createSchemaIndex(labelName String, body String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    @POST
    @Path( PATH_SCHEMA_CONSTRAINT_LABEL_UNIQUENESS )
    public Response createPropertyUniquenessConstraint( @PathParam( "label" ) String labelName, String body )
    {
        try
        {
            Map<String, Object> data = input.readMap( body, "property_keys" );
            Iterable<String> singlePropertyKey = singleOrList( data, "property_keys" );
            if ( singlePropertyKey == null )
            {
                return output.badRequest( new IllegalArgumentException(
                        "Supply single property key or list of property keys" ) );
            }
            return output.ok( actions.createPropertyUniquenessConstraint( labelName, singlePropertyKey ) );
        }
        catch ( UnsupportedOperationException | BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( org.neo4j.graphdb.ConstraintViolationException e )
        {
            return output.conflict( e );
        }
    }

    @POST
    @Path( PATH_SCHEMA_CONSTRAINT_LABEL_UNIQUENESS )
    public Response createPropertyUniquenessConstraint( @PathParam( "label" ) String labelName, String body )
    {
        try
        {
            Map<String, Object> data = input.readMap( body, "property_keys" );
            Iterable<String> singlePropertyKey = singleOrList( data, "property_keys" );
            if ( singlePropertyKey == null )
            {
                return output.badRequest( new IllegalArgumentException(
                        "Supply single property key or list of property keys" ) );
            }
            return output.ok( actions.createPropertyUniquenessConstraint( labelName, singlePropertyKey ) );
        }
        catch ( UnsupportedOperationException e )
        {
            return output.badRequest( e );
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( org.neo4j.graphdb.ConstraintViolationException e )
        {
            return output.conflict( e );
        }
    }

Merge Catch [catch(UnsupportedOperationException e), catch(BadInputException e)] to catch(UnsupportedOperationException|BadInputException e) in method public createPropertyUniquenessConstraint(labelName String, body String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    public static Set<String> getWhiteList()
    {
        HashSet<String> safe = new HashSet<>();

        // Core API concepts

        safe.add( Path.class.getName() );
        safe.add( Node.class.getName() );
        safe.add( Relationship.class.getName() );
        safe.add( RelationshipType.class.getName() );
        // can't list anonymous inner classes, using instance to get name of its class
        safe.add( RelationshipType.withName( "classSource" ).getClass().getName() );
        safe.add( DynamicRelationshipType.class.getName() );
        safe.add( Lock.class.getName() );

        safe.add( NotFoundException.class.getName() );

        // Traversal concepts

        safe.add( Direction.class.getName() );
        safe.add( Evaluation.class.getName() );

        // Java Core API

        safe.add( Object.class.getName() );
        safe.add( String.class.getName() );
        safe.add( Integer.class.getName() );
        safe.add( Long.class.getName() );
        safe.add( Float.class.getName() );
        safe.add( Double.class.getName() );
        safe.add( Boolean.class.getName() );

        // This is a work-around, since these are not supposed to be publicly available.
        // The reason we need to add it here is, most likely, that some methods in the API
        // returns these rather than the corresponding interfaces, which means our white list
        // checker doesn't know which interface to cast to (since there could be several). Instead
        // we allow users direct access to these classes for now.
        safe.add( "org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch" );
        safe.add( "org.neo4j.kernel.impl.traversal.TraversalBranchImpl" );
        safe.add( "org.neo4j.kernel.impl.core.NodeProxy" );

        return safe;
    }

    public static Set<String> getWhiteList()
    {
        HashSet<String> safe = new HashSet<String>();

        // Core API concepts

        safe.add( Path.class.getName() );
        safe.add( Node.class.getName() );
        safe.add( Relationship.class.getName() );
        safe.add( RelationshipType.class.getName() );
        // can't list anonymous inner classes, using instance to get name of its class
        safe.add( RelationshipType.withName( "classSource" ).getClass().getName() );
        safe.add( DynamicRelationshipType.class.getName() );
        safe.add( Lock.class.getName() );

        safe.add( NotFoundException.class.getName() );

        // Traversal concepts

        safe.add( Direction.class.getName() );
        safe.add( Evaluation.class.getName() );

        // Java Core API

        safe.add( Object.class.getName() );
        safe.add( String.class.getName() );
        safe.add( Integer.class.getName() );
        safe.add( Long.class.getName() );
        safe.add( Float.class.getName() );
        safe.add( Double.class.getName() );
        safe.add( Boolean.class.getName() );

        // This is a work-around, since these are not supposed to be publicly available.
        // The reason we need to add it here is, most likely, that some methods in the API
        // returns these rather than the corresponding interfaces, which means our white list
        // checker doesn't know which interface to cast to (since there could be several). Instead
        // we allow users direct access to these classes for now.
        safe.add( "org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch" );
        safe.add( "org.neo4j.kernel.impl.traversal.TraversalBranchImpl" );
        safe.add( "org.neo4j.kernel.impl.core.NodeProxy" );

        return safe;
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public getWhiteList() : Set<String> from class org.neo4j.server.scripting.UserScriptClassWhiteList


    public static MediaType mediaTypeWithCharsetUtf8( MediaType mediaType )
    {
        Map<String,String> parameters = mediaType.getParameters();
        if ( parameters.isEmpty() )
        {
            return new MediaType( mediaType.getType(), mediaType.getSubtype(), CHARSET );
        }
        if ( parameters.containsKey( "charset" ) )
        {
            return mediaType;
        }
        Map<String,String> paramsWithCharset = new HashMap<>( parameters );
        paramsWithCharset.putAll( CHARSET );
        return new MediaType( mediaType.getType(), mediaType.getSubtype(), paramsWithCharset );
    }

    public static MediaType mediaTypeWithCharsetUtf8( MediaType mediaType )
    {
        Map<String,String> parameters = mediaType.getParameters();
        if ( parameters.isEmpty() )
        {
            return new MediaType( mediaType.getType(), mediaType.getSubtype(), CHARSET );
        }
        if ( parameters.containsKey( "charset" ) )
        {
            return mediaType;
        }
        Map<String,String> paramsWithCharset = new HashMap<String,String>( parameters );
        paramsWithCharset.putAll( CHARSET );
        return new MediaType( mediaType.getType(), mediaType.getSubtype(), paramsWithCharset );
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public mediaTypeWithCharsetUtf8(mediaType MediaType) : MediaType from class org.neo4j.server.web.HttpHeaderUtils


    private Collection<InjectableProvider<?>> mergeInjectables( Collection<InjectableProvider<?>> defaultInjectables,
            Collection<Injectable<?>> injectables )
    {
        Collection<InjectableProvider<?>> injectableProviders = new ArrayList<>();
        if ( defaultInjectables != null )
        {
            injectableProviders.addAll( defaultInjectables );
        }
        if ( injectables != null )
        {
            for ( Injectable<?> injectable : injectables )
            {
                injectableProviders.add( new InjectableWrapper( injectable ) );
            }
        }
        return injectableProviders;
    }

    private Collection<InjectableProvider<?>> mergeInjectables( Collection<InjectableProvider<?>> defaultInjectables,
            Collection<Injectable<?>> injectables )
    {
        Collection<InjectableProvider<?>> injectableProviders = new ArrayList<InjectableProvider<?>>();
        if ( defaultInjectables != null )
        {
            injectableProviders.addAll( defaultInjectables );
        }
        if ( injectables != null )
        {
            for ( Injectable<?> injectable : injectables )
            {
                injectableProviders.add( new InjectableWrapper( injectable ) );
            }
        }
        return injectableProviders;
    }

Replace Generic With Diamond ArrayList<InjectableProvider<?>> with ArrayList<> in method private mergeInjectables(defaultInjectables Collection<InjectableProvider<?>>, injectables Collection<Injectable<?>>) : Collection<InjectableProvider<?>> from class org.neo4j.server.web.JaxRsServletHolderFactory


    public Map<String, Object> removeAnyAutoIndex( Map<String, Object> map )
    {
        Map<String, Object> result = new HashMap<>();
        for ( Map.Entry<String, Object> entry : map.entrySet() )
        {
            Map<?, ?> innerMap = (Map<?,?>) entry.getValue();
            String template = innerMap.get( "template" ).toString();
            if ( !template.contains( PATH_AUTO_INDEX.replace("{type}", RestfulGraphDatabase.NODE_AUTO_INDEX_TYPE) ) &&
                 !template.contains( PATH_AUTO_INDEX.replace("{type}", RestfulGraphDatabase.RELATIONSHIP_AUTO_INDEX_TYPE) ) &&
                 !template.contains( "_auto_" ) )
            {
                result.put( entry.getKey(), entry.getValue() );
            }
        }
        return result;
    }

    public Map<String, Object> removeAnyAutoIndex( Map<String, Object> map )
    {
        Map<String, Object> result = new HashMap<String, Object>();
        for ( Map.Entry<String, Object> entry : map.entrySet() )
        {
            Map<?, ?> innerMap = (Map<?,?>) entry.getValue();
            String template = innerMap.get( "template" ).toString();
            if ( !template.contains( PATH_AUTO_INDEX.replace("{type}", RestfulGraphDatabase.NODE_AUTO_INDEX_TYPE) ) &&
                 !template.contains( PATH_AUTO_INDEX.replace("{type}", RestfulGraphDatabase.RELATIONSHIP_AUTO_INDEX_TYPE) ) &&
                 !template.contains( "_auto_" ) )
            {
                result.put( entry.getKey(), entry.getValue() );
            }
        }
        return result;
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public removeAnyAutoIndex(map Map<String,Object>) : Map<String,Object> from class org.neo4j.server.helpers.FunctionalTestHelper


    @Test
    public void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception
    {
        // Given
        WebServer webServer = mock( WebServer.class );

        CommunityNeoServer neoServer = mock( CommunityNeoServer.class );
        when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) );
        when( neoServer.getWebServer() ).thenReturn( webServer );
        when( neoServer.getDatabase() ).thenReturn( mock(Database.class));

        Config config = mock( Config.class );
        List<ThirdPartyJaxRsPackage> jaxRsPackages = new ArrayList<>();
        String path = "/third/party/package";
        jaxRsPackages.add( new ThirdPartyJaxRsPackage( "org.example.neo4j", path ) );
        when( config.get( ServerSettings.third_party_packages ) ).thenReturn( jaxRsPackages );

        // When
        ThirdPartyJAXRSModule module =
                new ThirdPartyJAXRSModule( webServer, config, NullLogProvider.getInstance(), neoServer );
        module.start();

        // Then
        verify( webServer ).addJAXRSPackages( any( List.class ), anyString(), anyCollection() );
    }

    @Test
    public void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception
    {
        // Given
        WebServer webServer = mock( WebServer.class );

        CommunityNeoServer neoServer = mock( CommunityNeoServer.class );
        when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) );
        when( neoServer.getWebServer() ).thenReturn( webServer );
        when( neoServer.getDatabase() ).thenReturn( mock(Database.class));

        Config config = mock( Config.class );
        List<ThirdPartyJaxRsPackage> jaxRsPackages = new ArrayList<ThirdPartyJaxRsPackage>();
        String path = "/third/party/package";
        jaxRsPackages.add( new ThirdPartyJaxRsPackage( "org.example.neo4j", path ) );
        when( config.get( ServerSettings.third_party_packages ) ).thenReturn( jaxRsPackages );

        // When
        ThirdPartyJAXRSModule module =
                new ThirdPartyJAXRSModule( webServer, config, NullLogProvider.getInstance(), neoServer );
        module.start();

        // Then
        verify( webServer ).addJAXRSPackages( any( List.class ), anyString(), anyCollection() );
    }

Replace Generic With Diamond ArrayList<ThirdPartyJaxRsPackage> with ArrayList<> in method public shouldReportThirdPartyPackagesAtSpecifiedMount() : void from class org.neo4j.server.modules.ThirdPartyJAXRSModuleTest


    private static void setupTheDatabase()
    {
        long relationship = helper.createRelationship( "LIKES" );
        Map<String, Object> map = new HashMap<>();
        map.put( "foo", "bar" );
        helper.setRelationshipProperties( relationship, map );
        baseRelationshipUri = functionalTestHelper.dataUri() + "relationship/" + relationship + "/properties/";
    }

    private static void setupTheDatabase()
    {
        long relationship = helper.createRelationship( "LIKES" );
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "foo", "bar" );
        helper.setRelationshipProperties( relationship, map );
        baseRelationshipUri = functionalTestHelper.dataUri() + "relationship/" + relationship + "/properties/";
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method private setupTheDatabase() : void from class org.neo4j.server.rest.GetRelationshipPropertiesIT


    @Test
    public void shouldReturn204WhenPropertiesAreRemoved()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<>();
        map.put( "jim", "tobias" );
        helper.setNodeProperties( nodeId, map );
        JaxRsResponse response = removeNodePropertiesOnServer(nodeId);
        assertEquals( 204, response.getStatus() );
        response.close();
    }

    @Test
    public void shouldReturn204WhenPropertiesAreRemoved()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "jim", "tobias" );
        helper.setNodeProperties( nodeId, map );
        JaxRsResponse response = removeNodePropertiesOnServer(nodeId);
        assertEquals( 204, response.getStatus() );
        response.close();
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldReturn204WhenPropertiesAreRemoved() : void from class org.neo4j.server.rest.RemoveNodePropertiesIT


    @Documented( "Delete all properties from node." )
    @Test
    public void shouldReturn204WhenAllPropertiesAreRemoved()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<>();
        map.put( "jim", "tobias" );
        helper.setNodeProperties( nodeId, map );
        gen.get().expectedStatus( 204 )
                .delete( functionalTestHelper.nodePropertiesUri( nodeId ) );
    }

    @Documented( "Delete all properties from node." )
    @Test
    public void shouldReturn204WhenAllPropertiesAreRemoved()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "jim", "tobias" );
        helper.setNodeProperties( nodeId, map );
        gen.get().expectedStatus( 204 )
                .delete( functionalTestHelper.nodePropertiesUri( nodeId ) );
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldReturn204WhenAllPropertiesAreRemoved() : void from class org.neo4j.server.rest.RemoveNodePropertiesIT


    @Documented( "To delete a single property\n" +
                 "from a node, see the example below" )
    @Test
    public void delete_a_named_property_from_a_node()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<>();
        map.put( "name", "tobias" );
        helper.setNodeProperties( nodeId, map );
        gen.get()
        .expectedStatus( 204 )
        .delete( functionalTestHelper.nodePropertyUri( nodeId, "name") );
    }

    @Documented( "To delete a single property\n" +
                 "from a node, see the example below" )
    @Test
    public void delete_a_named_property_from_a_node()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "name", "tobias" );
        helper.setNodeProperties( nodeId, map );
        gen.get()
        .expectedStatus( 204 )
        .delete( functionalTestHelper.nodePropertyUri( nodeId, "name") );
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public delete_a_named_property_from_a_node() : void from class org.neo4j.server.rest.RemoveNodePropertiesIT


    @Test
    public void shouldReturn404WhenRemovingNonExistingNodeProperty()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<>();
        map.put( "jim", "tobias" );
        helper.setNodeProperties( nodeId, map );
        JaxRsResponse response = removeNodePropertyOnServer(nodeId, "foo");
        assertEquals(404, response.getStatus());
    }

    @Test
    public void shouldReturn404WhenRemovingNonExistingNodeProperty()
    {
        long nodeId = helper.createNode();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "jim", "tobias" );
        helper.setNodeProperties( nodeId, map );
        JaxRsResponse response = removeNodePropertyOnServer(nodeId, "foo");
        assertEquals(404, response.getStatus());
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldReturn404WhenRemovingNonExistingNodeProperty() : void from class org.neo4j.server.rest.RemoveNodePropertiesIT


    @Test
    @Graph( "jim knows joe" )
    public void shouldReturn400WhenSendinIncompatibleJsonProperties()
            throws JsonParseException
    {
        Map<String, Object> map = new HashMap<>();
        map.put( "jim", new HashMap<String, Object>() );
        gen.get().payload( JsonHelper.createJsonFrom( map ) ).expectedStatus(
                400 ).put( getPropertiesUri( data.get().get( "jim" ) ) );
    }

    @Test
    @Graph( "jim knows joe" )
    public void shouldReturn400WhenSendinIncompatibleJsonProperties()
            throws JsonParseException
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "jim", new HashMap<String, Object>() );
        gen.get().payload( JsonHelper.createJsonFrom( map ) ).expectedStatus(
                400 ).put( getPropertiesUri( data.get().get( "jim" ) ) );
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldReturn400WhenSendinIncompatibleJsonProperties() : void from class org.neo4j.server.rest.SetNodePropertiesIT


    @Documented( "Update relationship properties." )
    @Test
    @Graph
    public void shouldReturn204WhenPropertiesAreUpdated() throws JsonParseException
    {
        data.get();
        Map<String, Object> map = new HashMap<>();
        map.put( "jim", "tobias" );
        gen.get().payload( JsonHelper.createJsonFrom( map ) )
                .expectedStatus( 204 )
                .put( propertiesUri.toString() );
        JaxRsResponse response = updatePropertiesOnServer(map);
        assertEquals( 204, response.getStatus() );
        response.close();
    }

    @Documented( "Update relationship properties." )
    @Test
    @Graph
    public void shouldReturn204WhenPropertiesAreUpdated() throws JsonParseException
    {
        data.get();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "jim", "tobias" );
        gen.get().payload( JsonHelper.createJsonFrom( map ) )
                .expectedStatus( 204 )
                .put( propertiesUri.toString() );
        JaxRsResponse response = updatePropertiesOnServer(map);
        assertEquals( 204, response.getStatus() );
        response.close();
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldReturn204WhenPropertiesAreUpdated() : void from class org.neo4j.server.rest.SetRelationshipPropertiesIT


    @Test
    public void shouldReturn400WhenSendinIncompatibleJsonProperties() throws JsonParseException
    {
        Map<String, Object> map = new HashMap<>();
        map.put( "jim", new HashMap<String, Object>() );
        JaxRsResponse response = updatePropertiesOnServer(map);
        assertEquals( 400, response.getStatus() );
        response.close();
    }

    @Test
    public void shouldReturn400WhenSendinIncompatibleJsonProperties() throws JsonParseException
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "jim", new HashMap<String, Object>() );
        JaxRsResponse response = updatePropertiesOnServer(map);
        assertEquals( 400, response.getStatus() );
        response.close();
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldReturn400WhenSendinIncompatibleJsonProperties() : void from class org.neo4j.server.rest.SetRelationshipPropertiesIT


    @Test
    public void shouldReturn404WhenPropertiesSentToANodeWhichDoesNotExist() throws JsonParseException
    {
        Map<String, Object> map = new HashMap<>();
        map.put("jim", "tobias");

        JaxRsResponse response = RestRequest.req().put(badUri.toString(), JsonHelper.createJsonFrom(map));
        assertEquals(404, response.getStatus());
        response.close();
    }

    @Test
    public void shouldReturn404WhenPropertiesSentToANodeWhichDoesNotExist() throws JsonParseException
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("jim", "tobias");

        JaxRsResponse response = RestRequest.req().put(badUri.toString(), JsonHelper.createJsonFrom(map));
        assertEquals(404, response.getStatus());
        response.close();
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldReturn404WhenPropertiesSentToANodeWhichDoesNotExist() : void from class org.neo4j.server.rest.SetRelationshipPropertiesIT


    @Test
    public void shouldNotFailSettingEmptyArrayIfEntityAlreadyHasAnEmptyArrayAsValue() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", new String[]{} );

        // When
        propSetter.setProperty( node, "arr", new ArrayList<>() );

        // Then
        assertThat( node.getProperty( "arr" ), is(new String[]{}));
    }

    @Test
    public void shouldNotFailSettingEmptyArrayIfEntityAlreadyHasAnEmptyArrayAsValue() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", new String[]{} );

        // When
        propSetter.setProperty( node, "arr", new ArrayList<Object>() );

        // Then
        assertThat( node.getProperty( "arr" ), is(new String[]{}));
    }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public shouldNotFailSettingEmptyArrayIfEntityAlreadyHasAnEmptyArrayAsValue() : void from class org.neo4j.server.rest.domain.PropertySettingStrategyTest


    @Test
    public void shouldNotFailSettingEmptyArrayAndOtherValuesIfEntityAlreadyHasAnEmptyArrayAsValue() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", new String[]{} );

        Map<String, Object> props = new HashMap<>();
        props.put( "name", "bob" );
        props.put( "arr", new ArrayList<String>(  ) );

        // When
        propSetter.setProperties( node, props );

        // Then
        assertThat( node.getProperty( "name" ), is("bob"));
        assertThat( node.getProperty( "arr" ), is(new String[]{}));
    }

    @Test
    public void shouldNotFailSettingEmptyArrayAndOtherValuesIfEntityAlreadyHasAnEmptyArrayAsValue() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", new String[]{} );

        Map<String, Object> props = new HashMap<String, Object>();
        props.put( "name", "bob" );
        props.put( "arr", new ArrayList<String>(  ) );

        // When
        propSetter.setProperties( node, props );

        // Then
        assertThat( node.getProperty( "name" ), is("bob"));
        assertThat( node.getProperty( "arr" ), is(new String[]{}));
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldNotFailSettingEmptyArrayAndOtherValuesIfEntityAlreadyHasAnEmptyArrayAsValue() : void from class org.neo4j.server.rest.domain.PropertySettingStrategyTest


    @Test( expected = PropertyValueException.class )
    public void shouldThrowPropertyErrorWhenSettingEmptyArrayOnEntityWithNoPreExistingProperty() throws Exception
    {
        // Given
        Node node = db.createNode();

        // When
        propSetter.setProperty( node, "arr", new ArrayList<>() );
    }

    @Test( expected = PropertyValueException.class )
    public void shouldThrowPropertyErrorWhenSettingEmptyArrayOnEntityWithNoPreExistingProperty() throws Exception
    {
        // Given
        Node node = db.createNode();

        // When
        propSetter.setProperty( node, "arr", new ArrayList<Object>() );
    }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public shouldThrowPropertyErrorWhenSettingEmptyArrayOnEntityWithNoPreExistingProperty() : void from class org.neo4j.server.rest.domain.PropertySettingStrategyTest


    @Test( expected = PropertyValueException.class )
    public void shouldThrowPropertyErrorWhenSettingEmptyArrayOnEntityWithNoPreExistingEmptyArray() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", "hello" );

        // When
        propSetter.setProperty( node, "arr", new ArrayList<>() );
    }

    @Test( expected = PropertyValueException.class )
    public void shouldThrowPropertyErrorWhenSettingEmptyArrayOnEntityWithNoPreExistingEmptyArray() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", "hello" );

        // When
        propSetter.setProperty( node, "arr", new ArrayList<Object>() );
    }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public shouldThrowPropertyErrorWhenSettingEmptyArrayOnEntityWithNoPreExistingEmptyArray() : void from class org.neo4j.server.rest.domain.PropertySettingStrategyTest


    @Test
    public void shouldUseOriginalTypeWhenSettingEmptyArrayIfEntityAlreadyHasACollection() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", new String[]{"a","b"} );

        // When
        propSetter.setProperty( node, "arr", new ArrayList<>() );

        // Then
        assertThat( node.getProperty( "arr" ), is(new String[]{}));
    }

    @Test
    public void shouldUseOriginalTypeWhenSettingEmptyArrayIfEntityAlreadyHasACollection() throws Exception
    {
        // Given
        Node node = db.createNode();
        node.setProperty( "arr", new String[]{"a","b"} );

        // When
        propSetter.setProperty( node, "arr", new ArrayList<Object>() );

        // Then
        assertThat( node.getProperty( "arr" ), is(new String[]{}));
    }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public shouldUseOriginalTypeWhenSettingEmptyArrayIfEntityAlreadyHasACollection() : void from class org.neo4j.server.rest.domain.PropertySettingStrategyTest


    @Test( expected = IllegalArgumentException.class )
    public void throwsIllegalArgumentOnUnknownExpanderType() throws Exception
    {
        // Given
        TraversalDescriptionBuilder builder = new TraversalDescriptionBuilder( true );
        Collection<Map<String,Object>> rels = new ArrayList<>();
        rels.add( map( "type", "blah" ) );

        // When
        builder.from( map(
                "relationships", rels,
                "expander", "Suddenly, a string!" ) );
    }

    @Test( expected = IllegalArgumentException.class )
    public void throwsIllegalArgumentOnUnknownExpanderType() throws Exception
    {
        // Given
        TraversalDescriptionBuilder builder = new TraversalDescriptionBuilder( true );
        Collection<Map<String,Object>> rels = new ArrayList<Map<String, Object>>();
        rels.add( map( "type", "blah" ) );

        // When
        builder.from( map(
                "relationships", rels,
                "expander", "Suddenly, a string!" ) );
    }

Replace Generic With Diamond ArrayList<Map<String,Object>> with ArrayList<> in method public throwsIllegalArgumentOnUnknownExpanderType() : void from class org.neo4j.server.rest.domain.TraversalDescriptionBuilderTest


    @Test( expected = IllegalArgumentException.class )
    public void throwsIllegalArgumentOnNonStringExpanderType() throws Exception
    {
        // Given
        TraversalDescriptionBuilder builder = new TraversalDescriptionBuilder( true );
        Collection<Map<String,Object>> rels = new ArrayList<>();
        rels.add( map( "type", "blah" ) );

        // When
        builder.from( map(
                "relationships", rels,
                "expander", map( ) ) );
    }

    @Test( expected = IllegalArgumentException.class )
    public void throwsIllegalArgumentOnNonStringExpanderType() throws Exception
    {
        // Given
        TraversalDescriptionBuilder builder = new TraversalDescriptionBuilder( true );
        Collection<Map<String,Object>> rels = new ArrayList<Map<String, Object>>();
        rels.add( map( "type", "blah" ) );

        // When
        builder.from( map(
                "relationships", rels,
                "expander", map( ) ) );
    }

Replace Generic With Diamond ArrayList<Map<String,Object>> with ArrayList<> in method public throwsIllegalArgumentOnNonStringExpanderType() : void from class org.neo4j.server.rest.domain.TraversalDescriptionBuilderTest


    @Test
    @SuppressWarnings( "unchecked" )
    public void shouldSerializeProfilingResult() throws Exception
    {
        // Given
        String name = "Kalle";

        ExecutionPlanDescription plan = getMockDescription( name );
        ExecutionPlanDescription childPlan = getMockDescription( "child" );
        when( plan.getChildren() ).thenReturn( asList( childPlan ) );
        when( plan.hasProfilerStatistics() ).thenReturn( true );

        ExecutionPlanDescription.ProfilerStatistics stats = mock( ExecutionPlanDescription.ProfilerStatistics.class );
        when( stats.getDbHits() ).thenReturn( 13L );
        when( stats.getRows() ).thenReturn( 25L );

        when( plan.getProfilerStatistics() ).thenReturn( stats );

        Result result = mock( Result.class );
        when( result.hasNext() ).thenReturn( false );
        when( result.columns() ).thenReturn( new ArrayList<>() );
        when( result.getExecutionPlanDescription() ).thenReturn( plan );

        // When
        Map<String, Object> serialized = serializeToStringThenParseAsToMap( new CypherResultRepresentation( result,
                /*includeStats=*/false, true ) );

        // Then
        Map<String, Object> serializedPlan = (Map<String, Object>) serialized.get( "plan" );
        assertThat( serializedPlan.get( "name" ), equalTo( name ) );
        assertThat( serializedPlan.get( "rows" ), is( 25 ) );
        assertThat( serializedPlan.get( "dbHits" ), is( 13 ) );

        List<Map<String, Object>> children = (List<Map<String, Object>>) serializedPlan.get( "children" );
        assertThat( children.size(), is( 1 ) );

        Map<String, Object> args = (Map<String, Object>) serializedPlan.get( "args" );
        assertThat( args.get( "argumentKey" ), is( "argumentValue" ) );
    }

    @Test
    @SuppressWarnings( "unchecked" )
    public void shouldSerializeProfilingResult() throws Exception
    {
        // Given
        String name = "Kalle";

        ExecutionPlanDescription plan = getMockDescription( name );
        ExecutionPlanDescription childPlan = getMockDescription( "child" );
        when( plan.getChildren() ).thenReturn( asList( childPlan ) );
        when( plan.hasProfilerStatistics() ).thenReturn( true );

        ExecutionPlanDescription.ProfilerStatistics stats = mock( ExecutionPlanDescription.ProfilerStatistics.class );
        when( stats.getDbHits() ).thenReturn( 13L );
        when( stats.getRows() ).thenReturn( 25L );

        when( plan.getProfilerStatistics() ).thenReturn( stats );

        Result result = mock( Result.class );
        when( result.hasNext() ).thenReturn( false );
        when( result.columns() ).thenReturn( new ArrayList<String>() );
        when( result.getExecutionPlanDescription() ).thenReturn( plan );

        // When
        Map<String, Object> serialized = serializeToStringThenParseAsToMap( new CypherResultRepresentation( result,
                /*includeStats=*/false, true ) );

        // Then
        Map<String, Object> serializedPlan = (Map<String, Object>) serialized.get( "plan" );
        assertThat( serializedPlan.get( "name" ), equalTo( name ) );
        assertThat( serializedPlan.get( "rows" ), is( 25 ) );
        assertThat( serializedPlan.get( "dbHits" ), is( 13 ) );

        List<Map<String, Object>> children = (List<Map<String, Object>>) serializedPlan.get( "children" );
        assertThat( children.size(), is( 1 ) );

        Map<String, Object> args = (Map<String, Object>) serializedPlan.get( "args" );
        assertThat( args.get( "argumentKey" ), is( "argumentValue" ) );
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public shouldSerializeProfilingResult() : void from class org.neo4j.server.rest.repr.CypherResultRepresentationTest


    @Test
    @SuppressWarnings( "unchecked" )
    public void shouldNotIncludePlanUnlessAskedFor() throws Exception
    {
        // Given
        Result result = mock( Result.class );
        when( result.hasNext() ).thenReturn( false );
        when( result.columns() ).thenReturn( new ArrayList<>() );

        // When
        Map<String, Object> serialized = serializeToStringThenParseAsToMap( new CypherResultRepresentation( result,
                /*includeStats=*/false, false ) );

        // Then
        assertFalse( "Didn't expect to see a plan here", serialized.containsKey( "plan" ) );
    }

    @Test
    @SuppressWarnings( "unchecked" )
    public void shouldNotIncludePlanUnlessAskedFor() throws Exception
    {
        // Given
        Result result = mock( Result.class );
        when( result.hasNext() ).thenReturn( false );
        when( result.columns() ).thenReturn( new ArrayList<String>() );

        // When
        Map<String, Object> serialized = serializeToStringThenParseAsToMap( new CypherResultRepresentation( result,
                /*includeStats=*/false, false ) );

        // Then
        assertFalse( "Didn't expect to see a plan here", serialized.containsKey( "plan" ) );
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public shouldNotIncludePlanUnlessAskedFor() : void from class org.neo4j.server.rest.repr.CypherResultRepresentationTest


    private PathRepresentation<Path> pathrep()
    {
        Node a = node( 0, properties() );
        Node b = node( 1, properties() );
        Node c = node( 2, properties() );
        Node d = node( 3, properties() );

        Relationship ab = relationship( 17, a, "LOVES", b );
        Relationship cb = relationship( 18, c, "HATES", b );
        Relationship cd = relationship( 19, c, "KNOWS", d );

        return new PathRepresentation<>( path( a, link( ab, b ), link( cb, c ), link( cd, d ) ) );
    }

    private PathRepresentation<Path> pathrep()
    {
        Node a = node( 0, properties() );
        Node b = node( 1, properties() );
        Node c = node( 2, properties() );
        Node d = node( 3, properties() );

        Relationship ab = relationship( 17, a, "LOVES", b );
        Relationship cb = relationship( 18, c, "HATES", b );
        Relationship cd = relationship( 19, c, "KNOWS", d );

        return new PathRepresentation<Path>( path( a, link( ab, b ), link( cb, c ), link( cd, d ) ) );
    }

Replace Generic With Diamond PathRepresentation<Path> with PathRepresentation<> in method private pathrep() : PathRepresentation<Path> from class org.neo4j.server.rest.repr.PathRepresentationTest


    @Test
    public void shouldContainAddedPropertiesWhenCreatedFromPropertyContainer()
    {
        Map<String, Object> values = new HashMap<>();
        values.put( "foo", "bar" );
        Map<String, Object> serialized = serialize( new PropertiesRepresentation( container( values ) ) );
        assertEquals( "bar", serialized.get( "foo" ) );
    }

    @Test
    public void shouldContainAddedPropertiesWhenCreatedFromPropertyContainer()
    {
        Map<String, Object> values = new HashMap<String, Object>();
        values.put( "foo", "bar" );
        Map<String, Object> serialized = serialize( new PropertiesRepresentation( container( values ) ) );
        assertEquals( "bar", serialized.get( "foo" ) );
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldContainAddedPropertiesWhenCreatedFromPropertyContainer() : void from class org.neo4j.server.rest.repr.PropertiesRepresentationTest


    @Test
    public void shouldSerializeToMapWithSamePropertiesWhenCreatedFromPropertyContainer()
    {
        Map<String, Object> values = new HashMap<>();
        values.put( "foo", "bar" );
        PropertiesRepresentation properties = new PropertiesRepresentation( container( values ) );
        Map<String, Object> map = serialize( properties );
        assertEquals( values, map );
    }

    @Test
    public void shouldSerializeToMapWithSamePropertiesWhenCreatedFromPropertyContainer()
    {
        Map<String, Object> values = new HashMap<String, Object>();
        values.put( "foo", "bar" );
        PropertiesRepresentation properties = new PropertiesRepresentation( container( values ) );
        Map<String, Object> map = serialize( properties );
        assertEquals( values, map );
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldSerializeToMapWithSamePropertiesWhenCreatedFromPropertyContainer() : void from class org.neo4j.server.rest.repr.PropertiesRepresentationTest


    @Test
    public void shouldSerializeToMap()
    {
        Map<String, Object> values = new HashMap<>();
        values.put( "string", "value" );
        values.put( "int", 5 );
        values.put( "long", 17L );
        values.put( "double", 3.14 );
        values.put( "float", 42.0f );
        values.put( "string array", new String[] { "one", "two" } );
        values.put( "long array", new long[] { 5L, 17L } );
        values.put( "double array", new double[] { 3.14, 42.0 } );

        PropertiesRepresentation properties = new PropertiesRepresentation( container( values ) );
        Map<String, Object> map = serialize( properties );

        assertEquals( "value", map.get( "string" ) );
        assertEquals( 5, ( (Number) map.get( "int" ) ).longValue() );
        assertEquals( 17, ( (Number) map.get( "long" ) ).longValue() );
        assertEquals( 3.14, ( (Number) map.get( "double" ) ).doubleValue(), 0.0 );
        assertEquals( 42.0, ( (Number) map.get( "float" ) ).doubleValue(), 0.0 );
        assertEqualContent( Arrays.asList( "one", "two" ), (List) map.get( "string array" ) );
        assertEqualContent( Arrays.asList( 5L, 17L ), (List) map.get( "long array" ) );
        assertEqualContent( Arrays.asList( 3.14, 42.0 ), (List) map.get( "double array" ) );
    }

    @Test
    public void shouldSerializeToMap()
    {
        Map<String, Object> values = new HashMap<String, Object>();
        values.put( "string", "value" );
        values.put( "int", 5 );
        values.put( "long", 17L );
        values.put( "double", 3.14 );
        values.put( "float", 42.0f );
        values.put( "string array", new String[] { "one", "two" } );
        values.put( "long array", new long[] { 5L, 17L } );
        values.put( "double array", new double[] { 3.14, 42.0 } );

        PropertiesRepresentation properties = new PropertiesRepresentation( container( values ) );
        Map<String, Object> map = serialize( properties );

        assertEquals( "value", map.get( "string" ) );
        assertEquals( 5, ( (Number) map.get( "int" ) ).longValue() );
        assertEquals( 17, ( (Number) map.get( "long" ) ).longValue() );
        assertEquals( 3.14, ( (Number) map.get( "double" ) ).doubleValue(), 0.0 );
        assertEquals( 42.0, ( (Number) map.get( "float" ) ).doubleValue(), 0.0 );
        assertEqualContent( Arrays.asList( "one", "two" ), (List) map.get( "string array" ) );
        assertEqualContent( Arrays.asList( 5L, 17L ), (List) map.get( "long array" ) );
        assertEqualContent( Arrays.asList( 3.14, 42.0 ), (List) map.get( "double array" ) );
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldSerializeToMap() : void from class org.neo4j.server.rest.repr.PropertiesRepresentationTest


    public static Map<String, Object> serialize( URI baseUri, MappingRepresentation repr )
    {
        Map<String, Object> result = new HashMap<>();
        repr.serialize( new MappingSerializer( new MapWrappingWriter( result ), baseUri, null ) );
        return result;
    }

    public static Map<String, Object> serialize( URI baseUri, MappingRepresentation repr )
    {
        Map<String, Object> result = new HashMap<String, Object>();
        repr.serialize( new MappingSerializer( new MapWrappingWriter( result ), baseUri, null ) );
        return result;
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public serialize(baseUri URI, repr MappingRepresentation) : Map<String,Object> from class org.neo4j.server.rest.repr.RepresentationTestAccess


    public static List<Object> serialize( URI baseUri, ListRepresentation repr )
    {
        List<Object> result = new ArrayList<>();
        repr.serialize( new ListSerializer( new ListWrappingWriter( result ), baseUri, null ) );
        return result;
    }

    public static List<Object> serialize( URI baseUri, ListRepresentation repr )
    {
        List<Object> result = new ArrayList<Object>();
        repr.serialize( new ListSerializer( new ListWrappingWriter( result ), baseUri, null ) );
        return result;
    }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public serialize(baseUri URI, repr ListRepresentation) : List<Object> from class org.neo4j.server.rest.repr.RepresentationTestAccess


    @Before
    public void setUp() throws Exception
    {
        JsonFormat inner = new JsonFormat();
        ArrayList<MediaType> supported = new ArrayList<>();
        MediaType requested = MediaType.APPLICATION_JSON_TYPE;
        input = new DefaultFormat( inner, supported, requested );
    }

    @Before
    public void setUp() throws Exception
    {
        JsonFormat inner = new JsonFormat();
        ArrayList<MediaType> supported = new ArrayList<MediaType>();
        MediaType requested = MediaType.APPLICATION_JSON_TYPE;
        input = new DefaultFormat( inner, supported, requested );
    }

Replace Generic With Diamond ArrayList<MediaType> with ArrayList<> in method public setUp() : void from class org.neo4j.server.rest.repr.formats.DefaultFormatTest


            @Override
            protected void serialize( MappingSerializer serializer )
            {
                ArrayList<Representation> maps = new ArrayList<>();
                maps.add( new MappingRepresentation( "map" )
                {

                    @Override
                    protected void serialize( MappingSerializer serializer )
                    {
                        serializer.putString( "foo", "bar" );

                    }
                } );
                serializer.putList( "foo", new ServerListRepresentation( RepresentationType.MAP, maps ) );
            }

            @Override
            protected void serialize( MappingSerializer serializer )
            {
                ArrayList<Representation> maps = new ArrayList<Representation>();
                maps.add( new MappingRepresentation( "map" )
                {

                    @Override
                    protected void serialize( MappingSerializer serializer )
                    {
                        serializer.putString( "foo", "bar" );

                    }
                } );
                serializer.putList( "foo", new ServerListRepresentation( RepresentationType.MAP, maps ) );
            }

Replace Generic With Diamond ArrayList<Representation> with ArrayList<> in method protected serialize(serializer MappingSerializer) : void from class org.neo4j.server.rest.repr.formats.JsonFormatTest.canFormatNestedMapsAndLists.entity.assemble.new MappingRepresentation


    @Test
    public void canFormatNestedMapsAndLists() throws Exception
    {
        String entity = json.assemble( new MappingRepresentation( "test" )
        {
            @Override
            protected void serialize( MappingSerializer serializer )
            {
                ArrayList<Representation> maps = new ArrayList<>();
                maps.add( new MappingRepresentation( "map" )
                {

                    @Override
                    protected void serialize( MappingSerializer serializer )
                    {
                        serializer.putString( "foo", "bar" );

                    }
                } );
                serializer.putList( "foo", new ServerListRepresentation( RepresentationType.MAP, maps ) );
            }
        } );

        assertEquals( "bar",((Map)((List) JsonHelper.jsonToMap(entity).get("foo")).get(0)).get("foo") );
    }

    @Test
    public void canFormatNestedMapsAndLists() throws Exception
    {
        String entity = json.assemble( new MappingRepresentation( "test" )
        {
            @Override
            protected void serialize( MappingSerializer serializer )
            {
                ArrayList<Representation> maps = new ArrayList<Representation>();
                maps.add( new MappingRepresentation( "map" )
                {

                    @Override
                    protected void serialize( MappingSerializer serializer )
                    {
                        serializer.putString( "foo", "bar" );

                    }
                } );
                serializer.putList( "foo", new ServerListRepresentation( RepresentationType.MAP, maps ) );
            }
        } );

        assertEquals( "bar",((Map)((List) JsonHelper.jsonToMap(entity).get("foo")).get(0)).get("foo") );
    }

Replace Generic With Diamond ArrayList<Representation> with ArrayList<> in method public canFormatNestedMapsAndLists() : void from class org.neo4j.server.rest.repr.formats.JsonFormatTest


    @Test
    public void shouldBeAbleToTraverseWithDefaultParameters()
    {
        long startNode = createBasicTraversableGraph();

        try ( Transaction transaction = graph.beginTx() )
        {
            assertEquals( 2, serialize( actions.traverse( startNode, new HashMap<>(),
                    TraverserReturnType.node ) ).size() );
        }
    }

    @Test
    public void shouldBeAbleToTraverseWithDefaultParameters()
    {
        long startNode = createBasicTraversableGraph();

        try ( Transaction transaction = graph.beginTx() )
        {
            assertEquals( 2, serialize( actions.traverse( startNode, new HashMap<String, Object>(),
                    TraverserReturnType.node ) ).size() );
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldBeAbleToTraverseWithDefaultParameters() : void from class org.neo4j.server.rest.web.DatabaseActionsTest


    @Test
    public void shouldBeAbleToGetRelationshipsIfSpecified()
    {
        long startNode = createBasicTraversableGraph();

        List<Object> hits;
        try ( Transaction transaction = graph.beginTx() )
        {
            hits = serialize( actions.traverse( startNode, new HashMap<>(),
                    TraverserReturnType.relationship ) );
        }

        for ( Object hit : hits )
        {
            @SuppressWarnings( "unchecked" )
            Map<String, Object> map = (Map<String, Object>) hit;
            RelationshipRepresentationTest.verifySerialisation( map );
        }
    }

    @Test
    public void shouldBeAbleToGetRelationshipsIfSpecified()
    {
        long startNode = createBasicTraversableGraph();

        List<Object> hits;
        try ( Transaction transaction = graph.beginTx() )
        {
            hits = serialize( actions.traverse( startNode, new HashMap<String, Object>(),
                    TraverserReturnType.relationship ) );
        }

        for ( Object hit : hits )
        {
            @SuppressWarnings( "unchecked" )
            Map<String, Object> map = (Map<String, Object>) hit;
            RelationshipRepresentationTest.verifySerialisation( map );
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldBeAbleToGetRelationshipsIfSpecified() : void from class org.neo4j.server.rest.web.DatabaseActionsTest


    @Test
    public void shouldBeAbleToGetPathsIfSpecified()
    {
        long startNode = createBasicTraversableGraph();

        List<Object> hits;
        try ( Transaction transaction = graph.beginTx() )
        {
            hits = serialize( actions.traverse( startNode, new HashMap<>(),
                    TraverserReturnType.path ) );
        }

        for ( Object hit : hits )
        {
            @SuppressWarnings( "unchecked" )
            Map<String, Object> map = (Map<String, Object>) hit;
            assertThat( map, hasKey( "start" ) );
            assertThat( map, hasKey( "end" ) );
            assertThat( map, hasKey( "length" ) );
        }
    }

    @Test
    public void shouldBeAbleToGetPathsIfSpecified()
    {
        long startNode = createBasicTraversableGraph();

        List<Object> hits;
        try ( Transaction transaction = graph.beginTx() )
        {
            hits = serialize( actions.traverse( startNode, new HashMap<String, Object>(),
                    TraverserReturnType.path ) );
        }

        for ( Object hit : hits )
        {
            @SuppressWarnings( "unchecked" )
            Map<String, Object> map = (Map<String, Object>) hit;
            assertThat( map, hasKey( "start" ) );
            assertThat( map, hasKey( "end" ) );
            assertThat( map, hasKey( "length" ) );
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldBeAbleToGetPathsIfSpecified() : void from class org.neo4j.server.rest.web.DatabaseActionsTest


    @Test
    public void shouldBeAbleToGetFullPathsIfSpecified()
    {
        long startNode = createBasicTraversableGraph();

        List<Object> hits;
        try ( Transaction transaction = graph.beginTx() )
        {
            hits = serialize( actions.traverse( startNode, new HashMap<>(),
                    TraverserReturnType.fullpath ) );
        }

        for ( Object hit : hits )
        {
            @SuppressWarnings( "unchecked" )
            Map<String, Object> map = (Map<String, Object>) hit;
            @SuppressWarnings( "unchecked" )
            Collection<Object> relationships = (Collection<Object>) map.get( "relationships" );
            for ( Object rel : relationships )
            {
                @SuppressWarnings( "unchecked" )
                Map<String, Object> relationship = (Map<String, Object>) rel;
                RelationshipRepresentationTest.verifySerialisation( relationship );
            }
            @SuppressWarnings( "unchecked" )
            Collection<Object> nodes = (Collection<Object>) map.get( "nodes" );
            for ( Object n : nodes )
            {
                @SuppressWarnings( "unchecked" )
                Map<String, Object> node = (Map<String, Object>) n;
                NodeRepresentationTest.verifySerialisation( node );
            }
            assertThat( map, hasKey( "start" ) );
            assertThat( map, hasKey( "end" ) );
            assertThat( map, hasKey( "length" ) );
        }
    }

    @Test
    public void shouldBeAbleToGetFullPathsIfSpecified()
    {
        long startNode = createBasicTraversableGraph();

        List<Object> hits;
        try ( Transaction transaction = graph.beginTx() )
        {
            hits = serialize( actions.traverse( startNode, new HashMap<String, Object>(),
                    TraverserReturnType.fullpath ) );
        }

        for ( Object hit : hits )
        {
            @SuppressWarnings( "unchecked" )
            Map<String, Object> map = (Map<String, Object>) hit;
            @SuppressWarnings( "unchecked" )
            Collection<Object> relationships = (Collection<Object>) map.get( "relationships" );
            for ( Object rel : relationships )
            {
                @SuppressWarnings( "unchecked" )
                Map<String, Object> relationship = (Map<String, Object>) rel;
                RelationshipRepresentationTest.verifySerialisation( relationship );
            }
            @SuppressWarnings( "unchecked" )
            Collection<Object> nodes = (Collection<Object>) map.get( "nodes" );
            for ( Object n : nodes )
            {
                @SuppressWarnings( "unchecked" )
                Map<String, Object> node = (Map<String, Object>) n;
                NodeRepresentationTest.verifySerialisation( node );
            }
            assertThat( map, hasKey( "start" ) );
            assertThat( map, hasKey( "end" ) );
            assertThat( map, hasKey( "length" ) );
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldBeAbleToGetFullPathsIfSpecified() : void from class org.neo4j.server.rest.web.DatabaseActionsTest


    @Test( expected = NoSuchScriptLanguageException.class )
    public void shouldThrowNoSuchScriptLanguageExceptionForUnkownLanguages() throws Exception
    {
        // Given
        ScriptExecutorFactoryRepository repo = new ScriptExecutorFactoryRepository( new HashMap<>() );

        // When
        repo.getFactory( "Blah" );
    }

    @Test( expected = NoSuchScriptLanguageException.class )
    public void shouldThrowNoSuchScriptLanguageExceptionForUnkownLanguages() throws Exception
    {
        // Given
        ScriptExecutorFactoryRepository repo = new ScriptExecutorFactoryRepository( new HashMap<String, ScriptExecutor.Factory>() );

        // When
        repo.getFactory( "Blah" );
    }

Replace Generic With Diamond ScriptExecutorFactoryRepository with ScriptExecutorFactoryRepository in method public shouldThrowNoSuchScriptLanguageExceptionForUnkownLanguages() : void from class org.neo4j.server.scripting.TestScriptExecutorFactoryRepository


    @Test
    public void shouldReturnRegisteredFactory() throws Exception
    {
        // Given
        Map<String, ScriptExecutor.Factory> languages = new HashMap<>();
        languages.put( "js", mock(ScriptExecutor.Factory.class) );

        ScriptExecutorFactoryRepository repo = new ScriptExecutorFactoryRepository( languages );

        // When
        ScriptExecutor.Factory factory = repo.getFactory( "js" );

        // Then
        assertThat(factory, not(nullValue()));
    }

    @Test
    public void shouldReturnRegisteredFactory() throws Exception
    {
        // Given
        Map<String, ScriptExecutor.Factory> languages = new HashMap<String, ScriptExecutor.Factory>(  );
        languages.put( "js", mock(ScriptExecutor.Factory.class) );

        ScriptExecutorFactoryRepository repo = new ScriptExecutorFactoryRepository( languages );

        // When
        ScriptExecutor.Factory factory = repo.getFactory( "js" );

        // Then
        assertThat(factory, not(nullValue()));
    }

Replace Generic With Diamond HashMap<String,ScriptExecutor.Factory> with HashMap<> in method public shouldReturnRegisteredFactory() : void from class org.neo4j.server.scripting.TestScriptExecutorFactoryRepository


    @Test
    public void shouldAllowContextVariables() throws Exception
    {
        // Given
        JavascriptExecutor executor = new JavascriptExecutor( "myVar;" );

        Map<String, Object> ctx = new HashMap<>();
        ctx.put( "myVar", 1338 );

        // When
        Object out = executor.execute( ctx );

        // Then
        assertThat( out, not( nullValue() ));
        assertThat( out, is( 1338 ));
    }

    @Test
    public void shouldAllowContextVariables() throws Exception
    {
        // Given
        JavascriptExecutor executor = new JavascriptExecutor( "myVar;" );

        Map<String, Object> ctx = new HashMap<String, Object>();
        ctx.put( "myVar", 1338 );

        // When
        Object out = executor.execute( ctx );

        // Then
        assertThat( out, not( nullValue() ));
        assertThat( out, is( 1338 ));
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public shouldAllowContextVariables() : void from class org.neo4j.server.scripting.javascript.TestJavascriptExecutor


    @Test
    public void varsSetInOneExecutionShouldNotBeAvailableInAnother() throws Exception
    {
        // Given
        JavascriptExecutor executor = new JavascriptExecutor(
                "if(firstRun) { " +
                "  this['theVar'] = 'boo'; " +
                "} else { " +
                "  this['theVar']; " +
                "}" );

        Map<String, Object> ctx = new HashMap<>();

        // When
        ctx.put( "firstRun", true );
        Object out1 = executor.execute( ctx );

        ctx.put( "firstRun", false );
        Object out2 = executor.execute( ctx );

        // Then
        assertThat( out1, is( "boo" ) );
        assertThat( out2, is( nullValue()) );
    }

    @Test
    public void varsSetInOneExecutionShouldNotBeAvailableInAnother() throws Exception
    {
        // Given
        JavascriptExecutor executor = new JavascriptExecutor(
                "if(firstRun) { " +
                "  this['theVar'] = 'boo'; " +
                "} else { " +
                "  this['theVar']; " +
                "}" );

        Map<String, Object> ctx = new HashMap<String, Object>();

        // When
        ctx.put( "firstRun", true );
        Object out1 = executor.execute( ctx );

        ctx.put( "firstRun", false );
        Object out2 = executor.execute( ctx );

        // Then
        assertThat( out1, is( "boo" ) );
        assertThat( out2, is( nullValue()) );
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public varsSetInOneExecutionShouldNotBeAvailableInAnother() : void from class org.neo4j.server.scripting.javascript.TestJavascriptExecutor


    @Test
    public void shouldAllowWhiteListedClasses() throws Exception
    {
        // Given
        Set<String> whiteList = new HashSet<>();
        whiteList.add( getClass().getName() );
        WhiteListClassShutter shutter = new WhiteListClassShutter( whiteList );

        // When
        boolean visible = shutter.visibleToScripts( getClass().getName() );

        // Then
        assertThat(visible, is(true));
    }

    @Test
    public void shouldAllowWhiteListedClasses() throws Exception
    {
        // Given
        Set<String> whiteList = new HashSet<String>();
        whiteList.add( getClass().getName() );
        WhiteListClassShutter shutter = new WhiteListClassShutter( whiteList );

        // When
        boolean visible = shutter.visibleToScripts( getClass().getName() );

        // Then
        assertThat(visible, is(true));
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public shouldAllowWhiteListedClasses() : void from class org.neo4j.server.scripting.javascript.TestWhiteListClassShutter


    @Test
    public void shouldDisallowUnlistedClasses() throws Exception
    {
        WhiteListClassShutter shutter = new WhiteListClassShutter( new HashSet<>() );

        // When
        boolean visible = shutter.visibleToScripts( getClass().getName() );

        // Then
        assertThat(visible, is(false));
    }

    @Test
    public void shouldDisallowUnlistedClasses() throws Exception
    {
        WhiteListClassShutter shutter = new WhiteListClassShutter( new HashSet<String>() );

        // When
        boolean visible = shutter.visibleToScripts( getClass().getName() );

        // Then
        assertThat(visible, is(false));
    }

Replace Generic With Diamond WhiteListClassShutter with WhiteListClassShutter in method public shouldDisallowUnlistedClasses() : void from class org.neo4j.server.scripting.javascript.TestWhiteListClassShutter


    @Test( expected = SecurityException.class )
    public void shouldBlockAttemptsAtAccessingClassLoader() throws Exception
    {
        // Given
        WhiteListJavaWrapper wrapper = new WhiteListJavaWrapper( new WhiteListClassShutter( new HashSet<>() ) );

        // When
        wrapper.wrap( null, null, getClass().getClassLoader(), null );
    }

    @Test( expected = SecurityException.class )
    public void shouldBlockAttemptsAtAccessingClassLoader() throws Exception
    {
        // Given
        WhiteListJavaWrapper wrapper = new WhiteListJavaWrapper( new WhiteListClassShutter( new HashSet<String>() ) );

        // When
        wrapper.wrap( null, null, getClass().getClassLoader(), null );
    }

Replace Generic With Diamond WhiteListJavaWrapper with WhiteListJavaWrapper in method public shouldBlockAttemptsAtAccessingClassLoader() : void from class org.neo4j.server.scripting.javascript.TestWhiteListJavaWrapper


    @Test
    public void shouldDownCastSubclassesToAllowedParentClass() throws Exception
    {
        // Given
        Set<String> whiteList = new HashSet<>();
        whiteList.add( Object.class.getName() );

        WhiteListJavaWrapper wrapper = new WhiteListJavaWrapper( new WhiteListClassShutter( whiteList ) );

        Context cx = Context.enter();
        Scriptable scope = cx.initStandardObjects();

        // When
        Object wrapped = wrapper.wrap( cx, scope, new TestWhiteListJavaWrapper(), null );

        // Then
        assertThat( wrapped, is( instanceOf( NativeJavaObject.class ) ) );
        NativeJavaObject obj = (NativeJavaObject)wrapped;

        assertThat( obj.has( "aGetter", scope ), is( false ));
        assertThat( obj.get( "aGetter", scope ), is( UniqueTag.NOT_FOUND ) );
    }

    @Test
    public void shouldDownCastSubclassesToAllowedParentClass() throws Exception
    {
        // Given
        Set<String> whiteList = new HashSet<String>(  );
        whiteList.add( Object.class.getName() );

        WhiteListJavaWrapper wrapper = new WhiteListJavaWrapper( new WhiteListClassShutter( whiteList ) );

        Context cx = Context.enter();
        Scriptable scope = cx.initStandardObjects();

        // When
        Object wrapped = wrapper.wrap( cx, scope, new TestWhiteListJavaWrapper(), null );

        // Then
        assertThat( wrapped, is( instanceOf( NativeJavaObject.class ) ) );
        NativeJavaObject obj = (NativeJavaObject)wrapped;

        assertThat( obj.has( "aGetter", scope ), is( false ));
        assertThat( obj.get( "aGetter", scope ), is( UniqueTag.NOT_FOUND ) );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public shouldDownCastSubclassesToAllowedParentClass() : void from class org.neo4j.server.scripting.javascript.TestWhiteListJavaWrapper


    @Test( expected = SecurityException.class )
    public void shouldThrowSecurityExceptionWhenAccessingLockedClasses() throws Exception
    {
        // Given
        Set<String> whiteList = new HashSet<>();
        whiteList.add( Object.class.getName() );

        WhiteListJavaWrapper wrapper = new WhiteListJavaWrapper( new WhiteListClassShutter( whiteList ) );

        Context cx = Context.enter();
        Scriptable scope = cx.initStandardObjects();

        // When
        Object wrapped = wrapper.wrap( cx, scope, TestWhiteListJavaWrapper.class, null );
    }

    @Test( expected = SecurityException.class )
    public void shouldThrowSecurityExceptionWhenAccessingLockedClasses() throws Exception
    {
        // Given
        Set<String> whiteList = new HashSet<String>(  );
        whiteList.add( Object.class.getName() );

        WhiteListJavaWrapper wrapper = new WhiteListJavaWrapper( new WhiteListClassShutter( whiteList ) );

        Context cx = Context.enter();
        Scriptable scope = cx.initStandardObjects();

        // When
        Object wrapped = wrapper.wrap( cx, scope, TestWhiteListJavaWrapper.class, null );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public shouldThrowSecurityExceptionWhenAccessingLockedClasses() : void from class org.neo4j.server.scripting.javascript.TestWhiteListJavaWrapper


    /**
     * Creates a client and "starts" it, i.e. grabs the console prompt.
     * @param server the server (in the same JVM) which the client will
     * communicate with.
     * @param signalHandler the ctrl-c handler to use
     * @throws ShellException if the execution fails
     * @return the new shell client.
     */
    public static ShellClient newClient( ShellServer server, CtrlCHandler signalHandler ) throws ShellException
    {
        return newClient( server, new HashMap<>(), signalHandler );
    }

    /**
     * Creates a client and "starts" it, i.e. grabs the console prompt.
     * @param server the server (in the same JVM) which the client will
     * communicate with.
     * @param signalHandler the ctrl-c handler to use
     * @throws ShellException if the execution fails
     * @return the new shell client.
     */
    public static ShellClient newClient( ShellServer server, CtrlCHandler signalHandler ) throws ShellException
    {
        return newClient( server, new HashMap<String, Serializable>(), signalHandler );
    }

Replace Generic With Diamond HashMap<String,Serializable> with HashMap<> in method public newClient(server ShellServer, signalHandler CtrlCHandler) : ShellClient from class org.neo4j.shell.ShellLobby


    /**
     * Creates a client and "starts" it, i.e. grabs the console prompt.
     * @param server the server (in the same JVM) which the client will
     * communicate with.
     * @throws ShellException if the execution fails
     * @return the new shell client.
     */
    public static ShellClient newClient( ShellServer server ) throws ShellException
    {
        return newClient( server, new HashMap<>(), InterruptSignalHandler.getHandler() );
    }

    /**
     * Creates a client and "starts" it, i.e. grabs the console prompt.
     * @param server the server (in the same JVM) which the client will
     * communicate with.
     * @throws ShellException if the execution fails
     * @return the new shell client.
     */
    public static ShellClient newClient( ShellServer server ) throws ShellException
    {
        return newClient( server, new HashMap<String, Serializable>(), InterruptSignalHandler.getHandler() );
    }

Replace Generic With Diamond HashMap<String,Serializable> with HashMap<> in method public newClient(server ShellServer) : ShellClient from class org.neo4j.shell.ShellLobby


    /**
     * Creates a client and "starts" it, i.e. grabs the console prompt.
     * It will try to find a remote server specified by {@code serverLocation}.
     * @param serverLocation the RMI location of the server to connect to.
     * @param ctrlcHandler the ctrl-c handler to use
     * @throws ShellException if no server was found at the RMI location.
     * @return the new shell client.
     */
    public static ShellClient newClient( RmiLocation serverLocation, CtrlCHandler ctrlcHandler )
        throws ShellException
    {
        return newClient( serverLocation, new HashMap<>(), ctrlcHandler );
    }

    /**
     * Creates a client and "starts" it, i.e. grabs the console prompt.
     * It will try to find a remote server specified by {@code serverLocation}.
     * @param serverLocation the RMI location of the server to connect to.
     * @param ctrlcHandler the ctrl-c handler to use
     * @throws ShellException if no server was found at the RMI location.
     * @return the new shell client.
     */
    public static ShellClient newClient( RmiLocation serverLocation, CtrlCHandler ctrlcHandler )
        throws ShellException
    {
        return newClient( serverLocation, new HashMap<String, Serializable>(), ctrlcHandler );
    }

Replace Generic With Diamond HashMap<String,Serializable> with HashMap<> in method public newClient(serverLocation RmiLocation, ctrlcHandler CtrlCHandler) : ShellClient from class org.neo4j.shell.ShellLobby