4242import static org .assertj .core .api .Assertions .assertThat ;
4343import static org .eclipse .jnosql .communication .semistructured .DeleteQuery .delete ;
4444import static org .eclipse .jnosql .communication .semistructured .SelectQuery .select ;
45+ import static org .eclipse .jnosql .databases .tinkerpop .communication .TinkerpopGraphDatabaseManager .ID ;
4546import static org .junit .jupiter .api .Assertions .assertEquals ;
4647import static org .junit .jupiter .api .Assertions .assertFalse ;
4748import static org .junit .jupiter .api .Assertions .assertNotNull ;
5051
5152class DefaultTinkerpopGraphDatabaseManagerTest {
5253
53- public static final String COLLECTION_NAME = "person " ;
54+ public static final String COLLECTION_NAME = "Person " ;
5455
5556 private TinkerpopGraphDatabaseManager entityManager ;
5657
@@ -80,7 +81,7 @@ void shouldInsertEntity(){
8081 SoftAssertions .assertSoftly (softly -> {
8182 softly .assertThat (communicationEntity .find ("name" , String .class )).get ().isEqualTo (name );
8283 softly .assertThat (communicationEntity .find ("age" , int .class )).get ().isEqualTo (age );
83- softly .assertThat (communicationEntity .find (DefaultTinkerpopGraphDatabaseManager . ID_PROPERTY )).isPresent ();
84+ softly .assertThat (communicationEntity .find (ID )).isPresent ();
8485 });
8586 }
8687
@@ -106,11 +107,11 @@ void shouldInsertEntities(){
106107 softly .assertThat (communicationEntities ).hasSize (2 );
107108 softly .assertThat (communicationEntities .get (0 ).find ("name" , String .class )).get ().isEqualTo (name );
108109 softly .assertThat (communicationEntities .get (0 ).find ("age" , int .class )).get ().isEqualTo (age );
109- softly .assertThat (communicationEntities .get (0 ).find (DefaultTinkerpopGraphDatabaseManager . ID_PROPERTY )).isPresent ();
110+ softly .assertThat (communicationEntities .get (0 ).find (ID )).isPresent ();
110111
111112 softly .assertThat (communicationEntities .get (1 ).find ("name" , String .class )).get ().isEqualTo (name2 );
112113 softly .assertThat (communicationEntities .get (1 ).find ("age" , int .class )).get ().isEqualTo (age2 );
113- softly .assertThat (communicationEntities .get (1 ).find (DefaultTinkerpopGraphDatabaseManager . ID_PROPERTY )).isPresent ();
114+ softly .assertThat (communicationEntities .get (1 ).find (ID )).isPresent ();
114115 });
115116
116117 }
@@ -119,7 +120,7 @@ void shouldInsertEntities(){
119120 void shouldInsert () {
120121 var entity = getEntity ();
121122 var documentEntity = entityManager .insert (entity );
122- assertTrue (documentEntity .elements ().stream ().map (Element ::name ).anyMatch (s -> s .equals ("_id" )));
123+ assertTrue (documentEntity .elements ().stream ().map (Element ::name ).anyMatch (s -> s .equals (ID )));
123124 }
124125
125126 @ Test
@@ -142,11 +143,11 @@ void shouldUpdate() {
142143 void shouldRemoveEntity () {
143144 var documentEntity = entityManager .insert (getEntity ());
144145
145- Optional <Element > id = documentEntity .find ("_id" );
146+ Optional <Element > id = documentEntity .find (ID );
146147 var query = select ().from (COLLECTION_NAME )
147- .where ("_id" ).eq (id .orElseThrow ().get ())
148+ .where (ID ).eq (id .orElseThrow ().get ())
148149 .build ();
149- var deleteQuery = delete ().from (COLLECTION_NAME ).where ("_id" )
150+ var deleteQuery = delete ().from (COLLECTION_NAME ).where (ID )
150151 .eq (id .get ().get ())
151152 .build ();
152153
@@ -157,10 +158,10 @@ void shouldRemoveEntity() {
157158 @ Test
158159 void shouldFindDocument () {
159160 var entity = entityManager .insert (getEntity ());
160- Optional <Element > id = entity .find ("_id" );
161+ Optional <Element > id = entity .find (ID );
161162
162163 var query = select ().from (COLLECTION_NAME )
163- .where ("_id" ).eq (id .orElseThrow ().get ())
164+ .where (ID ).eq (id .orElseThrow ().get ())
164165 .build ();
165166
166167 var entities = entityManager .select (query ).collect (Collectors .toList ());
@@ -171,11 +172,12 @@ void shouldFindDocument() {
171172 @ Test
172173 void shouldFindDocument2 () {
173174 var entity = entityManager .insert (getEntity ());
174- Optional <Element > id = entity .find ("_id" );
175+ Optional <Element > id = entity .find (ID );
175176
176177 var query = select ().from (COLLECTION_NAME )
177178 .where ("name" ).eq ("Poliana" )
178- .and ("city" ).eq ("Salvador" ).and ("_id" ).eq (id .orElseThrow ().get ())
179+ .and ("city" ).eq ("Salvador" )
180+ .and (ID ).eq (id .orElseThrow ().get ())
179181 .build ();
180182
181183 List <CommunicationEntity > entities = entityManager .select (query ).collect (Collectors .toList ());
@@ -186,11 +188,11 @@ void shouldFindDocument2() {
186188 @ Test
187189 void shouldFindDocument3 () {
188190 var entity = entityManager .insert (getEntity ());
189- Optional <Element > id = entity .find ("_id" );
191+ Optional <Element > id = entity .find (ID );
190192 var query = select ().from (COLLECTION_NAME )
191193 .where ("name" ).eq ("Poliana" )
192194 .or ("city" ).eq ("Salvador" )
193- .and (id . orElseThrow (). name ()). eq (id .get ().get ())
195+ .and (ID ). eq (id .orElseThrow ().get ())
194196 .build ();
195197
196198 List <CommunicationEntity > entities = entityManager .select (query ).collect (Collectors .toList ());
@@ -426,7 +428,7 @@ void shouldFindAllByFields() {
426428 assertEquals (3 , entity .size ());
427429 SoftAssertions .assertSoftly (softly -> {
428430 softly .assertThat (entity .find ("name" )).isPresent ();
429- softly .assertThat (entity .find ("_id" )).isPresent ();
431+ softly .assertThat (entity .find (ID )).isPresent ();
430432 softly .assertThat (entity .find ("city" )).isPresent ();
431433 });
432434 }
@@ -436,15 +438,15 @@ void shouldCreateEdge() {
436438 var person1 = entityManager .insert (getEntity ());
437439 var person2 = entityManager .insert (getEntity ());
438440
439- String label = "FRIEND " ;
441+ String label = "friend " ;
440442 Map <String , Object > properties = Map .of ("since" , 2023 );
441443
442444 var edge = entityManager .edge (person1 , label , person2 , properties );
443445
444446 assertNotNull (edge );
445447 assertEquals (label , edge .label ());
446- assertEquals (person1 .find ("_id" ).orElseThrow ().get (), edge .source ().find ("_id" ).orElseThrow ().get ());
447- assertEquals (person2 .find ("_id" ).orElseThrow ().get (), edge .target ().find ("_id" ).orElseThrow ().get ());
448+ assertEquals (person1 .find (ID ).orElseThrow ().get (), edge .source ().find (ID ).orElseThrow ().get ());
449+ assertEquals (person2 .find (ID ).orElseThrow ().get (), edge .target ().find (ID ).orElseThrow ().get ());
448450 assertEquals (properties , edge .properties ());
449451 }
450452
@@ -453,9 +455,9 @@ void shouldRemoveEdge() {
453455 var person1 = entityManager .insert (getEntity ());
454456 var person2 = entityManager .insert (getEntity ());
455457
456- CommunicationEdge communicationEdge = entityManager .edge (person1 , "FRIEND " , person2 , Map .of ());
458+ CommunicationEdge communicationEdge = entityManager .edge (person1 , "friend " , person2 , Map .of ());
457459
458- entityManager .remove (person1 , "FRIEND " , person2 );
460+ entityManager .remove (person1 , "friend " , person2 );
459461
460462 var edges = entityManager .findEdgeById (communicationEdge .id ());
461463
@@ -467,7 +469,7 @@ void shouldDeleteEdgeById() {
467469 var person1 = entityManager .insert (getEntity ());
468470 var person2 = entityManager .insert (getEntity ());
469471
470- var edge = entityManager .edge (person1 , "FRIEND " , person2 , Map .of ());
472+ var edge = entityManager .edge (person1 , "friend " , person2 , Map .of ());
471473
472474 entityManager .deleteEdge (edge .id ());
473475
@@ -480,15 +482,15 @@ void shouldFindEdgeById() {
480482 var person1 = entityManager .insert (getEntity ());
481483 var person2 = entityManager .insert (getEntity ());
482484
483- var edge = entityManager .edge (person1 , "FRIEND " , person2 , Map .of ("since" , 2023 ));
485+ var edge = entityManager .edge (person1 , "friend " , person2 , Map .of ("since" , 2023 ));
484486
485487 Optional <CommunicationEdge > foundEdge = entityManager .findEdgeById (edge .id ());
486488
487489 assertTrue (foundEdge .isPresent ());
488490 assertEquals (edge .id (), foundEdge .get ().id ());
489491 assertEquals (edge .label (), foundEdge .get ().label ());
490- assertEquals (edge .source ().find ("_id" ).orElseThrow ().get (), foundEdge .get ().source ().find ("_id" ).orElseThrow ().get ());
491- assertEquals (edge .target ().find ("_id" ).orElseThrow ().get (), foundEdge .get ().target ().find ("_id" ).orElseThrow ().get ());
492+ assertEquals (edge .source ().find (ID ).orElseThrow ().get (), foundEdge .get ().source ().find (ID ).orElseThrow ().get ());
493+ assertEquals (edge .target ().find (ID ).orElseThrow ().get (), foundEdge .get ().target ().find (ID ).orElseThrow ().get ());
492494 }
493495
494496 @ Test
0 commit comments