コード例 #1
0
        public void AddMissingComponents_TwoMissingComponentsWithSameNameDifferentGrandParents_CreatesComponentInArdoq()
        {
            // Arrange
            const string subscriptionName      = "mySub";
            const string rg1Name               = "myRG1";
            const string rg2Name               = "myRG2";
            const string eventHubNamespaceName = "myEventHubNamespace";
            const string eventHubName          = "myEventHub";

            var sub = new Subscription {
                Name = subscriptionName
            };
            var rg1 = new ResourceGroup {
                Name = rg1Name, Subscription = sub
            };
            var rg2 = new ResourceGroup {
                Name = rg2Name, Subscription = sub
            };
            var eh1 = new EventHub {
                Name = eventHubName
            };
            var eh2 = new EventHub {
                Name = eventHubName
            };                                              // Same name as eh1
            var ehn1 = new EventHubNamespace {
                Name = eventHubNamespaceName, ResourceGroup = rg1, EventHubs = new List <EventHub> {
                    eh1
                }
            };
            var ehn2 = new EventHubNamespace {
                Name = eventHubNamespaceName, ResourceGroup = rg2, EventHubs = new List <EventHub> {
                    eh2
                }
            };                                                                                                                               // Same name as ehn1

            var relations = Helper.CreateRelations((null, sub), (sub, rg1), (sub, rg2), (rg1, ehn1), (rg2, ehn2), (ehn1, eh1), (ehn2, eh2));

            var mappings  = Helper.GetModel(ModelType.Subscription_ResourceGroup_EventHubNamespace_EventHub);
            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var session = Helper.GetSession();

            session.AddComponent(subscriptionName, null, "Subscription", null);
            session.AddComponent(rg1Name, null, "ResourceGroup", subscriptionName);
            session.AddComponent(rg2Name, null, "ResourceGroup", subscriptionName);
            session.AddComponent(eventHubNamespaceName, null, "EventHubNamespace", rg1Name);
            session.AddComponent(eventHubNamespaceName, null, "EventHubNamespace", rg2Name);

            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.AddMissingComponents(hierarchy);

            // Assert
            Assert.Equal(2, c);
        }
        public void DeleteComponents_SuperfluousComponentWithSameNameInArdoq_DeletesComponentInArdoq()
        {
            // Arrange
            const string componentTypeSub = "Subscription";
            const string componentTypeRG  = "ResourceGroup";
            const string componentTypeEHN = "EventHubNamespace";
            const string tagString        = "tag1";
            Dictionary <Type, IBuiltComponentMapping> mappings = Helper.GetModel(ModelType.Subscription_ResourceGroup_EventHubNamespace);

            var sub = new Subscription {
                Name = "subName"
            };
            var rg1 = new ResourceGroup {
                Name = "rg1Name"
            };
            var rg2 = new ResourceGroup {
                Name = "rg2Name"
            };
            var ehn1 = new EventHubNamespace
            {
                Name          = "ehNamespaceName",
                ResourceGroup = rg1,
                Tags          = new List <string> {
                    tagString
                }
            };

            var relations = Helper.CreateRelations((null, sub), (sub, rg1), (sub, rg2), (rg1, ehn1));

            var builder     = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchies = builder.BuildRelationHierarchies(relations);

            var existingTag = new Tag(tagString, null, null)
            {
                Components = new List <string> {
                    "tag2"
                }
            };
            var session = Helper.GetSession(null, null, new List <Tag> {
                existingTag
            });

            session.AddComponent(sub.Name, null, componentTypeSub, null);
            session.AddComponent(rg1.Name, null, componentTypeRG, sub.Name);
            session.AddComponent(rg2.Name, null, componentTypeRG, sub.Name);
            session.AddComponent(ehn1.Name, null, componentTypeEHN, rg1.Name);
            session.AddComponent(ehn1.Name, null, componentTypeEHN, rg2.Name);

            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.DeleteComponents(hierarchies);

            // Assert
            Assert.Equal(4, session.GetAllComponents().Count());
            Assert.Equal(1, c);
        }
