// Path: src/main/java/org/neo4j/neode/properties/Property.java
// public abstract class Property
// {
//     public static Property property( String name )
//     {
//         return new NonIndexableProperty( name, new CounterBasedStringPropertyValueGenerator() );
//     }
// 
//     public static Property property( String name, PropertyValueGenerator generator )
//     {
//         return new NonIndexableProperty( name, generator );
//     }
// 
//     public static Property indexableProperty( GraphDatabaseService db, String label, String name, String... labelNames )
//     {
//         return indexableProperty( db,label, name, new CounterBasedStringPropertyValueGenerator(), labelNames );
//     }
// 
//     public static Property indexableProperty( GraphDatabaseService db, String label, String name, PropertyValueGenerator generator, String... labelNames )
//     {
//         return new IndexableProperty( db,label,name, generator, labelNames );
//     }
// 
//     public abstract void setProperty(PropertyContainer propertyContainer, String label,
//                                      int iteration);
// }
// 
// Path: src/test/java/org/neo4j/neode/test/Db.java
// public final class Db
// {
//     private Db()
//     {
//     }
// 
//     public static GraphDatabaseService impermanentDb()
//     {
//         Map<String, String> params = new HashMap<String, String>();
//         params.put( "online_backup_enabled", "false" );
// 
//         return new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig( params ).newGraphDatabase();
//     }
// 
//     public static GraphDatabaseService tempDb()
//     {
//         return new GraphDatabaseFactory().newEmbeddedDatabase( createTempDatabaseDir().getAbsolutePath() );
//     }
// 
//     private static File createTempDatabaseDir()
//     {
// 
//         File d;
//         try
//         {
//             d = File.createTempFile( "datasetbuilder-", "dir" );
//             System.out.println( String.format( "Created a new Neo4j database at [%s]", d.getAbsolutePath() ) );
//         }
//         catch ( IOException e )
//         {
//             throw new RuntimeException( e );
//         }
//         if ( !d.delete() )
//         {
//             throw new RuntimeException( "temp config directory pre-delete failed" );
//         }
//         if ( !d.mkdirs() )
//         {
//             throw new RuntimeException( "temp config directory not created" );
//         }
//         d.deleteOnExit();
//         return d;
//     }
// 
//     public static void usingSampleDataset( WithSampleDataset f )
//     {
//         GraphDatabaseService db = Db.impermanentDb();
//         Node firstNode, secondNode, thirdNode;
//         try ( Transaction tx = db.beginTx() )
//         {
//             firstNode = db.createNode();
//             secondNode = db.createNode();
//             thirdNode = db.createNode();
//             tx.success();
//         }
// 
//         try ( Transaction tx = db.beginTx() )
//         {
//             f.execute( db, firstNode, secondNode, thirdNode );
//             tx.success();
//         }
//         db.shutdown();
//     }
// 
//     public interface WithSampleDataset
//     {
//         public void execute( GraphDatabaseService db, Node firstNode, Node secondNode, Node thirdNode );
//     }
// 
// 
// }


import java.util.Collections;
import java.util.Iterator;
import org.junit.Test;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.neode.properties.Property;
import org.neo4j.neode.test.Db;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.neo4j.graphdb.DynamicRelationshipType.withName;
package org.neo4j.neode;






