|
15 | 15 | package org.eclipse.jnosql.databases.neo4j.integration; |
16 | 16 |
|
17 | 17 | import jakarta.inject.Inject; |
| 18 | +import org.assertj.core.api.SoftAssertions; |
18 | 19 | import org.eclipse.jnosql.databases.neo4j.communication.DatabaseContainer; |
19 | 20 | import org.eclipse.jnosql.databases.neo4j.communication.Neo4JConfigurations; |
20 | 21 | import org.eclipse.jnosql.databases.neo4j.mapping.Neo4JTemplate; |
@@ -117,6 +118,32 @@ void shouldCreateEdge() { |
117 | 118 | Magazine firstEdition = template.insert(new Magazine(null, "Effective Java", 1)); |
118 | 119 | Magazine secondEdition = template.insert(new Magazine(null, "Effective Java", 2)); |
119 | 120 | Edge<Magazine, Magazine> edge = Edge.source(firstEdition).label("NEXT").target(secondEdition).property("year", 2025).build(); |
120 | | - template.edge(edge); |
| 121 | + Edge<Magazine, Magazine> magazineEdge = template.edge(edge); |
| 122 | + |
| 123 | + SoftAssertions.assertSoftly(soft -> { |
| 124 | + soft.assertThat(magazineEdge.source()).isEqualTo(firstEdition); |
| 125 | + soft.assertThat(magazineEdge.target()).isEqualTo(secondEdition); |
| 126 | + soft.assertThat(magazineEdge.label()).isEqualTo("NEXT"); |
| 127 | + soft.assertThat(magazineEdge.property("year", Integer.class)).contains(2025); |
| 128 | + soft.assertThat(magazineEdge.id()).isPresent(); |
| 129 | + }); |
| 130 | + } |
| 131 | + |
| 132 | + @Test |
| 133 | + void shouldCreateEdgeFromNullId() { |
| 134 | + Magazine firstEdition = new Magazine(null, "Effective Java", 1); |
| 135 | + Magazine secondEdition = new Magazine(null, "Effective Java", 2); |
| 136 | + Edge<Magazine, Magazine> edge = Edge.source(firstEdition).label("NEXT").target(secondEdition).property("year", 2025).build(); |
| 137 | + Edge<Magazine, Magazine> magazineEdge = template.edge(edge); |
| 138 | + |
| 139 | + SoftAssertions.assertSoftly(soft -> { |
| 140 | + soft.assertThat(magazineEdge.source()).isNotNull(); |
| 141 | + soft.assertThat(magazineEdge.source().id()).isNotNull(); |
| 142 | + soft.assertThat(magazineEdge.target()).isNotNull(); |
| 143 | + soft.assertThat(magazineEdge.target().id()).isNotNull(); |
| 144 | + soft.assertThat(magazineEdge.label()).isEqualTo("NEXT"); |
| 145 | + soft.assertThat(magazineEdge.property("year", Integer.class)).contains(2025); |
| 146 | + soft.assertThat(magazineEdge.id()).isPresent(); |
| 147 | + }); |
121 | 148 | } |
122 | 149 | } |
0 commit comments