コード例 #3
0
        public void UpdateComponentTags_TagExistsButDoesNotReferenceComponent_UpdatesTag()
        {
            // Arrange
            var ehNamespaceName = "my-namespace";
            var tagString       = "tag1";
            var componentType   = "EventHubNamespace";
            var m = new ComponentMapping <EventHubNamespace>(componentType)
                    .WithKey(rg => rg.Name)
                    .WithTags(e => e.Tags)
                    .WithPreexistingHierarchyReference("EventHubs");

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(EventHubNamespace)] = m
            };

            var ehn = new EventHubNamespace
            {
                Name = ehNamespaceName,
                Tags = new List <string> {
                    tagString
                }
            };

            var relations = new List <ParentChildRelation> {
                new ParentChildRelation(null, ehn)
                {
                    PreexistingHierarchyReference = "EventHubs"
                }
            };

            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var existingTag = new Tag(tagString, null, null)
            {
                Components = new List <string> {
                    "tag2"
                }
            };
            var session = Helper.GetSession(null, null, new List <Tag> {
                existingTag
            });

            session.AddComponent(ehNamespaceName, null, componentType, null);

            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.UpdateComponentTags(hierarchy);

            // Assert
            Assert.Equal(2, existingTag.Components.Count);
            Assert.Equal(1, c);
        }
コード例 #4
0
        public void AddMissingComponents_WithModelledParent_CreatesComponentInArdoq()
        {
            // Arrange
            var m = new ComponentMapping <ResourceGroup>("ResourceGroup")
                    .WithKey(rg => rg.Name)
                    .WithModelledHierarchyReference(rg => rg.Subscription, ModelledReferenceDirection.Child);
            var m2 = new ComponentMapping <Subscription>("Subscription")
                     .WithKey(s => s.Name)
                     .WithPreexistingHierarchyReference("Subs");
            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(ResourceGroup)] = m,
                [typeof(Subscription)]  = m2
            };

            var subscription = new Subscription {
                Name = "MySub"
            };
            var resourceGroup = new ResourceGroup {
                Name = "myRG", Subscription = subscription
            };
            var relations = new List <ParentChildRelation>
            {
                new ParentChildRelation(null, subscription)
                {
                    PreexistingHierarchyReference = "Subs"
                },
                new ParentChildRelation(subscription, resourceGroup)
            };

            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var subComponent = new Component("MySub", "workspaceId", null)
            {
                Type = "Subscription"
            };
            var session = Helper.GetSession("workspaceId", new List <Component> {
                subComponent
            });
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.AddMissingComponents(hierarchy);

            // Assert
            var addedComp = session.GetComponents("ResourceGroup", "myRG").Single();

            Assert.Equal(1, c);
        }
