|
29 | 29 | import static org.junit.Assert.fail;
|
30 | 30 |
|
31 | 31 | import java.util.ArrayList;
|
| 32 | +import java.util.Arrays; |
32 | 33 | import java.util.Collection;
|
33 | 34 |
|
34 | 35 | import com.arangodb.model.*;
|
@@ -128,6 +129,30 @@ public void insertEdgeUpdateRev() {
|
128 | 129 | assertThat(value.getRevision(), is(edge.getRev()));
|
129 | 130 | }
|
130 | 131 |
|
| 132 | + @Test |
| 133 | + public void insertEdgeViolatingUniqueConstraint() { |
| 134 | + db.collection(EDGE_COLLECTION_NAME) |
| 135 | + .ensureSkiplistIndex(Arrays.asList("_from", "_to"), new SkiplistIndexOptions().unique(true)); |
| 136 | + |
| 137 | + final VertexEntity v1 = db.graph(GRAPH_NAME).vertexCollection(VERTEX_COLLECTION_NAME) |
| 138 | + .insertVertex(new BaseDocument("v1"), null); |
| 139 | + final VertexEntity v2 = db.graph(GRAPH_NAME).vertexCollection(VERTEX_COLLECTION_NAME) |
| 140 | + .insertVertex(new BaseDocument("v2"), null); |
| 141 | + |
| 142 | + BaseEdgeDocument edge = new BaseEdgeDocument(); |
| 143 | + edge.setFrom(v1.getId()); |
| 144 | + edge.setTo(v2.getId()); |
| 145 | + |
| 146 | + db.graph(GRAPH_NAME).edgeCollection(EDGE_COLLECTION_NAME).insertEdge(edge, null); |
| 147 | + |
| 148 | + try { |
| 149 | + db.graph(GRAPH_NAME).edgeCollection(EDGE_COLLECTION_NAME).insertEdge(edge, null); |
| 150 | + } catch (ArangoDBException e) { |
| 151 | + assertThat(e.getResponseCode(), is(409)); |
| 152 | + assertThat(e.getErrorNum(), is(1210)); |
| 153 | + } |
| 154 | + } |
| 155 | + |
131 | 156 | @Test
|
132 | 157 | public void getEdge() {
|
133 | 158 | final BaseEdgeDocument value = createEdgeValue();
|
|
0 commit comments