@@ -543,4 +543,50 @@ void shouldUpdateNullValues(){
543543 assertNull (human .getName ());
544544
545545 }
546+
547+ @ Test
548+ void shouldCreateEdgeByGraphAPI () {
549+ final Human otavio = getGraphTemplate ().insert (Human .builder ().withAge ()
550+ .withName ("Otavio" ).build ());
551+
552+ final Human poliana = getGraphTemplate ().insert (Human .builder ().withAge ()
553+ .withName ("Poliana" ).build ());
554+
555+ var edge = org .eclipse .jnosql .mapping .graph .Edge .source (otavio ).label ("LOVES" ).target (poliana ).build ();
556+ var edgeEntity = getGraphTemplate ().edge (edge );
557+
558+ SoftAssertions .assertSoftly (softly -> {
559+ softly .assertThat (edgeEntity ).isNotNull ();
560+ softly .assertThat (edgeEntity .label ()).isEqualTo ("LOVES" );
561+ softly .assertThat (edgeEntity .source ()).isEqualTo (otavio );
562+ softly .assertThat (edgeEntity .target ()).isEqualTo (poliana );
563+ });
564+ }
565+
566+ @ Test
567+ void shouldCreateEdgeByGraphAPIWithProperties () {
568+ final Human otavio = getGraphTemplate ().insert (Human .builder ().withAge ()
569+ .withName ("Otavio" ).build ());
570+
571+ final Human poliana = getGraphTemplate ().insert (Human .builder ().withAge ()
572+ .withName ("Poliana" ).build ());
573+
574+ var edge = org .eclipse .jnosql .mapping .graph .Edge .source (otavio )
575+ .label ("LOVES" )
576+ .target (poliana )
577+ .property ("when" , "2017" )
578+ .property ("where" , "Brazil" )
579+ .build ();
580+ var edgeEntity = getGraphTemplate ().edge (edge );
581+
582+ SoftAssertions .assertSoftly (softly -> {
583+ softly .assertThat (edgeEntity ).isNotNull ();
584+ softly .assertThat (edgeEntity .label ()).isEqualTo ("LOVES" );
585+ softly .assertThat (edgeEntity .source ()).isEqualTo (otavio );
586+ softly .assertThat (edgeEntity .target ()).isEqualTo (poliana );
587+ softly .assertThat (edgeEntity .properties ()).hasSize (2 );
588+ softly .assertThat (edgeEntity .property ("when" , String .class )).contains ("2017" );
589+ softly .assertThat (edgeEntity .property ("where" , String .class )).contains ("Brazil" );
590+ });
591+ }
546592}
0 commit comments