コード例 #5
0
        public void UpdateComponents_HasSmallChange_UpdatesComponentInArdoq()
        {
            // Arrange
            var m = new ComponentMapping <Employee>("Employee")
                    .WithKey(rg => rg.EmployeeNumber)
                    .WithField(e => e.Name, "employee-name")
                    .WithField(e => e.Age, "age")
                    .WithPreexistingHierarchyReference("Employees");

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(Employee)] = m
            };

            var employee = new Employee {
                Name = "Michael Jackson", EmployeeNumber = "XX99", Age = 55
            };
            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var relations = new List <ParentChildRelation>
            {
                new ParentChildRelation(null, employee)
                {
                    PreexistingHierarchyReference = "Employees"
                }
            };

            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var session = Helper.GetSession();
            var fields  = new Dictionary <string, object>
            {
                ["employee-name"] = "Michael Jackson",
                ["age"]           = "54"
            };

            session.AddComponent("XX99", fields, "Employee", null);
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.UpdateComponents(hierarchy);

            // Assert
            Assert.Equal(1, c);
            Component updatedComponent = session.GetAllComponents().Single();

            Assert.Equal("Michael Jackson", updatedComponent.Fields["employee-name"]);
            Assert.Equal(55, updatedComponent.Fields["age"]);
        }
        public void DeleteComponents_WithRealSession_SessionStateModified()
        {
            // Arrange
            var componentType = "Employee";

            var m = new ComponentMapping <Employee>(componentType)
                    .WithKey(rg => rg.EmployeeNumber)
                    .WithField(e => e.Name, "employee-name")
                    .WithField(e => e.Age, "age")
                    .WithPreexistingHierarchyReference("Employees");

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(Employee)] = m
            };

            var employee = new Employee {
                Name = "Michael Jackson", EmployeeNumber = "XX99", Age = 55
            };
            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var relations = new List <ParentChildRelation>
            {
                new ParentChildRelation(null, employee)
                {
                    PreexistingHierarchyReference = "Employees"
                }
            };

            var hierarchies = builder.BuildRelationHierarchies(relations);

            var session = Helper.GetSession();

            session.AddComponent("XX99", null, componentType, null);
            session.AddComponent("non-existing", null, componentType, null);
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.DeleteComponents(hierarchies);

            // Assert
            Assert.Equal(1, c);
        }
コード例 #7
0
        public void AddMissingComponents_WithTags_CreatesComponentWithTagsInArdoq()
        {
            // Arrange
            var m = new ComponentMapping <EventHubNamespace>("EventHubNamespace")
                    .WithKey(rg => rg.Name)
                    .WithTags(e => e.Tags)
                    .WithPreexistingHierarchyReference("EventHubs");

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(EventHubNamespace)] = m
            };

            var ehn = new EventHubNamespace()
            {
                Name = "events-1", Tags = new List <string> {
                    "v1", "v2"
                }
            };
            var relations = new List <ParentChildRelation> {
                new ParentChildRelation(null, ehn)
                {
                    PreexistingHierarchyReference = "EventHubs"
                }
            };

            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var session    = Helper.GetSession();
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.AddMissingComponents(hierarchy);

            // Assert
            var comp = session.GetComponents("EventHubNamespace", "events-1").Single();

            Assert.NotNull(comp);
            Assert.Equal(1, c);
        }
        public void DeleteComponents_NothingToDelete_NoDeletesSendToArdoq()
        {
            // Arrange
            var m = new ComponentMapping <Employee>("Employee")
                    .WithKey(rg => rg.EmployeeNumber)
                    .WithField(e => e.Name, "employee-name")
                    .WithField(e => e.Age, "age")
                    .WithPreexistingHierarchyReference("Employees");

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(Employee)] = m
            };

            var employee = new Employee {
                Name = "Michael Jackson", EmployeeNumber = "XX99", Age = 55
            };
            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var relations = new List <ParentChildRelation>
            {
                new ParentChildRelation(null, employee)
                {
                    PreexistingHierarchyReference = "Employees"
                }
            };

            var hierarchies = builder.BuildRelationHierarchies(relations);

            var session = Helper.GetSession();

            session.AddComponent("XX99", null, "Employee", null);
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.DeleteComponents(hierarchies);

            // Assert
            Assert.Single(session.GetAllComponents());
            Assert.Equal(0, c);
        }
コード例 #9
0
        public void AddMissingComponents_ComponentAlreadyExists_DoesNotCreateComponentInArdoq()
        {
            // Arrange
            var m = new ComponentMapping <ResourceGroup>("ResourceGroup")
                    .WithKey(rg => rg.Name)
                    .WithPreexistingHierarchyReference("ResourceGroups");

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(ResourceGroup)] = m
            };

            var resourceGroup = new ResourceGroup {
                Name = "myRG"
            };
            var relations = new List <ParentChildRelation> {
                new ParentChildRelation(null, resourceGroup)
                {
                    PreexistingHierarchyReference = "ResourceGroups"
                }
            };

            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var session = Helper.GetSession();

            session.AddComponent("myRG", null, "ResourceGroup", null);
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.AddMissingComponents(hierarchy);

            // Assert
            Assert.Single(session.GetAllComponents());
            Assert.Equal(0, c);
        }
コード例 #10
0
        public void AddMissingComponents_IsNew_ExpectedFieldValuesSentToArdoq()
        {
            // Arrange
            var m = new ComponentMapping <Employee>("Employee")
                    .WithKey(e => e.Name)
                    .WithField(e => e.EmployeeNumber, "employee-number");
            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(Employee)] = m
            };

            var employee = new Employee {
                Name = "Don Johnsen", EmployeeNumber = "808"
            };
            var relations = new List <ParentChildRelation>
            {
                new ParentChildRelation(null, employee)
                {
                    PreexistingHierarchyReference = "Employees"
                }
            };

            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var session    = Helper.GetSession();
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            maintainer.AddMissingComponents(hierarchy);

            // Assert
            var comp = session.GetComponents("Employee", "Don Johnsen").Single();

            Assert.Single(comp.Fields);
            Assert.Equal("808", comp.Fields["employee-number"]);
        }
コード例 #11
0
        public void UpdateComponentTags_TagExistsOnTwoComponentsWithSameName_UpdatesTag()
        {
            // Arrange
            const string componentTypeSub = "Subscription";
            var          componentTypeRG  = "ResourceGroup";
            var          componentTypeEHN = "EventHubNamespace";
            var          tagString        = "tag1";
            var          ehNamespaceName  = "my-namespace";
            string       workspaceId      = Guid.NewGuid().ToString();

            var sub = new Subscription {
                Name = "subName"
            };
            var rg1 = new ResourceGroup {
                Name = "rg1Name"
            };
            var rg2 = new ResourceGroup {
                Name = "rg2Name"
            };
            var ehn1 = new EventHubNamespace
            {
                Name          = ehNamespaceName,
                ResourceGroup = rg1,
                Tags          = new List <string> {
                    tagString
                }
            };
            var ehn2 = new EventHubNamespace
            {
                Name          = ehNamespaceName,
                ResourceGroup = rg2,
                Tags          = new List <string> {
                    tagString
                }
            };
            List <ParentChildRelation> relations = Helper.CreateRelations((null, sub), (sub, rg1), (sub, rg2), (rg1, ehn1), (rg2, ehn2));

            var mappings  = Helper.GetModel(ModelType.Subscription_ResourceGroup_EventHubNamespace);
            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var compSub = new Component(sub.Name, workspaceId, null)
            {
                Type = componentTypeSub, Id = "subid"
            };
            var compRG1 = new Component(rg1.Name, workspaceId, null)
            {
                Type = componentTypeRG, Id = "rg1id", Parent = compSub.Id
            };
            var compRG2 = new Component(rg2.Name, workspaceId, null)
            {
                Type = componentTypeRG, Id = "rg2id", Parent = compSub.Id
            };
            var compEHN1 = new Component(ehNamespaceName, workspaceId, null)
            {
                Type = componentTypeEHN, Id = "ehn1componentId", Parent = compRG1.Id
            };
            var compEHN2 = new Component(ehNamespaceName, workspaceId, null)
            {
                Type = componentTypeEHN, Id = "ehn2componentId", Parent = compRG2.Id
            };
            var existingTag = new Tag(tagString, null, null)
            {
                Components = new List <string> {
                    "tag2"
                }
            };
            var components = new List <Component> {
                compSub, compRG1, compRG2, compEHN1, compEHN2
            };
            var session = Helper.GetSession(workspaceId, components, new List <Tag> {
                existingTag
            });

            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.UpdateComponentTags(hierarchy);

            // Assert
            Assert.Equal(3, existingTag.Components.Count);
            Assert.Equal(2, c);
        }
        public void DeleteComponents_SuperfluousTreeInArdoq_DeletesComponentInArdoqOnCorrectOrder()
        {
            // Arrange
            var md = new ComponentMapping <Department>("Department")
                     .WithKey(rg => rg.Name);
            var me = new ComponentMapping <Employee>("Employee")
                     .WithKey(rg => rg.EmployeeNumber)
                     .WithModelledHierarchyReference(e => e.EmployedIn, ModelledReferenceDirection.Child)
                     .WithModelledHierarchyReference(e => e.Roles, ModelledReferenceDirection.Parent)
                     .WithField(e => e.Name, "employee-name")
                     .WithField(e => e.Age, "age");
            var mr = new ComponentMapping <Role>("Role")
                     .WithKey(rg => rg.Name);

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(Department)] = md,
                [typeof(Employee)]   = me,
                [typeof(Role)]       = mr,
            };

            var relations = new List <ParentChildRelation> {
            };

            var hierarchies  = new ParentChildRelationHierarchyBuilder(mappings).BuildRelationHierarchies(relations);
            var strickMock   = new Mock <IArdoqSession>(MockBehavior.Strict);
            var mockSequence = new MockSequence();

            var compDepartment = new Component("Sony", null, null)
            {
                Type = "Department", Id = "depId"
            };

            strickMock.Setup(s => s.GetComponentsOfType("Department"))
            .Returns(new List <Component> {
                compDepartment
            });

            var compEmployee = new Component("XX99", null, null)
            {
                Type = "Employee", Parent = compDepartment.Id
            };

            strickMock.Setup(s => s.GetComponentsOfType("Employee"))
            .Returns(new List <Component> {
                compEmployee
            });

            var compRole = new Component("Role132", null, null)
            {
                Type = "Role", Parent = compDepartment.Id
            };

            strickMock.Setup(s => s.GetComponentsOfType("Role"))
            .Returns(new List <Component> {
                compRole
            });

            strickMock.InSequence(mockSequence).Setup(s => s.DeleteComponent(compRole));
            strickMock.InSequence(mockSequence).Setup(s => s.DeleteComponent(compEmployee));
            strickMock.InSequence(mockSequence).Setup(s => s.DeleteComponent(compDepartment));

            var maintainer = new ComponentHierarchyMaintainer(mappings, strickMock.Object);

            // Act
            var c = maintainer.DeleteComponents(hierarchies);

            // Assert
            strickMock.VerifyAll();
            Assert.Equal(3, c);
        }
