public void EvaluateSVAVRDateTimeEqualsTest()
        {
            bool expected = true;
            bool actual;

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("dateTimeSV");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("2010-01-01");

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("dateTimeSV"), DateTime.Parse("2010-01-01"));
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("dateTimeSV"), DateTime.Parse("2011-01-01"));
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
        public void EvaluateSVAVRBinaryEqualsTest()
        {
            bool expected = true;
            bool actual;
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("objectSid");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("AAECAwQ=");

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("objectSid"), new byte[] { 0, 1, 2, 3, 4 });
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("objectSid"), new byte[] { 0, 0, 0, 3, 4 });
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #3
0
        public void DBQueryByAttributeMVToMVEquals()
        {
            Guid searchObjectId      = Guid.NewGuid();
            Guid valueSourceObjectId = Guid.NewGuid();

            DBQueryByValue match1 = new DBQueryByValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("mailAlternateAddresses"));
            DBQueryByValue match2 = new DBQueryByValue(ActiveConfig.DB.GetAttribute("objectId"), ValueOperator.Equals, searchObjectId);
            DBQueryGroup   group  = new DBQueryGroup(GroupOperator.All);

            group.AddChildQueryObjects(match1, match2);

            try
            {
                MAObjectHologram searchObject = ActiveConfig.DB.CreateMAObject(searchObjectId, "person");
                searchObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**", "*****@*****.**"
                });
                searchObject.CommitCSEntryChange();

                MAObjectHologram valueSourceObject = ActiveConfig.DB.CreateMAObject(valueSourceObjectId, "person");
                valueSourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**"
                });
                valueSourceObject.CommitCSEntryChange();

                List <MAObjectHologram> results = ActiveConfig.DB.GetMAObjectsFromDBQuery(group, valueSourceObject).ToList();

                if (results.Count() != 1)
                {
                    Assert.Fail("The incorrect number of results were returned");
                }

                if (results.First().ObjectID != searchObjectId)
                {
                    Assert.Fail("The incorrect object was returned");
                }

                valueSourceObject.SetObjectModificationType(ObjectModificationType.Update, false);
                valueSourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**"
                });

                valueSourceObject.CommitCSEntryChange();

                results = ActiveConfig.DB.GetMAObjectsFromDBQuery(group, valueSourceObject).ToList();

                if (results.Count != 0)
                {
                    Assert.Fail("The test returned an unexpected object");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(searchObjectId);
                ActiveConfig.DB.DeleteMAObjectPermanent(valueSourceObjectId);
            }
        }
        public void EvaluateSVAVRStringEqualsProposedTest()
        {
            bool expected = true;
            bool actual;
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("mail");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("*****@*****.**");
                target.View          = HologramView.Proposed;

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
        public void EvaluateSVAVRLongEqualsTest()
        {
            bool expected = true;
            bool actual;

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("sapExpiryDate");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("1234567890");

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sapExpiryDate"), 1234567890L);
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sapExpiryDate"), 9876543210L);
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
        public void PerformBulkUniqueAllocationTest()
        {
            UniqueValueConstructor constructor = new UniqueValueConstructor();
            AcmaSchemaAttribute    attribute   = ActiveConfig.DB.GetAttribute("accountName");

            constructor.UniqueAllocationAttributes = new System.Collections.Generic.List <AcmaSchemaAttribute>()
            {
                attribute
            };
            constructor.ValueDeclaration = new UniqueValueDeclaration("{sn}%n%");
            constructor.Attribute        = attribute;

            List <Guid> preCreatedIDs = new List <Guid>();
            List <Guid> testIDs       = new List <Guid>();

            int prestage  = 100;
            int testcount = 200;

            try
            {
                for (int i = 1; i <= prestage; i++)
                {
                    Guid             newId        = Guid.NewGuid();
                    MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                    preCreatedIDs.Add(newId);

                    sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sn"), "yzhu");
                    sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("accountName"), string.Format("yzhu{0}", i));
                    sourceObject.CommitCSEntryChange();
                }

                for (int i = 1; i <= testcount; i++)
                {
                    Guid             newId        = Guid.NewGuid();
                    MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                    testIDs.Add(newId);

                    sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sn"), "yzhu");
                    constructor.Execute(sourceObject);
                    sourceObject.CommitCSEntryChange();

                    AttributeValue value = sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("accountName"));

                    Assert.AreEqual(string.Format("yzhu{0}", i + prestage), value.ValueString);
                }
            }
            finally
            {
                foreach (Guid id in preCreatedIDs)
                {
                    ActiveConfig.DB.DeleteMAObjectPermanent(id);
                }

                foreach (Guid id in testIDs)
                {
                    ActiveConfig.DB.DeleteMAObjectPermanent(id);
                }
            }
        }
        public void EvaluateMVAVRNoMatchTest()
        {
            bool actual;
            bool expected = true;

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("mailAlternateAddresses");
                target.ValueOperator = ValueOperator.Equals;
                target.GroupOperator = GroupOperator.None;
                target.ExpectedValue = new ValueDeclaration("*****@*****.**");


                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**", "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreEqual(expected, actual);

                // Negative Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**", "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);

                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**"
                });
                actual = target.Evaluate(maObject);
                Assert.AreNotEqual(expected, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #8
0
        public void EvaluateOnSVAttributePresentCurrent()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("accountName"), "mytestvalue");
                maObject.CommitCSEntryChange();

                // Positive Tests
                AttributePresenceRule target = new AttributePresenceRule();
                target.Attribute = ActiveConfig.DB.GetAttribute("accountName");
                target.Operator  = PresenceOperator.IsPresent;
                target.View      = HologramView.Current;
                Assert.IsTrue(target.Evaluate(maObject));

                // Negative Tests
                target           = new AttributePresenceRule();
                target.Attribute = ActiveConfig.DB.GetAttribute("accountName");
                target.Operator  = PresenceOperator.NotPresent;
                target.View      = HologramView.Current;
                Assert.IsFalse(target.Evaluate(maObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #9
0
        public void EvaluateGroupAllTestNested()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");

                // Positive Tests
                RuleGroup target = GetAllGroup();
                RuleGroup group2 = GetAllGroup();
                target.Items.Add(group2);

                Assert.IsTrue(target.Evaluate(maObject));

                // Negative Tests
                ValueComparisonRule rule4 = new ValueComparisonRule();
                rule4.Attribute     = ActiveConfig.DB.GetAttribute("mail");
                rule4.ValueOperator = ValueOperator.Equals;
                rule4.ExpectedValue = new ValueDeclaration("*****@*****.**");
                target.Items.Add(rule4);

                Assert.IsFalse(target.Evaluate(maObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #10
0
        public void AttributeDeleteConstructorSVTest()
        {
            AttributeValueDeleteConstructor attributeConstructor = new AttributeValueDeleteConstructor();

            attributeConstructor.Attribute = ActiveConfig.DB.GetAttribute("mail");
            attributeConstructor.RuleGroup = new RuleGroup();
            attributeConstructor.RuleGroup.Items.Add(new ObjectChangeRule()
            {
                TriggerEvents = TriggerEvents.Add
            });

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                sourceObject.CommitCSEntryChange();
                sourceObject.DiscardPendingChanges();
                sourceObject.SetObjectModificationType(ObjectModificationType.Update, false);
                attributeConstructor.Execute(sourceObject);

                AttributeValue value = sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("mail"));

                if (!value.IsNull)
                {
                    Assert.Fail("The constructor did not delete the attribute value");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #11
0
        public void EvaluateGroupNoneTest()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");

                // Positive Tests
                RuleGroup target = GetNoneGroup();
                Assert.IsTrue(target.Evaluate(maObject));

                target = GetNoneGroup();
                target.Items.Add(GetAnyGroupNoMatch());
                Assert.IsTrue(target.Evaluate(maObject));

                // Negative Tests
                target = GetNoneGroupNoMatch();
                Assert.IsFalse(target.Evaluate(maObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #12
0
        public void EvaluateOnMVAttributePresentProposed()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("directReports"), new List <object> {
                    Guid.NewGuid().ToString(), Guid.NewGuid().ToString()
                });

                // Positive Tests
                AttributePresenceRule target = new AttributePresenceRule();
                target.Attribute = ActiveConfig.DB.GetAttribute("directReports");
                target.Operator  = PresenceOperator.IsPresent;
                target.View      = HologramView.Proposed;
                Assert.IsTrue(target.Evaluate(maObject));

                // Negative Tests
                target           = new AttributePresenceRule();
                target.Attribute = ActiveConfig.DB.GetAttribute("directReports");
                target.Operator  = PresenceOperator.NotPresent;
                target.View      = HologramView.Proposed;
                Assert.IsFalse(target.Evaluate(maObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #13
0
        /// <summary>
        /// Constructs a target attribute value based on the rules in the constructor
        /// </summary>
        /// <param name="hologram">The object to construct the value for</param>
        internal override void Execute(MAObjectHologram hologram)
        {
            List <MAObjectHologram> matchedObjects = ActiveConfig.DB.GetMAObjectsFromDBQuery(this.QueryGroup, hologram).ToList();

            if (matchedObjects.Count == 0)
            {
                hologram.DeleteAttribute(this.Attribute);
            }
            else
            {
                switch (this.MultipleResultAction)
                {
                case MultipleResultAction.UseAll:
                    if (!this.Attribute.IsMultivalued && matchedObjects.Count > 1)
                    {
                        throw new MultipleMatchException(string.Format("The reference lookup constructor for attribute {0} returned more than one result", this.Attribute));
                    }

                    hologram.SetAttributeValue(this.Attribute, matchedObjects.Select(t => (object)t.ObjectID).ToList());
                    break;

                case MultipleResultAction.UseFirst:
                    hologram.SetAttributeValue(this.Attribute, matchedObjects.First().ObjectID);
                    break;

                case MultipleResultAction.UseNone:
                    if (matchedObjects.Count > 1)
                    {
                        hologram.SetAttributeValue(this.Attribute, null);
                    }
                    else
                    {
                        hologram.SetAttributeValue(this.Attribute, matchedObjects.First().ObjectID);
                    }

                    break;

                case MultipleResultAction.Error:
                    throw new MultipleMatchException(string.Format("The reference lookup constructor for attribute {0} returned more than one result", this.Attribute));

                default:
                    throw new UnknownOrUnsupportedDataTypeException();
                }
            }

            this.RaiseCompletedEvent();
        }
        public void ReferenceLookupUseAllResults()
        {
            ReferenceLookupConstructor constructor = new ReferenceLookupConstructor();

            constructor.Attribute            = ActiveConfig.DB.GetAttribute("displayNameSharers");
            constructor.MultipleResultAction = MultipleResultAction.UseAll;
            constructor.QueryGroup           = new DBQueryGroup()
            {
                Operator = GroupOperator.All
            };
            constructor.QueryGroup.DBQueries.Add(new DBQueryByValue(ActiveConfig.DB.GetAttribute("displayName"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("displayName")));

            Guid object1Id = Guid.NewGuid();
            Guid object2Id = Guid.NewGuid();
            Guid object3Id = Guid.NewGuid();
            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person");

            try
            {
                MAObjectHologram object1 = ActiveConfig.DB.CreateMAObject(object1Id, "person");
                object1.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object1.CommitCSEntryChange();

                MAObjectHologram object2 = ActiveConfig.DB.CreateMAObject(object2Id, "person");
                object2.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object2.CommitCSEntryChange();

                MAObjectHologram object3 = ActiveConfig.DB.CreateMAObject(object3Id, "person");
                object3.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                constructor.Execute(object3);
                object3.CommitCSEntryChange();

                object3 = ActiveConfig.DB.GetMAObject(object3Id, objectClass);
                AttributeValues values = object3.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("displayNameSharers"));

                if (values.IsEmptyOrNull)
                {
                    Assert.Fail("The constructor did not create any results");
                }

                if (!values.ContainsAllElements(new List <object> {
                    object1Id, object2Id
                }))
                {
                    Assert.Fail("The constructor did not create the correct values");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(object1Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object2Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object3Id);
            }
        }
Exemple #15
0
        public void TextExitEvent()
        {
            Guid newId = Guid.NewGuid();

            string tempFileName = Path.Combine(Path.GetTempPath(), newId.ToString());

            try
            {
                AcmaExternalExitEventCmd e = new AcmaExternalExitEventCmd();
                e.ID        = "test external event";
                e.RuleGroup = new RuleGroup()
                {
                    Operator = GroupOperator.Any
                };
                e.RuleGroup.Items.Add(new ObjectChangeRule()
                {
                    TriggerEvents = TriggerEvents.Add
                });
                e.CommandLine = "cmd.exe";
                e.Arguments   = new ValueDeclaration("/c dir >> " + tempFileName.Replace(@"\", @"\\"));

                if (!ActiveConfig.XmlConfig.ClassConstructors.Contains("person"))
                {
                    ClassConstructor constructor = new ClassConstructor();
                    constructor.ObjectClass = ActiveConfig.DB.GetObjectClass("person");
                    ActiveConfig.XmlConfig.ClassConstructors.Add(constructor);
                }

                ActiveConfig.XmlConfig.ClassConstructors["person"].ExitEvents.Add(e);

                MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                sourceObject.CommitCSEntryChange();

                if (!System.IO.File.Exists(tempFileName))
                {
                    Assert.Fail("The external event did not created the expected file");
                }
            }
            finally
            {
                if (System.IO.File.Exists(tempFileName))
                {
                    System.IO.File.Delete(tempFileName);
                }
            }
        }
 /// <summary>
 /// Adds a reference to the source object on the specified target object
 /// </summary>
 /// <param name="sourceObject">The object to add a reference to</param>
 /// <param name="targetObject">The object to add the reference on</param>
 private void AddReference(MAObjectHologram sourceObject, MAObjectHologram targetObject)
 {
     if (this.BackLinkAttribute.IsMultivalued)
     {
         if (!targetObject.HasAttributeValue(this.BackLinkAttribute, sourceObject.ObjectID))
         {
             targetObject.UpdateAttributeValue(this.BackLinkAttribute, new List <ValueChange>()
             {
                 ValueChange.CreateValueAdd(sourceObject.ObjectID)
             });
         }
     }
     else
     {
         targetObject.SetAttributeValue(this.BackLinkAttribute, sourceObject.ObjectID);
     }
 }
        public void ReferenceLookupErrorOnMultipleResults()
        {
            ReferenceLookupConstructor constructor = new ReferenceLookupConstructor();

            constructor.Attribute            = ActiveConfig.DB.GetAttribute("displayNameSharers");
            constructor.MultipleResultAction = MultipleResultAction.Error;
            constructor.QueryGroup           = new DBQueryGroup()
            {
                Operator = GroupOperator.All
            };
            constructor.QueryGroup.DBQueries.Add(new DBQueryByValue(ActiveConfig.DB.GetAttribute("displayName"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("displayName")));

            Guid object1Id = Guid.NewGuid();
            Guid object2Id = Guid.NewGuid();
            Guid object3Id = Guid.NewGuid();

            try
            {
                MAObjectHologram object1 = ActiveConfig.DB.CreateMAObject(object1Id, "person");
                object1.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object1.CommitCSEntryChange();

                MAObjectHologram object2 = ActiveConfig.DB.CreateMAObject(object2Id, "person");
                object2.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object2.CommitCSEntryChange();

                try
                {
                    MAObjectHologram object3 = ActiveConfig.DB.CreateMAObject(object3Id, "person");
                    object3.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                    constructor.Execute(object3);
                    object3.CommitCSEntryChange();
                    Assert.Fail("The expected exception was not throw");
                }
                catch (MultipleMatchException)
                {
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(object1Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object2Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object3Id);
            }
        }
        /// <summary>
        /// Applies the value changes created by the constructor to the underlying object, using the requested modification type to define how to apply the new values
        /// </summary>
        /// <param name="hologram">The object to apply the changes to</param>
        /// <param name="valueChanges">The value changes to apply</param>
        /// <param name="modificationType">The type of modification to apply to the object</param>
        protected void ApplyValueChanges(MAObjectHologram hologram, IList <ValueChange> valueChanges, AcmaAttributeModificationType modificationType)
        {
            switch (modificationType)
            {
            case AcmaAttributeModificationType.Add:
                hologram.UpdateAttributeValue(this.Attribute, valueChanges);
                break;

            case AcmaAttributeModificationType.Replace:
                hologram.SetAttributeValue(this.Attribute, valueChanges.Select(t => t.Value).ToList <object>());
                break;

            case AcmaAttributeModificationType.Delete:
                hologram.UpdateAttributeValue(this.Attribute, valueChanges);
                break;

            default:
                throw new InvalidOperationException("The specified modification type is unsupported for this constructor");
            }
        }
Exemple #19
0
        public void EvaluateOnSourceEvent()
        {
            Guid supervisorId = Guid.NewGuid();
            Guid targetId     = Guid.NewGuid();

            try
            {
                MAObjectHologram supervisorObject = ActiveConfig.DB.CreateMAObject(supervisorId, "person");
                MAObjectHologram targetObject     = ActiveConfig.DB.CreateMAObject(targetId, "person");

                AcmaSchemaAttribute supervisorAttribute = ActiveConfig.DB.GetAttribute("supervisor");
                targetObject.SetAttributeValue(supervisorAttribute, supervisorObject.ObjectID);
                targetObject.CommitCSEntryChange();

                AcmaEvent   maevent   = GetAccountNameChangedEvent();
                RaisedEvent exitEvent = new RaisedEvent(maevent, supervisorObject);
                targetObject.IncomingEvents = new List <RaisedEvent>()
                {
                    exitEvent
                };

                // Positive Tests
                EventRule target = new EventRule();
                target.EventName   = "accountNameChanged";
                target.EventSource = ActiveConfig.DB.GetAttribute("supervisor");
                Assert.IsTrue(target.Evaluate(targetObject));

                // Negative Tests
                target             = new EventRule();
                target.EventName   = "accountNameChanged";
                target.EventSource = ActiveConfig.DB.GetAttribute("directReports");
                Assert.IsFalse(target.Evaluate(targetObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(targetId);
                ActiveConfig.DB.DeleteMAObjectPermanent(supervisorId);
            }
        }
Exemple #20
0
        public void EvaluateMVStringOneEqualsTest()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "test1", "test2"
                });
                maObject.CommitCSEntryChange();

                AdvancedComparisonRule target = new AdvancedComparisonRule();

                target.CompareAs     = ExtendedAttributeType.String;
                target.SourceValue   = new ValueDeclaration("{mailAlternateAddresses}");
                target.TargetValue   = new ValueDeclaration("test1");
                target.ValueOperator = ValueOperator.Equals;
                target.GroupOperator = GroupOperator.One;

                if (!target.Evaluate(maObject))
                {
                    Assert.Fail("The value comparison failed");
                }

                target.TargetValue = new ValueDeclaration("{mailAlternateAddresses}");

                if (target.Evaluate(maObject))
                {
                    Assert.Fail("The value comparison did not fail");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Exemple #21
0
        public void ExportCSEntryChangeAddResurrect()
        {
            Guid originalId    = Guid.NewGuid();
            Guid replacementId = Guid.NewGuid();

            if (!ActiveConfig.XmlConfig.ClassConstructors.Contains("person"))
            {
                ActiveConfig.XmlConfig.ClassConstructors.Add(new ClassConstructor()
                {
                    ObjectClass = ActiveConfig.DB.GetObjectClass("person")
                });
            }

            ActiveConfig.XmlConfig.ClassConstructors["person"].ResurrectionParameters          = new DBQueryGroup();
            ActiveConfig.XmlConfig.ClassConstructors["person"].ResurrectionParameters.Operator = GroupOperator.Any;
            DBQueryByValue query = new DBQueryByValue(ActiveConfig.DB.GetAttribute("sapPersonId"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("sapPersonId"));

            ActiveConfig.XmlConfig.ClassConstructors["person"].ResurrectionParameters.DBQueries.Add(query);


            CSEntryChange csentry = CSEntryChange.Create();

            csentry.DN = originalId.ToString();
            csentry.ObjectModificationType = ObjectModificationType.Add;
            csentry.ObjectType             = "person";
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mail", "*****@*****.**"));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mailAlternateAddresses", new List <object> {
                "*****@*****.**", "*****@*****.**"
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("unixUid", 44L));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("expiryDates", new List <object>()
            {
                55L, 66L, 77L
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("directReports", new List <object>()
            {
                new Guid("{8FC92471-7835-4804-8BBB-0A5ED7078074}"), new Guid("{0EF7CC21-729E-4ED9-A3AF-8203796334C6}")
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("supervisor", new Guid("{2807ED76-E262-4EB4-ABD9-9629F3830F12}")));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("connectedToSap", true));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSids", new List <object>()
            {
                new byte[] { 0, 1, 2, 3, 4, 5 }, new byte[] { 2, 4, 6, 8, 0 }
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSid", new byte[] { 0, 1, 2, 3, 4 }));

            try
            {
                bool refretry;
                CSEntryExport.PutExportEntry(csentry, out refretry);
                AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person");

                MAObjectHologram originalObject = ActiveConfig.DB.GetMAObject(originalId, objectClass);
                originalObject.SetObjectModificationType(ObjectModificationType.Update, false);
                originalObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sapPersonId"), 7777L);
                originalObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("accountName"), "jesus");
                originalObject.DeletedTimestamp = DateTime.UtcNow.Ticks;
                originalObject.CommitCSEntryChange();

                csentry    = CSEntryChange.Create();
                csentry.DN = replacementId.ToString();
                csentry.ObjectModificationType = ObjectModificationType.Add;
                csentry.ObjectType             = "person";
                csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mail", "*****@*****.**"));
                csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("sapPersonId", 7777L));

                CSEntryExport.PutExportEntry(csentry, out refretry);

                MAObjectHologram newObject = ActiveConfig.DB.GetMAObjectOrDefault(replacementId);

                if (newObject == null)
                {
                    Assert.Fail("The object with the new ID was not found");
                }

                if (newObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("accountName")) != "jesus")
                {
                    Assert.Fail("The object was not resurrected");
                }

                if (newObject.DeletedTimestamp != 0)
                {
                    Assert.Fail("The object was not undeleted");
                }

                originalObject = ActiveConfig.DB.GetMAObjectOrDefault(originalId);

                if (originalObject != null)
                {
                    Assert.Fail("The original object still exists");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(originalId);
                ActiveConfig.DB.DeleteMAObjectPermanent(replacementId);
            }
        }