Changeset 247 for branches/new-datamodel


Ignore:
Timestamp:
03/22/10 18:49:05 (15 years ago)
Author:
lgiessmann
Message:

new-datamodel: added some unit-test for "make-construct" --> "VersionedConstructC" and unknown class; fixed a problem in "make-construct" that appears when creating "VersionedConstructC"s

Location:
branches/new-datamodel/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/new-datamodel/src/model/datamodel.lisp

    r246 r247  
    26932693   specific keyword arguments for their purpose."
    26942694  (declare (symbol class-symbol))
     2695  (when (and (VersionedConstructC-p class-symbol)
     2696             (not (getf args :start-revision)))
     2697    (error "From make-construct(): start-revision must be set"))
    26952698  (let ((construct
    26962699         (cond
     
    27082711            (apply #'make-association args))
    27092712           ((VersionedConstructC-p class-symbol)
    2710             (apply #'make-instance (rec-remf args :start-revision)))
     2713            (apply #'make-instance class-symbol
     2714                   (rec-remf args :start-revision)))
    27112715           (t
    27122716            (apply #'make-instance class-symbol args))))
     
    27192723                         :start-revision start-revision))
    27202724    (when (typep construct 'VersionedConstructC)
    2721       (unless start-revision
    2722         (error "From make-construct(): start-revision must be set"))
    27232725      (add-to-version-history construct :start-revision start-revision))
    27242726    (if (typep construct 'ReifiableConstructC)
  • TabularUnified branches/new-datamodel/src/unit_tests/datamodel_test.lisp

    r246 r247  
    6060           :test-equivalent-TopicMapC
    6161           :test-class-p
    62            :test-find-item-by-revision))
     62           :test-find-item-by-revision
     63           :test-make-Unknown
     64           :test-make-VersionedConstructC))
    6365
    6466
     
    18751877
    18761878
     1879(test test-make-Unknown ()
     1880  "Tests the function make-construct corresponding to an unknown class."
     1881  (defclass Unknown ()
     1882    ((value :initarg :value
     1883            :accessor value)))
     1884  (let ((construct (make-construct 'Unknown :value "value")))
     1885    (is-true construct)
     1886    (string= (value construct) "value")))
     1887
     1888
     1889(test test-make-VersionedConstructC ()
     1890  "Tests the function make-construct corresponding to VersionedConstructC."
     1891  (with-fixture with-empty-db (*db-dir*)
     1892    (let ((psi-1 (make-instance 'PersistentIdC :uri "psi-1"))
     1893          (top-1 (make-instance 'TopicC))
     1894          (rev-0 0)
     1895          (rev-1 100)
     1896          (rev-2 200))
     1897      (let ((vc (make-construct 'VersionedConstructC
     1898                                :start-revision rev-2))
     1899            (psi-assoc (make-construct 'd::PersistentIdAssociationC
     1900                                       :start-revision rev-1
     1901                                       :identifier psi-1
     1902                                       :parent-construct top-1)))
     1903        (signals error (make-construct 'd::PersistentIdAssociationC
     1904                                       :start-revision rev-1
     1905                                       :identifier psi-1))
     1906        (signals error (make-construct 'VersionedConstructC))
     1907        (is (= (length (d::versions vc)) 1))
     1908        (is-true (find-if #'(lambda(vi)
     1909                              (and (= (d::start-revision vi) rev-2)
     1910                                   (= (d::end-revision vi) rev-0)))
     1911                          (d::versions vc)))
     1912        (is (= (length (d::versions psi-assoc)) 1))
     1913        (is-true (find-if #'(lambda(vi)
     1914                              (and (= (d::start-revision vi) rev-1)
     1915                                   (= (d::end-revision vi) rev-0)))
     1916                          (d::versions psi-assoc)))))))
     1917
     1918
    18771919
    18781920
     
    19191961  (it.bese.fiveam:run! 'test-class-p)
    19201962  (it.bese.fiveam:run! 'test-find-item-by-revision)
     1963  (it.bese.fiveam:run! 'test-make-Unknown)
     1964  (it.bese.fiveam:run! 'test-make-VersionedConstructC)
    19211965  )
Note: See TracChangeset for help on using the changeset viewer.