@@ -28,7 +28,7 @@ const { InetAddress, Uuid, Tuple } = types;
2828const ExecutionProfile = require ( '../../../../lib/execution-profile' ) . ExecutionProfile ;
2929const utils = require ( '../../../../lib/utils' ) ;
3030const graphModule = require ( '../../../../lib/datastax/graph' ) ;
31- const { asInt, asFloat, asUdt, t } = graphModule ;
31+ const { asInt, asFloat, asUdt, t, Edge , direction } = graphModule ;
3232const { graphProtocol } = require ( '../../../../lib/datastax/graph/options' ) ;
3333const graphTestHelper = require ( './graph-test-helper' ) ;
3434
@@ -857,16 +857,25 @@ vdescribe('dse-5.0', 'Client @SERVER_API', function () {
857857 return client . executeGraph ( query , null , { graphName } ) ;
858858 } ) ;
859859
860- before ( ( ) => {
861- const createLabelQuery = `schema.vertexLabel('label_test').ifNotExists().partitionBy('id', Int)
860+ before ( async ( ) => {
861+ const createVertexLabel1Query = `schema.vertexLabel('label_test').ifNotExists().partitionBy('id', Int)
862862 .property('prop_double', Double)
863863 .property('prop_text', Text)
864864 .property('prop_uuid', Uuid)
865865 .property('prop_long', Bigint)
866866 .property('prop_blob', Blob)
867867 .property('prop_duration', Duration)
868868 .create()` ;
869- return client . executeGraph ( createLabelQuery , null , { graphName } ) ;
869+ const createVertexLabel2Query = `schema.vertexLabel('label_test2').ifNotExists().partitionBy('id', Int)
870+ .property('prop_text', Text)
871+ .create()` ;
872+ const createEdgeLabelQuery = `schema.edgeLabel('created')
873+ .from('label_test').to('label_test2')
874+ .property('tag', Text)
875+ .create()` ;
876+ await client . executeGraph ( createVertexLabel1Query , null , { graphName } ) ;
877+ await client . executeGraph ( createVertexLabel2Query , null , { graphName } ) ;
878+ await client . executeGraph ( createEdgeLabelQuery , null , { graphName } ) ;
870879 } ) ;
871880
872881 after ( ( ) => client . shutdown ( ) ) ;
@@ -911,6 +920,43 @@ vdescribe('dse-5.0', 'Client @SERVER_API', function () {
911920 assert . deepEqual ( rs . toArray ( ) , [ 'value1' ] ) ;
912921 } ) ;
913922
923+ it ( 'should be able to add a edge and retrieve it' , async ( ) => {
924+ const id1 = schemaCounter ++ ;
925+ const id2 = schemaCounter ++ ;
926+ const addTraversal = `g.addV('label_test')
927+ .property('id', ${ id1 } )
928+ .property('prop_text', 'value1')
929+ .as('first')
930+ .addV('label_test2')
931+ .property('id', ${ id2 } )
932+ .property('prop_text', 'value2')
933+ .as('second')
934+ .addE('created').from('first').to('second').property('tag', 'sample')` ;
935+ await client . executeGraph ( addTraversal , null , { graphName } ) ;
936+
937+ const retrieveMapTraversal = `g.V().hasLabel('label_test').has('id', ${ id1 } ).outE('created').elementMap()` ;
938+ let rs = await client . executeGraph ( retrieveMapTraversal , null , { executionProfile : 'profile1' } ) ;
939+ const map = rs . first ( ) ;
940+ assert . instanceOf ( map , Map ) ;
941+ assert . equal ( map . get ( 'tag' ) , 'sample' ) ;
942+ assert . equal ( map . get ( t . label ) , 'created' ) ;
943+ const outMap = map . get ( direction . out ) ;
944+ const inMap = map . get ( direction . in ) ;
945+ assert . instanceOf ( outMap , Map ) ;
946+ assert . equal ( outMap . get ( t . label ) , 'label_test' ) ;
947+ assert . instanceOf ( inMap , Map ) ;
948+ assert . equal ( inMap . get ( t . label ) , 'label_test2' ) ;
949+
950+ const retrieveEdgeTraversal = `g.V().hasLabel('label_test').has('id', ${ id1 } ).outE('created')` ;
951+ rs = await client . executeGraph ( retrieveEdgeTraversal , null , { executionProfile : 'profile1' } ) ;
952+ const edge = rs . first ( ) ;
953+ assert . instanceOf ( edge , Edge ) ;
954+ assert . equal ( edge . label , 'created' ) ;
955+ assert . equal ( edge . outVLabel , 'label_test' ) ;
956+ assert . equal ( edge . inVLabel , 'label_test2' ) ;
957+ assert . typeOf ( edge . outV , 'string' ) ;
958+ } ) ;
959+
914960 it ( 'should support named parameters' , async ( ) => {
915961 const id = schemaCounter ++ ;
916962 const value = 'value2' ;
0 commit comments