|
| 1 | +/* |
| 2 | + * Copyright (C) 2012 tamtam180 |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.arangodb; |
| 18 | + |
| 19 | +import static org.hamcrest.CoreMatchers.instanceOf; |
| 20 | +import static org.hamcrest.CoreMatchers.is; |
| 21 | +import static org.hamcrest.CoreMatchers.not; |
| 22 | +import static org.hamcrest.CoreMatchers.notNullValue; |
| 23 | +import static org.hamcrest.CoreMatchers.nullValue; |
| 24 | +import static org.junit.Assert.assertThat; |
| 25 | +import static org.junit.Assert.fail; |
| 26 | + |
| 27 | +import java.util.Arrays; |
| 28 | +import java.util.Set; |
| 29 | +import java.util.TreeSet; |
| 30 | + |
| 31 | +import org.junit.After; |
| 32 | +import org.junit.Before; |
| 33 | +import org.junit.Test; |
| 34 | +import org.slf4j.Logger; |
| 35 | +import org.slf4j.LoggerFactory; |
| 36 | + |
| 37 | +import com.arangodb.entity.CollectionEntity; |
| 38 | +import com.arangodb.entity.DocumentEntity; |
| 39 | +import com.arangodb.entity.EdgeEntity; |
| 40 | + |
| 41 | +/** |
| 42 | + * @author tamtam180 - kirscheless at gmail.com |
| 43 | + */ |
| 44 | +public class ArangoDriverEdgeTest extends BaseTest { |
| 45 | + |
| 46 | + public ArangoDriverEdgeTest(ArangoConfigure configure, ArangoDriver driver) { |
| 47 | + super(configure, driver); |
| 48 | + } |
| 49 | + |
| 50 | + final String collectionName = "unit_test_edge_collection_EdgeTest"; |
| 51 | + final String collectionName2 = "unit_test_normal_collection_EdgeTest"; |
| 52 | + |
| 53 | + @Before |
| 54 | + public void before() throws ArangoException { |
| 55 | + try { |
| 56 | + driver.deleteCollection(collectionName); |
| 57 | + } catch (ArangoException e) { |
| 58 | + } |
| 59 | + try { |
| 60 | + driver.deleteCollection(collectionName2); |
| 61 | + } catch (ArangoException e) { |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + @After |
| 66 | + public void after() throws ArangoException { |
| 67 | + try { |
| 68 | + driver.deleteCollection(collectionName); |
| 69 | + } catch (ArangoException e) { |
| 70 | + } |
| 71 | + try { |
| 72 | + driver.deleteCollection(collectionName2); |
| 73 | + } catch (ArangoException e) { |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + @Test |
| 78 | + public void test_create_normal() throws ArangoException { |
| 79 | + |
| 80 | + TestComplexEntity01 value = new TestComplexEntity01("user", "desc", 42); |
| 81 | + DocumentEntity<TestComplexEntity01> fromDoc = driver.createDocument(collectionName2, value, true, true); |
| 82 | + DocumentEntity<TestComplexEntity01> toDoc = driver.createDocument(collectionName2, value, true, true); |
| 83 | + |
| 84 | + EdgeEntity<TestComplexEntity01> doc = driver.createEdge( |
| 85 | + databaseName, |
| 86 | + collectionName, |
| 87 | + value, |
| 88 | + fromDoc.getDocumentHandle(), |
| 89 | + toDoc.getDocumentHandle(), |
| 90 | + true, |
| 91 | + true); |
| 92 | + |
| 93 | + assertThat(doc.getDocumentKey(), is(notNullValue())); |
| 94 | + assertThat(doc.getDocumentHandle(), is(collectionName + "/" + doc.getDocumentKey())); |
| 95 | + assertThat(doc.getDocumentRevision(), is(not(0L))); |
| 96 | + |
| 97 | + } |
| 98 | + |
| 99 | +} |
0 commit comments