Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkPropertyRelationRuleBaseTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include "mitkDataNode.h"
16 #include "mitkPointSet.h"
17 #include "mitkStringProperty.h"
18 
19 #include "mitkTestFixture.h"
20 #include "mitkTestingMacros.h"
21 
22 #include <regex>
23 
26 namespace mitk
27 {
28  class TestRule : public mitk::PropertyRelationRuleBase
29  {
30  public:
32  itkFactorylessNewMacro(Self);
33  itkCloneMacro(Self);
34 
35  using RuleIDType = PropertyRelationRuleBase::RuleIDType;
36  using RelationUIDType = PropertyRelationRuleBase::RelationUIDType;
37  using RelationUIDVectorType = PropertyRelationRuleBase::RelationUIDVectorType;
38 
39  RuleIDType GetRuleID() const override
40  {
41  if (m_AbstractMode)
42  {
43  return "TestRule";
44  }
45  else
46  {
47  return "TestRule_type1";
48  }
49  };
50 
51  std::string GetDisplayName() const override { return "TestDisplayName"; }
52  std::string GetSourceRoleName() const override { return "source role"; }
53  std::string GetDestinationRoleName() const override { return "destination role"; }
54 
55  bool m_AbstractMode;
56 
57  bool IsAbstract() const override { return m_AbstractMode; }
58 
59  using Superclass::GetRootKeyPath;
60  using Superclass::Connect;
61 
62  protected:
63  TestRule() : m_AbstractMode(false)
64  {
65  };
66 
67  ~TestRule() override = default;
68 
69  using InstanceIDType = PropertyRelationRuleBase::InstanceIDType;
70  using InstanceIDVectorType = PropertyRelationRuleBase::InstanceIDVectorType;
71 
72  bool IsSupportedRuleID(const RuleIDType& ruleID) const override
73  {
74  if (m_AbstractMode)
75  {
76  return ruleID.find(this->GetRuleID()) == 0;
77  }
78  else
79  {
80  return Superclass::IsSupportedRuleID(ruleID);
81  }
82  };
83 
84  InstanceIDVectorType GetInstanceID_datalayer(const IPropertyProvider *source,
85  const IPropertyProvider *destination) const override
86  {
87  InstanceIDVectorType result;
88 
89  auto destProp = destination->GetConstProperty("name");
90 
91  if (destProp.IsNotNull())
92  {
93  auto destRegExStr =
94  PropertyKeyPathToPropertyRegEx(Superclass::GetRootKeyPath().AddAnyElement().AddElement("dataHandle"));
95  auto regEx = std::regex(destRegExStr);
96  std::smatch instance_matches;
97 
98  auto keys = source->GetPropertyKeys();
99 
100  for (const auto &key : keys)
101  {
102  if (std::regex_search(key, instance_matches, regEx))
103  {
104  auto sourceProp = source->GetConstProperty(key);
105  if (sourceProp->GetValueAsString() == destProp->GetValueAsString())
106  {
107  if (instance_matches.size()>1)
108  {
109  result.push_back(instance_matches[1]);
110  }
111  }
112  }
113  }
114  }
115  return result;
116  };
117 
118  bool HasImplicitDataRelation(const IPropertyProvider *source,
119  const IPropertyProvider *destination) const override
120  {
121  auto destProp = destination->GetConstProperty("name");
122  auto sourceProp = source->GetConstProperty("referencedName");
123 
124  return destProp.IsNotNull() && sourceProp.IsNotNull() &&
125  destProp->GetValueAsString() == sourceProp->GetValueAsString();
126  };
127 
128  void Connect_datalayer(IPropertyOwner *source,
129  const IPropertyProvider *destination,
130  const InstanceIDType &instanceID) const override
131  {
132  auto destProp = destination->GetConstProperty("name");
133 
134  source->SetProperty("referencedName", StringProperty::New(destProp->GetValueAsString()));
135  source->SetProperty(
136  PropertyKeyPathToPropertyName(Superclass::GetRootKeyPath().AddElement(instanceID).AddElement("dataHandle")),
137  StringProperty::New(destProp->GetValueAsString()));
138  };
139 
140  void Disconnect_datalayer(IPropertyOwner *source, const InstanceIDType & /*instanceID*/) const override
141  {
142  source->RemoveProperty("referencedName");
143  };
144  };
145 } // namespace mitk
146 
147 class mitkPropertyRelationRuleBaseTestSuite : public mitk::TestFixture
148 {
149  CPPUNIT_TEST_SUITE(mitkPropertyRelationRuleBaseTestSuite);
150 
151  MITK_TEST(GetRootKeyPath);
152  MITK_TEST(IsSourceCandidate);
153  MITK_TEST(IsDestinationCandidate);
154  MITK_TEST(IsSource);
155  MITK_TEST(HasRelation);
156  MITK_TEST(GetExistingRelations);
157  MITK_TEST(GetRelationUIDs);
158  MITK_TEST(GetSourceCandidateIndicator);
159  MITK_TEST(GetDestinationCandidateIndicator);
160  MITK_TEST(GetConnectedSourcesDetector);
161  MITK_TEST(GetSourcesDetector);
162  MITK_TEST(GetDestinationsDetector);
163  MITK_TEST(GetDestinationDetector);
164  MITK_TEST(Connect);
165  MITK_TEST(Disconnect);
166  MITK_TEST(Connect_abstract);
167  MITK_TEST(Disconnect_abstract);
168 
169  CPPUNIT_TEST_SUITE_END();
170 
171 private:
173  mitk::TestRule::Pointer abstractRule;
174 
175  mitk::DataNode::Pointer unRelated;
176  mitk::PointSet::Pointer unRelated_1_data;
177 
178  mitk::DataNode::Pointer source_implicit_1;
179  mitk::DataNode::Pointer source_data_1;
180  mitk::DataNode::Pointer source_idOnly_1;
181  mitk::DataNode::Pointer source_1;
182 
183  mitk::DataNode::Pointer source_multi;
184 
185  mitk::DataNode::Pointer source_otherRule;
186 
187  mitk::DataNode::Pointer source_otherTypeRule; //relevant for abstract rule checks. Abstract rule should see it concrete rule not.
188 
190  mitk::PointSet::Pointer dest_1_data;
192  mitk::PointSet::Pointer dest_2_data;
193 
194  bool hasRelationProperties(mitk::IPropertyProvider *provider, std::string instance = "") const
195  {
197  if (!instance.empty())
198  {
199  keyPath.AddElement(instance);
200  }
201 
202  auto prefix = mitk::PropertyKeyPathToPropertyName(keyPath);
203  auto keys = provider->GetPropertyKeys();
204 
205  for (const auto &key : keys)
206  {
207  if (key.find(prefix) == 0)
208  {
209  return true;
210  }
211  }
212 
213  return false;
214  }
215 
216 public:
217  void setUp() override
218  {
219  rule = mitk::TestRule::New();
220 
221  abstractRule = mitk::TestRule::New();
222  abstractRule->m_AbstractMode = true;
223 
224  unRelated = mitk::DataNode::New();
225  unRelated->SetName("unRelated");
226  unRelated_1_data = mitk::PointSet::New();
227  unRelated->SetData(unRelated_1_data);
228 
229  dest_1 = mitk::DataNode::New();
230  dest_1->SetName("dest_1");
231  dest_1_data = mitk::PointSet::New();
232  dest_1->SetData(dest_1_data);
233 
234  dest_2 = mitk::DataNode::New();
235  dest_2->SetName("dest_2");
236  dest_2_data = mitk::PointSet::New();
237  dest_2->SetData(dest_2_data);
238 
239  source_implicit_1 = mitk::DataNode::New();
240  source_implicit_1->AddProperty("referencedName", mitk::StringProperty::New(dest_1->GetName()));
241 
242  source_idOnly_1 = mitk::DataNode::New();
243  std::string name = "MITK.Relations.1.relationUID";
244  source_idOnly_1->AddProperty(name.c_str(), mitk::StringProperty::New("uid1"));
245  name = "MITK.Relations.1.destinationUID";
246  source_idOnly_1->AddProperty(name.c_str(), mitk::StringProperty::New(dest_1_data->GetUID()));
247  name = "MITK.Relations.1.ruleID";
248  source_idOnly_1->AddProperty(name.c_str(), mitk::StringProperty::New(rule->GetRuleID()));
249 
250  source_data_1 = source_implicit_1->Clone();
251  name = "MITK.Relations.1.relationUID";
252  source_data_1->AddProperty(name.c_str(), mitk::StringProperty::New("uid2"));
253  name = "MITK.Relations.1.dataHandle";
254  source_data_1->AddProperty(name.c_str(), mitk::StringProperty::New(dest_1->GetName()));
255  name = "MITK.Relations.1.ruleID";
256  source_data_1->AddProperty(name.c_str(), mitk::StringProperty::New(rule->GetRuleID()));
257  name = "MITK.Relations.2.relationUID";
258  source_data_1->AddProperty(name.c_str(), mitk::StringProperty::New("uid10"), nullptr, true);
259  name = "MITK.Relations.2.destinationUID";
260  source_data_1->AddProperty(name.c_str(), mitk::StringProperty::New(dest_1_data->GetUID()));
261  name = "MITK.Relations.2.ruleID";
262  source_data_1->AddProperty(name.c_str(), mitk::StringProperty::New("TestRule_othertype"));
263 
264  source_1 = source_data_1->Clone();
265  name = "MITK.Relations.1.relationUID";
266  source_1->AddProperty(name.c_str(), mitk::StringProperty::New("uid3"), nullptr, true);
267  name = "MITK.Relations.1.destinationUID";
268  source_1->AddProperty(name.c_str(), mitk::StringProperty::New(dest_1_data->GetUID()));
269  name = "MITK.Relations.1.ruleID";
270  source_1->AddProperty(name.c_str(), mitk::StringProperty::New(rule->GetRuleID()));
271  name = "MITK.Relations.2.relationUID";
272  source_1->AddProperty(name.c_str(), mitk::StringProperty::New("uid8"), nullptr, true);
273  name = "MITK.Relations.2.destinationUID";
274  source_1->AddProperty(name.c_str(), mitk::StringProperty::New(dest_2_data->GetUID()));
275  name = "MITK.Relations.2.ruleID";
276  source_1->AddProperty(name.c_str(), mitk::StringProperty::New("TestRule_othertype"));
277 
278  source_multi = source_1->Clone();
279  name = "MITK.Relations.1.relationUID";
280  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New("uid4"), nullptr, true);
281  name = "MITK.Relations.1.destinationUID";
282  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New(dest_1_data->GetUID()));
283  name = "MITK.Relations.1.ruleID";
284  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New(rule->GetRuleID()));
285  name = "MITK.Relations.4.relationUID";
286  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New("uid5"));
287  name = "MITK.Relations.4.destinationUID";
288  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New(dest_2_data->GetUID()));
289  name = "MITK.Relations.4.ruleID";
290  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New(rule->GetRuleID()));
291  name = "MITK.Relations.2.relationUID";
292  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New("uid6"));
293  name = "MITK.Relations.2.destinationUID";
294  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New("unknown"));
295  name = "MITK.Relations.2.ruleID";
296  source_multi->AddProperty(name.c_str(), mitk::StringProperty::New(rule->GetRuleID()));
297 
298  source_otherRule = mitk::DataNode::New();
299  name = "MITK.Relations.1.relationUID";
300  source_otherRule->AddProperty(name.c_str(), mitk::StringProperty::New("uid7"));
301  name = "MITK.Relations.1.destinationUID";
302  source_otherRule->AddProperty(name.c_str(), mitk::StringProperty::New(dest_1_data->GetUID()));
303  name = "MITK.Relations.1.ruleID";
304  source_otherRule->AddProperty(name.c_str(), mitk::StringProperty::New("otherRuleID"));
305 
306  source_otherTypeRule = mitk::DataNode::New();
307  name = "MITK.Relations.1.relationUID";
308  source_otherTypeRule->AddProperty(name.c_str(), mitk::StringProperty::New("uid9"));
309  name = "MITK.Relations.1.destinationUID";
310  source_otherTypeRule->AddProperty(name.c_str(), mitk::StringProperty::New(dest_1_data->GetUID()));
311  name = "MITK.Relations.1.ruleID";
312  source_otherTypeRule->AddProperty(name.c_str(), mitk::StringProperty::New("TestRule_othertype"));
313  }
314 
315  void tearDown() override {}
316 
317  void GetRootKeyPath()
318  {
320  ref.AddElement("MITK").AddElement("Relations");
321  CPPUNIT_ASSERT(mitk::PropertyRelationRuleBase::GetRootKeyPath() == ref);
322  }
323 
324  void IsSourceCandidate()
325  {
326  CPPUNIT_ASSERT(rule->IsSourceCandidate(mitk::DataNode::New()));
327  CPPUNIT_ASSERT(!rule->IsSourceCandidate(nullptr));
328  }
329 
330  void IsDestinationCandidate()
331  {
332  CPPUNIT_ASSERT(rule->IsDestinationCandidate(mitk::DataNode::New()));
333  CPPUNIT_ASSERT(!rule->IsDestinationCandidate(nullptr));
334  }
335 
336  void IsSource()
337  {
338  CPPUNIT_ASSERT_THROW_MESSAGE(
339  "Violated precondition (nullptr) does not throw.", rule->IsSource(nullptr), itk::ExceptionObject);
340 
341  CPPUNIT_ASSERT(!rule->IsSource(unRelated));
342  CPPUNIT_ASSERT(!rule->IsSource(source_implicit_1));
343  CPPUNIT_ASSERT(rule->IsSource(source_data_1));
344  CPPUNIT_ASSERT(rule->IsSource(source_idOnly_1));
345  CPPUNIT_ASSERT(rule->IsSource(source_1));
346  CPPUNIT_ASSERT(rule->IsSource(source_multi));
347 
348  CPPUNIT_ASSERT(!rule->IsSource(source_otherRule));
349  CPPUNIT_ASSERT(!rule->IsSource(source_otherTypeRule));
350 
351  CPPUNIT_ASSERT(!abstractRule->IsSource(unRelated));
352  CPPUNIT_ASSERT(!abstractRule->IsSource(source_implicit_1));
353  CPPUNIT_ASSERT(abstractRule->IsSource(source_data_1));
354  CPPUNIT_ASSERT(abstractRule->IsSource(source_idOnly_1));
355  CPPUNIT_ASSERT(abstractRule->IsSource(source_1));
356  CPPUNIT_ASSERT(abstractRule->IsSource(source_multi));
357 
358  CPPUNIT_ASSERT(!abstractRule->IsSource(source_otherRule));
359  CPPUNIT_ASSERT(abstractRule->IsSource(source_otherTypeRule));
360  }
361 
362  void HasRelation()
363  {
364  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (source is nullptr) does not throw.",
365  rule->HasRelation(nullptr, dest_1),
366  itk::ExceptionObject);
367 
368  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (destination is nullptr) does not throw.",
369  rule->HasRelation(source_1, nullptr),
370  itk::ExceptionObject);
371 
372  CPPUNIT_ASSERT(rule->HasRelation(source_1, unRelated) == mitk::PropertyRelationRuleBase::RelationType::None);
373  CPPUNIT_ASSERT(rule->HasRelation(unRelated, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
374  CPPUNIT_ASSERT(rule->HasRelation(source_otherRule, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
375  CPPUNIT_ASSERT(rule->HasRelation(source_otherTypeRule, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
376 
377  CPPUNIT_ASSERT(rule->HasRelation(source_implicit_1, dest_1) ==
379  CPPUNIT_ASSERT(rule->HasRelation(source_data_1, dest_1) ==
381  CPPUNIT_ASSERT(rule->HasRelation(source_idOnly_1, dest_1) ==
383  CPPUNIT_ASSERT(rule->HasRelation(source_1, dest_1) == mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
384  CPPUNIT_ASSERT(rule->HasRelation(source_multi, dest_1) ==
386 
387  CPPUNIT_ASSERT(rule->HasRelation(source_1, dest_2) == mitk::PropertyRelationRuleBase::RelationType::None);
388  CPPUNIT_ASSERT(rule->HasRelation(source_multi, dest_2) ==
390 
391 
392  CPPUNIT_ASSERT(abstractRule->HasRelation(source_1, unRelated) == mitk::PropertyRelationRuleBase::RelationType::None);
393  CPPUNIT_ASSERT(abstractRule->HasRelation(unRelated, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
394  CPPUNIT_ASSERT(abstractRule->HasRelation(source_otherRule, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
395  CPPUNIT_ASSERT(abstractRule->HasRelation(source_otherTypeRule, dest_1) ==
397 
398  CPPUNIT_ASSERT(abstractRule->HasRelation(source_implicit_1, dest_1) ==
400  CPPUNIT_ASSERT(abstractRule->HasRelation(source_data_1, dest_1) ==
402  CPPUNIT_ASSERT(abstractRule->HasRelation(source_idOnly_1, dest_1) ==
404  CPPUNIT_ASSERT(abstractRule->HasRelation(source_1, dest_1) == mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
405  CPPUNIT_ASSERT(abstractRule->HasRelation(source_multi, dest_1) ==
407 
408  CPPUNIT_ASSERT(abstractRule->HasRelation(source_1, dest_2) == mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
409  CPPUNIT_ASSERT(abstractRule->HasRelation(source_multi, dest_2) ==
411  }
412 
413  void GetExistingRelations()
414  {
415  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (source is nullptr) does not throw.",
416  rule->GetExistingRelations(nullptr),
417  itk::ExceptionObject);
418 
419  CPPUNIT_ASSERT(rule->GetExistingRelations(unRelated).empty());
420  CPPUNIT_ASSERT(rule->GetExistingRelations(source_otherRule).empty());
421  CPPUNIT_ASSERT(rule->GetExistingRelations(source_otherTypeRule).empty());
422  CPPUNIT_ASSERT(rule->GetExistingRelations(source_implicit_1).empty());
423 
424  auto uids = rule->GetExistingRelations(source_idOnly_1);
425  CPPUNIT_ASSERT(uids.size() == 1);
426  CPPUNIT_ASSERT(uids.front() == "uid1");
427 
428  uids = rule->GetExistingRelations(source_data_1);
429  CPPUNIT_ASSERT(uids.size() == 1);
430  CPPUNIT_ASSERT(uids.front() == "uid2");
431 
432  uids = rule->GetExistingRelations(source_1);
433  CPPUNIT_ASSERT(uids.size() == 1);
434  CPPUNIT_ASSERT(uids.front() == "uid3");
435 
436  uids = rule->GetExistingRelations(source_multi);
437  CPPUNIT_ASSERT(uids.size() == 3);
438  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid4") != uids.end());
439  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid5") != uids.end());
440  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid6") != uids.end());
441 
442 
443  CPPUNIT_ASSERT(abstractRule->GetExistingRelations(unRelated).empty());
444  CPPUNIT_ASSERT(abstractRule->GetExistingRelations(source_otherRule).empty());
445  CPPUNIT_ASSERT(abstractRule->GetExistingRelations(source_implicit_1).empty());
446 
447  uids = abstractRule->GetExistingRelations(source_idOnly_1);
448  CPPUNIT_ASSERT(uids.size() == 1);
449  CPPUNIT_ASSERT(uids.front() == "uid1");
450 
451  uids = abstractRule->GetExistingRelations(source_data_1);
452  CPPUNIT_ASSERT(uids.size() == 2);
453  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid2") != uids.end());
454  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid10") != uids.end());
455 
456  uids = abstractRule->GetExistingRelations(source_1);
457  CPPUNIT_ASSERT(uids.size() == 2);
458  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid3") != uids.end());
459  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid8") != uids.end());
460 
461  uids = abstractRule->GetExistingRelations(source_multi);
462  CPPUNIT_ASSERT(uids.size() == 3);
463  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid4") != uids.end());
464  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid5") != uids.end());
465  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid6") != uids.end());
466 
467  uids = abstractRule->GetExistingRelations(source_otherTypeRule);
468  CPPUNIT_ASSERT(uids.size() == 1);
469  CPPUNIT_ASSERT(uids.front() == "uid9");
470 
471  }
472 
473  void GetRelationUIDs()
474  {
475  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (source is nullptr) does not throw.",
476  rule->GetRelationUIDs(nullptr, dest_1),
477  itk::ExceptionObject);
478 
479  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (destination is nullptr) does not throw.",
480  rule->GetRelationUIDs(source_1, nullptr),
481  itk::ExceptionObject);
482 
483  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_1, unRelated).empty());
484  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_1, dest_2).empty());
485  CPPUNIT_ASSERT(rule->GetRelationUIDs(unRelated, dest_1).empty());
486  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_otherRule, dest_1).empty());
487  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_otherTypeRule, dest_1).empty());
488 
489  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_idOnly_1, dest_1).front() == "uid1");
490  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_data_1, dest_1).front() == "uid2");
491  auto uids = rule->GetRelationUIDs(source_1, dest_1);
492  CPPUNIT_ASSERT(uids.size() == 1);
493  CPPUNIT_ASSERT(uids.front() == "uid3");
494  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_multi, dest_1).front() == "uid4");
495  CPPUNIT_ASSERT(rule->GetRelationUIDs(source_multi, dest_2).front() == "uid5");
496 
497  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(source_1, unRelated).empty());
498  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(unRelated, dest_1).empty());
499  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(source_otherRule, dest_1).empty());
500  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(source_otherTypeRule, dest_1).front() == "uid9");
501 
502  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(source_idOnly_1, dest_1).front() == "uid1");
503  uids = abstractRule->GetRelationUIDs(source_data_1, dest_1);
504  CPPUNIT_ASSERT(uids.size() == 2);
505  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid2") != uids.end());
506  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid10") != uids.end());
507  uids = abstractRule->GetRelationUIDs(source_1, dest_1);
508  CPPUNIT_ASSERT(uids.size() == 1);
509  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid3") != uids.end());
510  uids = abstractRule->GetRelationUIDs(source_1, dest_2);
511  CPPUNIT_ASSERT(uids.size() == 1);
512  CPPUNIT_ASSERT(std::find(uids.begin(), uids.end(), "uid8") != uids.end());
513  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(source_1, dest_1).front() == "uid3");
514  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(source_multi, dest_1).front() == "uid4");
515  CPPUNIT_ASSERT(abstractRule->GetRelationUIDs(source_multi, dest_2).front() == "uid5");
516 
517  }
518 
519  void GetSourceCandidateIndicator()
520  {
521  auto predicate = rule->GetSourceCandidateIndicator();
522 
523  CPPUNIT_ASSERT(predicate->CheckNode(mitk::DataNode::New()));
524  CPPUNIT_ASSERT(!predicate->CheckNode(nullptr));
525  }
526 
527  void GetDestinationCandidateIndicator()
528  {
529  auto predicate = rule->GetDestinationCandidateIndicator();
530 
531  CPPUNIT_ASSERT(predicate->CheckNode(mitk::DataNode::New()));
532  CPPUNIT_ASSERT(!predicate->CheckNode(nullptr));
533  }
534 
535  void GetConnectedSourcesDetector()
536  {
537  auto predicate = rule->GetConnectedSourcesDetector();
538 
539  CPPUNIT_ASSERT(!predicate->CheckNode(nullptr));
540  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
541  CPPUNIT_ASSERT(!predicate->CheckNode(source_implicit_1));
542  CPPUNIT_ASSERT(predicate->CheckNode(source_data_1));
543  CPPUNIT_ASSERT(predicate->CheckNode(source_idOnly_1));
544  CPPUNIT_ASSERT(predicate->CheckNode(source_1));
545  CPPUNIT_ASSERT(predicate->CheckNode(source_multi));
546 
547  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherRule));
548  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherTypeRule));
549 
550 
551  auto predicate2 = abstractRule->GetConnectedSourcesDetector();
552 
553  CPPUNIT_ASSERT(!predicate2->CheckNode(nullptr));
554  CPPUNIT_ASSERT(!predicate2->CheckNode(unRelated));
555  CPPUNIT_ASSERT(!predicate2->CheckNode(source_implicit_1));
556  CPPUNIT_ASSERT(predicate2->CheckNode(source_data_1));
557  CPPUNIT_ASSERT(predicate2->CheckNode(source_idOnly_1));
558  CPPUNIT_ASSERT(predicate2->CheckNode(source_1));
559  CPPUNIT_ASSERT(predicate2->CheckNode(source_multi));
560 
561  CPPUNIT_ASSERT(!predicate2->CheckNode(source_otherRule));
562  CPPUNIT_ASSERT(predicate2->CheckNode(source_otherTypeRule));
563  }
564 
565  void GetSourcesDetector()
566  {
567  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (destination is nullptr) does not throw.",
568  rule->GetSourcesDetector(nullptr),
569  itk::ExceptionObject);
570 
571  auto predicate = rule->GetSourcesDetector(dest_1);
572 
573  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
574  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherRule));
575  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherTypeRule));
576 
577  CPPUNIT_ASSERT(predicate->CheckNode(source_implicit_1));
578  CPPUNIT_ASSERT(predicate->CheckNode(source_data_1));
579  CPPUNIT_ASSERT(predicate->CheckNode(source_idOnly_1));
580  CPPUNIT_ASSERT(predicate->CheckNode(source_1));
581  CPPUNIT_ASSERT(predicate->CheckNode(source_multi));
582 
583  predicate = rule->GetSourcesDetector(dest_1, mitk::PropertyRelationRuleBase::RelationType::Connected_Data);
584 
585  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
586  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherRule));
587  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherTypeRule));
588 
589  CPPUNIT_ASSERT(!predicate->CheckNode(source_implicit_1));
590  CPPUNIT_ASSERT(predicate->CheckNode(source_data_1));
591  CPPUNIT_ASSERT(predicate->CheckNode(source_idOnly_1));
592  CPPUNIT_ASSERT(predicate->CheckNode(source_1));
593  CPPUNIT_ASSERT(predicate->CheckNode(source_multi));
594 
595  predicate = rule->GetSourcesDetector(dest_1, mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
596 
597  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
598  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherRule));
599  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherTypeRule));
600 
601  CPPUNIT_ASSERT(!predicate->CheckNode(source_implicit_1));
602  CPPUNIT_ASSERT(!predicate->CheckNode(source_data_1));
603  CPPUNIT_ASSERT(predicate->CheckNode(source_idOnly_1));
604  CPPUNIT_ASSERT(predicate->CheckNode(source_1));
605  CPPUNIT_ASSERT(predicate->CheckNode(source_multi));
606 
607  predicate = rule->GetSourcesDetector(dest_2, mitk::PropertyRelationRuleBase::RelationType::Implicit_Data);
608 
609  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
610  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherRule));
611  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherTypeRule));
612 
613  CPPUNIT_ASSERT(!predicate->CheckNode(source_implicit_1));
614  CPPUNIT_ASSERT(!predicate->CheckNode(source_data_1));
615  CPPUNIT_ASSERT(!predicate->CheckNode(source_idOnly_1));
616  CPPUNIT_ASSERT(!predicate->CheckNode(source_1));
617  CPPUNIT_ASSERT(predicate->CheckNode(source_multi));
618 
619  predicate = abstractRule->GetSourcesDetector(dest_1, mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
620 
621  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
622  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherRule));
623  CPPUNIT_ASSERT(predicate->CheckNode(source_otherTypeRule));
624 
625  CPPUNIT_ASSERT(!predicate->CheckNode(source_implicit_1));
626  CPPUNIT_ASSERT(predicate->CheckNode(source_data_1));
627  CPPUNIT_ASSERT(predicate->CheckNode(source_idOnly_1));
628  CPPUNIT_ASSERT(predicate->CheckNode(source_1));
629  CPPUNIT_ASSERT(predicate->CheckNode(source_multi));
630 
631  predicate = abstractRule->GetSourcesDetector(dest_1);
632 
633  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
634  CPPUNIT_ASSERT(!predicate->CheckNode(source_otherRule));
635  CPPUNIT_ASSERT(predicate->CheckNode(source_otherTypeRule));
636 
637  CPPUNIT_ASSERT(predicate->CheckNode(source_implicit_1));
638  CPPUNIT_ASSERT(predicate->CheckNode(source_data_1));
639  CPPUNIT_ASSERT(predicate->CheckNode(source_idOnly_1));
640  CPPUNIT_ASSERT(predicate->CheckNode(source_1));
641  CPPUNIT_ASSERT(predicate->CheckNode(source_multi));
642  }
643 
644  void GetDestinationsDetector()
645  {
646  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (source is nullptr) does not throw.",
647  rule->GetDestinationsDetector(nullptr),
648  itk::ExceptionObject);
649 
650  auto predicate = rule->GetDestinationsDetector(source_otherRule);
651  CPPUNIT_ASSERT(!predicate->CheckNode(dest_1));
652 
653  predicate = rule->GetDestinationsDetector(source_otherTypeRule);
654  CPPUNIT_ASSERT(!predicate->CheckNode(dest_1));
655 
656  predicate = rule->GetDestinationsDetector(source_implicit_1);
657  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
658  predicate =
659  rule->GetDestinationsDetector(source_implicit_1, mitk::PropertyRelationRuleBase::RelationType::Connected_Data);
660  CPPUNIT_ASSERT(!predicate->CheckNode(dest_1));
661 
662  predicate = rule->GetDestinationsDetector(source_data_1);
663  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
664  predicate =
665  rule->GetDestinationsDetector(source_data_1, mitk::PropertyRelationRuleBase::RelationType::Connected_Data);
666  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
667  predicate =
668  rule->GetDestinationsDetector(source_data_1, mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
669  CPPUNIT_ASSERT(!predicate->CheckNode(dest_1));
670 
671  predicate = rule->GetDestinationsDetector(source_idOnly_1);
672  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
673  predicate =
674  rule->GetDestinationsDetector(source_idOnly_1, mitk::PropertyRelationRuleBase::RelationType::Connected_Data);
675  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
676  predicate =
677  rule->GetDestinationsDetector(source_idOnly_1, mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
678  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
679 
680  predicate = rule->GetDestinationsDetector(source_1);
681  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
682  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
683  CPPUNIT_ASSERT(!predicate->CheckNode(dest_2));
684  predicate =
685  rule->GetDestinationsDetector(source_1, mitk::PropertyRelationRuleBase::RelationType::Connected_Data);
686  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
687  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
688  CPPUNIT_ASSERT(!predicate->CheckNode(dest_2));
689  predicate =
690  rule->GetDestinationsDetector(source_1, mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
691  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
692  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
693  CPPUNIT_ASSERT(!predicate->CheckNode(dest_2));
694 
695  predicate = rule->GetDestinationsDetector(source_multi);
696  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
697  CPPUNIT_ASSERT(predicate->CheckNode(dest_2));
698  predicate =
699  rule->GetDestinationsDetector(source_multi, mitk::PropertyRelationRuleBase::RelationType::Connected_Data);
700  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
701  CPPUNIT_ASSERT(predicate->CheckNode(dest_2));
702  predicate =
703  rule->GetDestinationsDetector(source_multi, mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
704  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
705  CPPUNIT_ASSERT(predicate->CheckNode(dest_2));
706 
707  predicate = abstractRule->GetDestinationsDetector(source_otherTypeRule);
708  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
709  predicate = abstractRule->GetDestinationsDetector(source_otherTypeRule);
710  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
711 
712  }
713 
714  void GetDestinationDetector()
715  {
716  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (source is nullptr) does not throw.",
717  rule->GetDestinationDetector(nullptr, "uid1"),
718  itk::ExceptionObject);
719 
720  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (relation uid is invalid) does not throw.",
721  rule->GetDestinationDetector(source_1, "invalid uid"),
722  itk::ExceptionObject);
723 
724  auto predicate = rule->GetDestinationDetector(source_1, "uid3");
725  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
726  CPPUNIT_ASSERT(predicate->CheckNode(dest_1));
727  CPPUNIT_ASSERT(!predicate->CheckNode(dest_2));
728 
729  predicate = rule->GetDestinationDetector(source_multi, "uid5");
730  CPPUNIT_ASSERT(!predicate->CheckNode(unRelated));
731  CPPUNIT_ASSERT(!predicate->CheckNode(dest_1));
732  CPPUNIT_ASSERT(predicate->CheckNode(dest_2));
733  }
734 
735  void Connect()
736  {
737  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (source is nullptr) does not throw.",
738  rule->Connect(nullptr, dest_1),
739  itk::ExceptionObject);
740 
741  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (destination is nullptr) does not throw.",
742  rule->Connect(source_1, nullptr),
743  itk::ExceptionObject);
744 
745  // check upgrade of an implicit connection
746  CPPUNIT_ASSERT(rule->HasRelation(source_implicit_1, dest_1) ==
748  rule->Connect(source_implicit_1, dest_1);
749  CPPUNIT_ASSERT(rule->HasRelation(source_implicit_1, dest_1) ==
751 
752  // check upgrade of an data connection
753  CPPUNIT_ASSERT(rule->HasRelation(source_data_1, dest_1) ==
755  rule->Connect(source_data_1, dest_1);
756  CPPUNIT_ASSERT(rule->HasRelation(source_data_1, dest_1) ==
758  std::string name = "MITK.Relations.1.destinationUID";
759  auto prop = source_data_1->GetProperty(name.c_str());
760  CPPUNIT_ASSERT_MESSAGE(
761  "Destination uid was not stored with the correct key. Already existing session should be used.", prop);
762  CPPUNIT_ASSERT_MESSAGE("Incorrect destination uid was stored.", prop->GetValueAsString() == dest_1_data->GetUID());
763 
764  // check actualization of an id only connection
765  rule->Connect(source_idOnly_1, dest_1);
766  CPPUNIT_ASSERT(rule->HasRelation(source_idOnly_1, dest_1) ==
768  CPPUNIT_ASSERT_MESSAGE("Additional relation was defined instead of updating exting one.",
769  rule->GetExistingRelations(source_1).size() == 1);
770  name = "MITK.Relations.1.dataHandle";
771  prop = source_idOnly_1->GetProperty(name.c_str());
772  CPPUNIT_ASSERT_MESSAGE(
773  "Data layer information was not stored with the correct key. Already existing session should be used.", prop);
774  CPPUNIT_ASSERT_MESSAGE("Incorrect data layer information not stored.",
775  prop->GetValueAsString() == dest_1->GetName());
776  prop = source_idOnly_1->GetProperty("referencedName");
777  CPPUNIT_ASSERT_MESSAGE(
778  "Data layer information was not stored with the correct key. Already existing session should be used.", prop);
779  CPPUNIT_ASSERT_MESSAGE("Incorrect data layer information was stored.",
780  prop->GetValueAsString() == dest_1->GetName());
781 
782  // check actualization of an existing connection
783  rule->Connect(source_1, dest_1);
784  CPPUNIT_ASSERT(rule->HasRelation(source_1, dest_1) == mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
785  CPPUNIT_ASSERT_MESSAGE("Additional relation was defined instead of updating exting one.",
786  rule->GetExistingRelations(source_1).size() == 1);
787 
788  // check new connection
789  auto newConnectUID = rule->Connect(source_multi, unRelated);
790  CPPUNIT_ASSERT(rule->HasRelation(source_multi, unRelated) ==
792  name = "MITK.Relations.5.dataHandle";
793  prop = source_multi->GetProperty(name.c_str());
794  CPPUNIT_ASSERT_MESSAGE(
795  "Data layer information was not stored with the correct key. Already existing session should be used.", prop);
796  CPPUNIT_ASSERT_MESSAGE("Incorrect data layer information was stored.",
797  prop->GetValueAsString() == unRelated->GetName());
798  prop = source_multi->GetProperty("referencedName");
799  CPPUNIT_ASSERT_MESSAGE(
800  "Data layer information was not stored with the correct key. Already existing session should be used.", prop);
801  CPPUNIT_ASSERT_MESSAGE("Incorrect data layer information was stored.",
802  prop->GetValueAsString() == unRelated->GetName());
803  name = "MITK.Relations.5.destinationUID";
804  prop = source_multi->GetProperty(name.c_str());
805  CPPUNIT_ASSERT_MESSAGE(
806  "Destination uid was not stored with the correct key. Already existing session should be used.", prop);
807  CPPUNIT_ASSERT_MESSAGE("Incorrect destination uid was stored.", prop->GetValueAsString() == unRelated_1_data->GetUID());
808 
809  auto storedRelationUIDs = rule->GetRelationUIDs(source_multi, unRelated);
810  CPPUNIT_ASSERT_MESSAGE(
811  "Relation uid was not stored for given source and destination.", storedRelationUIDs.size() == 1);
812  CPPUNIT_ASSERT_MESSAGE("Incorrect Relation uid was stored.", storedRelationUIDs[0] == newConnectUID);
813  }
814 
815  void Disconnect()
816  {
817  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (source is nullptr) does not throw.",
818  rule->Disconnect(nullptr, dest_1),
819  itk::ExceptionObject);
820 
821  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (destination is nullptr) does not throw.",
822  rule->Disconnect(source_1, nullptr),
823  itk::ExceptionObject);
824 
825  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (destination is nullptr) does not throw.",
826  rule->Disconnect(nullptr, "uid"),
827  itk::ExceptionObject);
828 
829  CPPUNIT_ASSERT(rule->HasRelation(source_1, unRelated) == mitk::PropertyRelationRuleBase::RelationType::None);
830  rule->Disconnect(source_1, unRelated);
831  CPPUNIT_ASSERT(rule->HasRelation(source_1, unRelated) == mitk::PropertyRelationRuleBase::RelationType::None);
832  CPPUNIT_ASSERT_MESSAGE("Data property was not removed.", !source_1->GetProperty("referencedName"));
833 
834  rule->Disconnect(source_1, dest_2);
835  CPPUNIT_ASSERT(rule->HasRelation(source_1, dest_2) == mitk::PropertyRelationRuleBase::RelationType::None);
836  CPPUNIT_ASSERT(this->hasRelationProperties(source_1));
837 
838  CPPUNIT_ASSERT(rule->HasRelation(source_1, dest_1) == mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
839  rule->Disconnect(source_1, dest_1);
840  CPPUNIT_ASSERT(rule->HasRelation(source_1, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
841  CPPUNIT_ASSERT(!this->hasRelationProperties(source_1, "1"));
842  CPPUNIT_ASSERT_MESSAGE("Data of other rule type was removed.",this->hasRelationProperties(source_1, "2"));
843 
844  CPPUNIT_ASSERT(rule->HasRelation(source_multi, dest_1) ==
846  rule->Disconnect(source_multi, dest_1);
847  CPPUNIT_ASSERT(rule->HasRelation(source_multi, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
848  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "1"));
849  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "2"));
850  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "4"));
851 
852  rule->Disconnect(source_multi, "uid6");
853  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "1"));
854  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "2"));
855  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "4"));
856 
857  rule->Disconnect(source_multi, "unkownRelationUID");
858  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "1"));
859  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "2"));
860  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "4"));
861 
862  rule->Disconnect(source_otherTypeRule, dest_1);
863  CPPUNIT_ASSERT_MESSAGE("Data of other rule type was removed.", this->hasRelationProperties(source_otherTypeRule, "1"));
864  }
865 
866  void Connect_abstract()
867  {
868  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (abstract does not connect) does not throw.",
869  abstractRule->Connect(nullptr, dest_1),
870  itk::ExceptionObject);
871 
872  CPPUNIT_ASSERT_THROW_MESSAGE("Violated precondition (abstract does not connect) does not throw.",
873  abstractRule->Connect(source_1, nullptr),
874  itk::ExceptionObject);
875  }
876 
877  void Disconnect_abstract()
878  {
879 
880  CPPUNIT_ASSERT(abstractRule->HasRelation(source_1, dest_2) == mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
881  abstractRule->Disconnect(source_1, dest_2);
882  CPPUNIT_ASSERT(abstractRule->HasRelation(source_1, dest_2) == mitk::PropertyRelationRuleBase::RelationType::None);
883  CPPUNIT_ASSERT(!this->hasRelationProperties(source_1, "2"));
884 
885  CPPUNIT_ASSERT(abstractRule->HasRelation(source_1, dest_1) == mitk::PropertyRelationRuleBase::RelationType::Connected_ID);
886  abstractRule->Disconnect(source_1, dest_1);
887  CPPUNIT_ASSERT(abstractRule->HasRelation(source_1, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
888  CPPUNIT_ASSERT(!this->hasRelationProperties(source_1, "1"));
889 
890  CPPUNIT_ASSERT(abstractRule->HasRelation(source_multi, dest_1) ==
892  abstractRule->Disconnect(source_multi, dest_1);
893  CPPUNIT_ASSERT(abstractRule->HasRelation(source_multi, dest_1) == mitk::PropertyRelationRuleBase::RelationType::None);
894  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "1"));
895  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "2"));
896  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "4"));
897 
898  abstractRule->Disconnect(source_multi, "uid6");
899  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "1"));
900  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "2"));
901  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "4"));
902 
903  abstractRule->Disconnect(source_multi, "unkownRelationUID");
904  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "1"));
905  CPPUNIT_ASSERT(!this->hasRelationProperties(source_multi, "2"));
906  CPPUNIT_ASSERT(this->hasRelationProperties(source_multi, "4"));
907 
908  abstractRule->Disconnect(source_otherTypeRule, dest_1);
909  CPPUNIT_ASSERT_MESSAGE("Data of other rule type was removed.", !this->hasRelationProperties(source_otherTypeRule, "1"));
910 
911  }
912 
913 };
914 
915 MITK_TEST_SUITE_REGISTRATION(mitkPropertyRelationRuleBase)
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyName(const PropertyKeyPath &tagPath)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
static Pointer New()
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
DataCollection - Class to facilitate loading/accessing structured data.
PropertyKeyPath & AddElement(const ElementNameType &name)
static Pointer New()
virtual std::vector< std::string > GetPropertyKeys(const std::string &contextName="", bool includeDefaultContext=false) const =0
Query keys of existing properties.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Test fixture for parameterized tests.
std::vector< RelationUIDType > RelationUIDVectorType
std::vector< InstanceIDType > InstanceIDVectorType
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
static Pointer New()
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyRegEx(const PropertyKeyPath &tagPath)