Changeset 437


Ignore:
Timestamp:
04/29/11 08:26:47 (14 years ago)
Author:
lgiessmann
Message:

JTM: added a unit-tests for the function export-instance-ofs-to-jtm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/unit_tests/jtm_test.lisp

    r436 r437  
    2424           :test-type-scopes-reifier-to-jtm
    2525           :test-parent-reference-to-jtm
    26            :run-jtm-tests))
     26           :run-jtm-tests
     27           :test-instance-ofs-to-jtm))
    2728
    2829
     
    425426
    426427
    427 ;TODO: *export-instance-ofs
     428(test test-instance-ofs-to-jtm
     429  "Tests the function export-instance-ofs-to-jtm."
     430  (with-fixture with-empty-db ("data_base")
     431    (let* ((top-1 (make-construct 'TopicC :start-revision 100
     432                                  :psis
     433                                  (list
     434                                   (make-construct 'PersistentIdC
     435                                                   :uri "http://some.where/example#psi-1"))))
     436           (top-2 (make-construct 'TopicC :start-revision 100
     437                                  :locators
     438                                  (list
     439                                   (make-construct 'SubjectLocatorC
     440                                                   :uri "http://some.where/example#sl-1"))))
     441           (top-3 (make-construct 'TopicC :start-revision 100
     442                                  :item-identifiers
     443                                  (list
     444                                   (make-construct 'ItemIdentifierC
     445                                                   :uri "http://some.where/example#ii-1"))))
     446           (top-4 (make-construct 'TopicC :start-revision 100))
     447           (top-5 (make-construct 'TopicC :start-revision 100))
     448           (tit (make-construct 'TopicC :start-revision 100
     449                                :psis (list (make-construct
     450                                             'PersistentIdC
     451                                             :uri *type-instance-psi*))))
     452           (it (make-construct 'TopicC :start-revision 100
     453                               :psis (list (make-construct 'PersistentIdC
     454                                                           :uri *instance-psi*))))
     455           (tt (make-construct 'TopicC :start-revision 100
     456                               :psis (list (make-construct 'PersistentIdC
     457                                                           :uri *type-psi*))))
     458           (prefixes (list (list :pref "pref_1" :value "http://some.where/"))))
     459      (make-construct 'AssociationC :start-revision 100
     460                      :roles (list (list :player top-1 :instance-of tt
     461                                         :start-revision 100)
     462                                   (list :player top-4 :instance-of it
     463                                         :start-revision 100))
     464                      :instance-of tit)
     465      (make-construct 'AssociationC :start-revision 100
     466                      :roles (list (list :player top-2 :instance-of tt
     467                                         :start-revision 100)
     468                                   (list :player top-4 :instance-of it
     469                                         :start-revision 100))
     470                      :instance-of tit)
     471      (make-construct 'AssociationC :start-revision 100
     472                      :roles (list (list :player top-3 :instance-of tt
     473                                         :start-revision 100)
     474                                   (list :player top-5 :instance-of it
     475                                         :start-revision 100))
     476                      :instance-of tit)
     477      (setf *TM-REVISION* 0)
     478      (is (string= (jtm::export-instance-ofs-to-jtm top-5)
     479                   "[\"ii:http:\\/\\/some.where\\/example#ii-1\"]"))
     480      (is (string= (jtm::export-instance-ofs-to-jtm top-5 :prefixes prefixes)
     481                   "[\"ii:[pref_1:example#ii-1]\"]"))
     482      (is (string= (jtm::export-instance-ofs-to-jtm top-1)
     483                   "null"))
     484      (is (or (string= (jtm::export-instance-ofs-to-jtm top-4)
     485                       "[\"si:http:\\/\\/some.where\\/example#psi-1\",\"sl:http:\\/\\/some.where\\/example#sl-1\"]")
     486              (string= (jtm::export-instance-ofs-to-jtm top-4)
     487                       "[\"sl:http:\\/\\/some.where\\/example#sl-1\",\"si:http:\\/\\/some.where\\/example#psi-1\"]")))
     488      (is (or (string= (jtm::export-instance-ofs-to-jtm top-4 :prefixes prefixes)
     489                       "[\"si:[pref_1:example#psi-1]\",\"sl:[pref_1:example#sl-1]\"]")
     490              (string= (jtm::export-instance-ofs-to-jtm top-4 :prefixes prefixes)
     491                       "[\"sl:[pref_1:example#sl-1]\",\"si:[pref_1:example#psi-1]\"]")))
     492      (make-construct 'AssociationC :start-revision 100
     493                      :roles (list (list :player top-4 :instance-of tt
     494                                         :start-revision 100)
     495                                   (list :player top-5 :instance-of it
     496                                         :start-revision 100))
     497                      :instance-of tit)
     498      (signals exceptions:JTM-error (jtm::export-instance-ofs-to-jtm top-5)))))
     499
     500
     501
    428502
    429503(defun run-jtm-tests()
Note: See TracChangeset for help on using the changeset viewer.