# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


from tmapi.exceptions import ModelConstraintException
from tmapi_test_case import TMAPITestCase
        sid = self.create_locator('http://www.tmapi.org/test/me')
        topic = self.tm.create_topic_by_subject_identifier(sid)
        self.assertEqual(1, self.tm.get_topics().count())
        self.assertEqual(topic, self.tm.get_topic_by_subject_identifier(sid))
        topic.merge_in(topic)
        self.assertEqual(1, self.tm.get_topics().count())
        self.assertEqual(topic, self.tm.get_topic_by_subject_identifier(sid))

    def test_types_merged (self):
        """Tests if the types are also merged."""
        t1 = self.create_topic()
        t2 = self.create_topic()
        t3 = self.create_topic()
        t2.add_type(t3)
        self.assertTrue(t3 in t2.get_types())
        self.assertEqual(0, t1.get_types().count())
        t1.merge_in(t2)
        self.assertTrue(t3 in t1.get_types(), 'Topic must have a type now')

    def test_reified_clash (self):
        """If topics reify different Topic Maps constructs, they
        cannot be merged."""
        topic1 = self.create_topic()
        topic2 = self.create_topic()
        association1 = self.create_association()
        association2 = self.create_association()
        association1.set_reifier(topic1)
        association2.set_reifier(topic2)
        self.assertEqual(topic1, association1.get_reifier())
        self.assertEqual(topic2, association2.get_reifier())

# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


# Path: tmapi/tests/models/test_topic_merge.py
from tmapi.exceptions import ModelConstraintException
from tmapi_test_case import TMAPITestCase

        sid = self.create_locator('http://www.tmapi.org/test/me')
        topic = self.tm.create_topic_by_subject_identifier(sid)
        self.assertEqual(1, self.tm.get_topics().count())
        self.assertEqual(topic, self.tm.get_topic_by_subject_identifier(sid))
        topic.merge_in(topic)
        self.assertEqual(1, self.tm.get_topics().count())
        self.assertEqual(topic, self.tm.get_topic_by_subject_identifier(sid))

    def test_types_merged (self):
        """Tests if the types are also merged."""
        t1 = self.create_topic()
        t2 = self.create_topic()
        t3 = self.create_topic()
        t2.add_type(t3)
        self.assertTrue(t3 in t2.get_types())
        self.assertEqual(0, t1.get_types().count())
        t1.merge_in(t2)
        self.assertTrue(t3 in t1.get_types(), 'Topic must have a type now')

    def test_reified_clash (self):
        """If topics reify different Topic Maps constructs, they
        cannot be merged."""
        topic1 = self.create_topic()
        topic2 = self.create_topic()
        association1 = self.create_association()
        association2 = self.create_association()
        association1.set_reifier(topic1)
        association2.set_reifier(topic2)
        self.assertEqual(topic1, association1.get_reifier())
        self.assertEqual(topic2, association2.get_reifier())

        self.assertRaises(ModelConstraintException, topic1.merge_in, topic2)