Created
August 11, 2010 20:40
-
-
Save c-spencer/519704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'clojure.test) | |
(testing "Initialising" | |
(start "var/test") | |
(are [x y] (= x y) | |
(.getClass *neo*) EmbeddedGraphDatabase | |
(.getClass *lucene* LuceneFullTextIndexService))) | |
(testing "Homogeneous Nodes" | |
(register-indices #{"message"}) | |
(let [first-node (node! {:message "FirstNode"}) | |
second-node (node! {:message "SecondNode"}) | |
third-node (node! {:message "ThirdNode"}) | |
relation (relate! first-node :knows second-node {:message "ARelation"})] | |
(testing "Properties, dereferencing" | |
(are [x y] (= x y) | |
{:message "FirstNode"} @first-node | |
{:message "ARelation"} @relation | |
first-node (start-node relation))) | |
(testing "Traversal" | |
(are [x y] (= x y) | |
1 (count (related first-node :knows)) | |
0 (count (related first-node :some-label))) | |
0 (count (related first-node :knows incoming)) | |
1 (count (related first-node :knows outgoing)) | |
1 (count (related second-node :knows incoming)) | |
0 (count (related third-node :knows))) | |
(testing "Searching" | |
(let [search (find-nodes "message" "FirstNode")] | |
(are [x y] (= x y) | |
1 (count search) | |
first-node (first search) | |
0 (count (find-nodes :message "ARelation")) | |
0 (count (find-nodes :not-an-index "FirstNode"))))) | |
(testing "Invalid Transactions" | |
(are [x] (thrown? TransactionFailureException x) | |
(delete! first-node) | |
(do-tx (failure)))) | |
(testing "Deletion" | |
(do-tx | |
(delete! relation) | |
(delete! first-node)) | |
(is (thrown? Exception @first-node)) | |
(is (thrown? Exception @relation)) | |
(is @second-node) | |
(delete! second-node) | |
(is (thrown? Exception @second-node))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment