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); } }
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 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); } }