コード例 #13
0
        public void AddMissingComponents_MissingComponentWithExistingNameDifferentGrandParent_CreatesComponentInArdoq()
        {
            // Arrange
            const string subscriptionName      = "mySub";
            const string rg1Name               = "myRG1";
            const string rg2Name               = "myRG2";
            const string eventHubNamespaceName = "myEventHubNamespace";
            const string eventHubName          = "myEventHub";
            const string workspaceId           = "workspaceId";

            var sub = new Subscription {
                Name = subscriptionName
            };
            var rg1 = new ResourceGroup {
                Name = rg1Name, Subscription = sub
            };
            var rg2 = new ResourceGroup {
                Name = rg2Name, Subscription = sub
            };
            var eh1 = new EventHub {
                Name = eventHubName
            };
            var eh2 = new EventHub {
                Name = eventHubName
            };                                              // Same name as eh1
            var ehn1 = new EventHubNamespace {
                Name = eventHubNamespaceName, ResourceGroup = rg1, EventHubs = new List <EventHub> {
                    eh1
                }
            };
            var ehn2 = new EventHubNamespace {
                Name = eventHubNamespaceName, ResourceGroup = rg2, EventHubs = new List <EventHub> {
                    eh2
                }
            };                                                                                                                               // Same name as ehn1

            var relations = Helper.CreateRelations((null, sub), (sub, rg1), (sub, rg2), (rg1, ehn1), (rg2, ehn2), (ehn1, eh1), (ehn2, eh2));

            var mappings  = Helper.GetModel(ModelType.Subscription_ResourceGroup_EventHubNamespace_EventHub);
            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var subComp = new Component(subscriptionName, workspaceId, null)
            {
                Type = "Subscription", Id = "subId"
            };
            var rg1Comp = new Component(rg1Name, workspaceId, null)
            {
                Type = "ResourceGroup", Id = "rg1Id", Parent = subComp.Id
            };
            var rg2Comp = new Component(rg2Name, workspaceId, null)
            {
                Type = "ResourceGroup", Id = "rg2Id", Parent = subComp.Id
            };
            var ehn1Comp = new Component(eventHubNamespaceName, workspaceId, null)
            {
                Type = "EventHubNamespace", Id = "ehn1Id", Parent = rg1Comp.Id
            };
            var ehn2Comp = new Component(eventHubNamespaceName, workspaceId, null)
            {
                Type = "EventHubNamespace", Id = "ehn2Id", Parent = rg2Comp.Id
            };
            var ehComp = new Component(eventHubName, workspaceId, null)
            {
                Type = "EventHub", Id = "ehId", Parent = ehn1Comp.Id
            };
            var session = Helper.GetSession(workspaceId, new List <Component> {
                subComp, rg1Comp, rg2Comp, ehn1Comp, ehn2Comp, ehComp
            });

            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.AddMissingComponents(hierarchy);

            // Assert
            Assert.Equal(1, c);
        }
