Ignore:
Timestamp:
04/29/10 15:07:06 (15 years ago)
Author:
lgiessmann
Message:

new-datamodel: fixed two bugs in "merge-constructs" corresponding to "AssociationC"

File:
1 edited

Legend:

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

    r291 r292  
    9191           :test-merge-constructs-TopicC-8
    9292           :test-merge-constructs-TopicC-9
    93            :test-merge-constructs-TopicC-10))
     93           :test-merge-constructs-TopicC-10
     94           :test-merge-constructs-AssociationC))
    9495
    9596
     
    29392940
    29402941(test test-merge-constructs-TopicC-1 ()
    2941   "Tests the generic move-referenced-constructs corresponding to TopicC."
     2942  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    29422943  (with-fixture with-empty-db (*db-dir*)
    29432944    (let ((rev-1 100)
     
    30523053
    30533054(test test-merge-constructs-TopicC-2 ()
    3054   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3055  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    30553056  (with-fixture with-empty-db (*db-dir*)
    30563057    (let ((rev-1 100)
     
    31663167
    31673168(test test-merge-constructs-TopicC-3 ()
    3168   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3169  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    31693170  (with-fixture with-empty-db (*db-dir*)
    31703171    (let ((rev-1 100)
     
    32663267
    32673268(test test-merge-constructs-TopicC-4 ()
    3268   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3269  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    32693270  (with-fixture with-empty-db (*db-dir*)
    32703271    (let ((rev-1 100)
     
    33243325
    33253326(test test-merge-constructs-TopicC-5 ()
    3326   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3327  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    33273328  (with-fixture with-empty-db (*db-dir*)
    33283329    (let ((rev-1 100)
     
    33823383
    33833384(test test-merge-constructs-TopicC-6 ()
    3384   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3385  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    33853386  (with-fixture with-empty-db (*db-dir*)
    33863387    (let ((rev-1 100)
     
    34533454
    34543455(test test-merge-constructs-TopicC-7 ()
    3455   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3456  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    34563457  (with-fixture with-empty-db (*db-dir*)
    34573458    (let ((rev-1 100)
     
    35223523
    35233524(test test-merge-constructs-TopicC-8 ()
    3524   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3525  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    35253526  (with-fixture with-empty-db (*db-dir*)
    35263527    (let ((rev-1 100)
     
    35883589
    35893590(test test-merge-constructs-TopicC-9 ()
    3590   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3591  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    35913592  (with-fixture with-empty-db (*db-dir*)
    35923593    (let ((rev-1 100)
     
    36423643
    36433644(test test-merge-constructs-TopicC-10 ()
    3644   "Tests the generic move-referenced-constructs corresponding to TopicC."
     3645  "Tests the generic merge-constructs corresÃŒponding to TopicC."
    36453646  (with-fixture with-empty-db (*db-dir*)
    36463647    (let ((rev-1 100)
     
    37173718            (is-false (set-exclusive-or (list variant-2) (variants name-4)))
    37183719            (is (= (length (d::versions top-1)) 2))))))))
    3719                                      
    3720 
    3721 
    3722 ;;TODO: merge associations caused by a merge of their roles
    3723 
    3724 
     3720
     3721
     3722(test test-merge-constructs-AssociationC ()
     3723  "Tests merge-constructs corresponding to AssociationC."
     3724  (with-fixture with-empty-db (*db-dir*)
     3725    (let ((rev-1 100)
     3726          (rev-2 200)
     3727          (rev-3 300))
     3728      (let ((type-1 (make-construct 'TopicC :start-revision rev-1))
     3729            (r-type-1 (make-construct 'TopicC :start-revision rev-1))
     3730            (r-type-2 (make-construct 'TopicC :start-revision rev-1))
     3731            (player-1 (make-construct 'TopicC :start-revision rev-1))
     3732            (player-2 (make-construct 'TopicC :start-revision rev-1))
     3733            (ii-1 (make-construct 'ItemIdentifierC :uri "ii-1"))
     3734            (ii-2 (make-construct 'ItemIdentifierC :uri "ii-2")))
     3735        (let ((role-1 (list :start-revision rev-1
     3736                            :player player-1
     3737                            :instance-of r-type-1))
     3738              (role-2-1 (list :start-revision rev-1
     3739                              :player player-1
     3740                              :instance-of r-type-2))
     3741              (role-2-2 (list :start-revision rev-2
     3742                              :player player-1
     3743                              :item-identifiers (list ii-2)
     3744                              :instance-of r-type-2))
     3745              (role-3 (list :start-revision rev-2
     3746                            :player player-2
     3747                            :instance-of r-type-1
     3748                            :item-identifiers (list ii-1)
     3749                            :instance-of r-type-2)))
     3750          (let ((assoc-1 (make-construct 'AssociationC
     3751                                         :start-revision rev-1
     3752                                         :instance-of type-1
     3753                                         :roles (list role-1 role-2-1)))
     3754                (assoc-2 (make-construct 'AssociationC
     3755                                         :start-revision rev-2
     3756                                         :instance-of type-1
     3757                                         :roles (list role-2-2 role-3))))
     3758            (setf *TM-REVISION* rev-3)
     3759            (is (= (length (get-all-associations nil)) 2))
     3760            (make-construct 'AssociationC
     3761                            :start-revision rev-2
     3762                            :instance-of type-1
     3763                            :roles (list role-1 role-2-1))
     3764            (is (= (length (get-all-associations nil)) 2))
     3765            (let ((role-2-1-inst
     3766                   (find-if #'(lambda(role)
     3767                                (and (eql (instance-of role) r-type-2)
     3768                                     (eql (player role) player-1)))
     3769                            (roles assoc-1))))
     3770              (is-true role-2-1-inst)
     3771              (is (eql (add-item-identifier role-2-1-inst ii-2) role-2-1-inst))
     3772              (is-true (marked-as-deleted-p assoc-2))
     3773              (is-false (roles assoc-2))
     3774              (is-false (instance-of assoc-2))
     3775              (is-false (themes assoc-2))
     3776              (is (eql (instance-of assoc-2 :revision rev-2) type-1))
     3777              (is (= (length (roles assoc-1)) 3))
     3778              (is-true (find-if #'(lambda(role)
     3779                                    (and (eql (instance-of role) r-type-1)
     3780                                         (eql (player role) player-1)))
     3781                                (roles assoc-1)))
     3782              (is-true (find-if #'(lambda(role)
     3783                                    (and (eql (instance-of role) r-type-1)
     3784                                         (eql (player role) player-2)
     3785                                         (not (set-exclusive-or
     3786                                               (list ii-1)
     3787                                               (item-identifiers role)))))
     3788                                (roles assoc-1)))
     3789              (is-true (find-if #'(lambda(role)
     3790                                    (and (eql (instance-of role) r-type-2)
     3791                                         (eql (player role) player-1)
     3792                                         (not (set-exclusive-or
     3793                                               (list ii-2)
     3794                                               (item-identifiers role)))))
     3795                                (roles assoc-1))))))))))
    37253796
    37263797
     
    37933864  (it.bese.fiveam:run! 'test-merge-constructs-TopicC-9)
    37943865  (it.bese.fiveam:run! 'test-merge-constructs-TopicC-10)
    3795   )
     3866  (it.bese.fiveam:run! 'test-merge-constructs-AssociationC))
Note: See TracChangeset for help on using the changeset viewer.