public class RelationshipUniquenessTest
{
    @Test
    public void uniqueSingleDirectionShouldNotCreateNewRelationshipIfRelationshipAlreadyExists() throws Exception
    {
        // given
        GraphDatabaseService db = Db.impermanentDb();
        DynamicRelationshipType friend_of = withName( "FRIEND_OF" );
        Node firstNode;
        try (Transaction tx = db.beginTx())
        {

            firstNode = db.createNode();
            Node secondNode = db.createNode();
            firstNode.createRelationshipTo( secondNode, friend_of );

            RelationshipSpecification relationshipSpecification = new RelationshipSpecification( friend_of,
// Path: src/main/java/org/neo4j/neode/properties/Property.java
// public abstract class Property
// {
//     public static Property property( String name )
//     {
//         return new NonIndexableProperty( name, new CounterBasedStringPropertyValueGenerator() );
//     }
// 
//     public static Property property( String name, PropertyValueGenerator generator )
//     {
//         return new NonIndexableProperty( name, generator );
//     }
// 
//     public static Property indexableProperty( GraphDatabaseService db, String label, String name, String... labelNames )
//     {
//         return indexableProperty( db,label, name, new CounterBasedStringPropertyValueGenerator(), labelNames );
//     }
// 
//     public static Property indexableProperty( GraphDatabaseService db, String label, String name, PropertyValueGenerator generator, String... labelNames )
//     {
//         return new IndexableProperty( db,label,name, generator, labelNames );
//     }
// 
//     public abstract void setProperty(PropertyContainer propertyContainer, String label,
//                                      int iteration);
// }
// 
// Path: src/test/java/org/neo4j/neode/test/Db.java
// public final class Db
// {
//     private Db()
//     {
//     }
// 
//     public static GraphDatabaseService impermanentDb()
//     {
//         Map<String, String> params = new HashMap<String, String>();
//         params.put( "online_backup_enabled", "false" );
// 
//         return new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig( params ).newGraphDatabase();
//     }
// 
//     public static GraphDatabaseService tempDb()
//     {
//         return new GraphDatabaseFactory().newEmbeddedDatabase( createTempDatabaseDir().getAbsolutePath() );
//     }
// 
//     private static File createTempDatabaseDir()
//     {
// 
//         File d;
//         try
//         {
//             d = File.createTempFile( "datasetbuilder-", "dir" );
//             System.out.println( String.format( "Created a new Neo4j database at [%s]", d.getAbsolutePath() ) );
//         }
//         catch ( IOException e )
//         {
//             throw new RuntimeException( e );
//         }
//         if ( !d.delete() )
//         {
//             throw new RuntimeException( "temp config directory pre-delete failed" );
//         }
//         if ( !d.mkdirs() )
//         {
//             throw new RuntimeException( "temp config directory not created" );
//         }
//         d.deleteOnExit();
//         return d;
//     }
// 
//     public static void usingSampleDataset( WithSampleDataset f )
//     {
//         GraphDatabaseService db = Db.impermanentDb();
//         Node firstNode, secondNode, thirdNode;
//         try ( Transaction tx = db.beginTx() )
//         {
//             firstNode = db.createNode();
//             secondNode = db.createNode();
//             thirdNode = db.createNode();
//             tx.success();
//         }
// 
//         try ( Transaction tx = db.beginTx() )
//         {
//             f.execute( db, firstNode, secondNode, thirdNode );
//             tx.success();
//         }
//         db.shutdown();
//     }
// 
//     public interface WithSampleDataset
//     {
//         public void execute( GraphDatabaseService db, Node firstNode, Node secondNode, Node thirdNode );
//     }
// 
// 
// }


// Path: src/test/java/org/neo4j/neode/RelationshipUniquenessTest.java
import java.util.Collections;
import java.util.Iterator;
import org.junit.Test;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.neode.properties.Property;
import org.neo4j.neode.test.Db;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.neo4j.graphdb.DynamicRelationshipType.withName;

package org.neo4j.neode;






public class RelationshipUniquenessTest
{
    @Test
    public void uniqueSingleDirectionShouldNotCreateNewRelationshipIfRelationshipAlreadyExists() throws Exception
    {
        // given
        GraphDatabaseService db = Db.impermanentDb();
        DynamicRelationshipType friend_of = withName( "FRIEND_OF" );
        Node firstNode;
        try (Transaction tx = db.beginTx())
        {

            firstNode = db.createNode();
            Node secondNode = db.createNode();
            firstNode.createRelationshipTo( secondNode, friend_of );

            RelationshipSpecification relationshipSpecification = new RelationshipSpecification( friend_of,
                    Collections.<Property>emptyList(), db );