コード例 #14
0
        public void UpdateComponents_TwoComponentsWithSameName_NoChanges_NoUpdatesToArdoq()
        {
            // Arrange
            const string workspaceId = "workspaceId";
            var          d           = new ComponentMapping <Department>("Department")
                                       .WithKey(dd => dd.Name);

            var m = new ComponentMapping <Employee>("Employee")
                    .WithKey(rg => rg.EmployeeNumber)
                    .WithField(e => e.Name, "employee-name")
                    .WithField(e => e.Age, "age")
                    .WithPreexistingHierarchyReference("Employees");

            var mappings = new Dictionary <Type, IBuiltComponentMapping>
            {
                [typeof(Department)] = d,
                [typeof(Employee)]   = m
            };

            var department1 = new Department {
                Name = "Sony Music"
            };
            var department2 = new Department {
                Name = "MTV"
            };
            var employee = new Employee {
                Name = "Michael Jackson", EmployeeNumber = "XX99", Age = 55
            };
            var builder   = new ParentChildRelationHierarchyBuilder(mappings);
            var relations = new List <ParentChildRelation>
            {
                new ParentChildRelation(null, department1)
                {
                },
                new ParentChildRelation(department1, employee)
                {
                },
                new ParentChildRelation(department2, employee)
                {
                }
            };

            var hierarchy = builder.BuildRelationHierarchies(relations).First();

            var compDep1 = new Component("Sony Music", workspaceId, null)
            {
                Id = "parentId1", Type = "Department"
            };
            var compDep2 = new Component("MTV", workspaceId, null)
            {
                Id = "parentId2", Type = "Department"
            };
            var comp1 = new Component("XX99", workspaceId, null)
            {
                Id     = "id1",
                Parent = compDep1.Id,
                Type   = "Employee",
                Fields = new Dictionary <string, object>
                {
                    ["employee-name"] = "Michael Jackson",
                    ["age"]           = 55
                }
            };
            var comp2 = new Component("XX99", workspaceId, null)
            {
                Id     = "id2",
                Parent = compDep2.Id,
                Type   = "Employee",
                Fields = new Dictionary <string, object>
                {
                    ["employee-name"] = "Michael Jackson",
                    ["age"]           = 55
                }
            };

            var session = Helper.GetSession(workspaceId, new List <Component> {
                compDep1, compDep2, comp1, comp2
            });
            var maintainer = new ComponentHierarchyMaintainer(mappings, session);

            // Act
            var c = maintainer.UpdateComponents(hierarchy);

            // Assert
            Assert.Equal(0, c);
        }