/** * Creates a set of mappings that operations can be applied to, such as * saving to a DOM or Agent.cfg. The results can be asserted by calling * {@see #assertMappings(Mappings)}. * * NOTE: This method returns an AgentConfig instance instead of a mappings * instance because there is no way set the Mappings instance on * AgentConfig. This might change in the future * * @return */ private AgentConfig createMappings() { Mappings root = fCfg.Mappings; // Remove the mappings being used root.RemoveChild(root.GetMappings("Default")); root.RemoveChild(root.GetMappings("TestID")); Mappings newMappings = root.CreateChild("Test"); // Add an object mapping ObjectMapping objMap = new ObjectMapping("StudentPersonal"); // Currently, the Adk code requires that an Object Mapping be added // to it's parent before fields are added. // We should re-examine this and perhaps fix it, if possible newMappings.AddRules(objMap); objMap.AddRule(new FieldMapping("FIELD1", "Name/FirstName")); // Field 2 FieldMapping field2 = new FieldMapping("FIELD2", "Name/LastName"); field2.ValueSetID = "VS1"; field2.Alias = "ALIAS1"; field2.DefaultValue = "DEFAULT1"; MappingsFilter mf = new MappingsFilter(); mf.Direction = MappingDirection.Inbound; mf.SifVersion = SifVersion.SIF11.ToString(); field2.Filter = mf; objMap.AddRule(field2); // Field 3 test setting the XML values after it's been added to the // parent object (the code paths are different) FieldMapping field3 = new FieldMapping("FIELD3", "Name/MiddleName"); objMap.AddRule(field3); field3.ValueSetID = "VS2"; field3.Alias = "ALIAS2"; field3.DefaultValue = "DEFAULT2"; MappingsFilter mf2 = new MappingsFilter(); mf2.Direction = MappingDirection.Outbound; mf2.SifVersion = SifVersion.SIF15r1.ToString(); field3.Filter = mf2; field3.NullBehavior = MappingBehavior.IfNullDefault; OtherIdMapping oim = new OtherIdMapping("ZZ", "BUSROUTE"); FieldMapping field4 = new FieldMapping("FIELD4", oim); objMap.AddRule(field4); field4.DefaultValue = "Default"; field4.ValueSetID = "vs"; field4.Alias = "alias"; field4.DefaultValue = null; field4.ValueSetID = null; field4.Alias = null; field4.NullBehavior = MappingBehavior.IfNullSuppress; // Field4 tests the new datatype attribute FieldMapping field5 = new FieldMapping("FIELD5", "Demographics/BirthDate"); objMap.AddRule(field5); field5.DataType = SifDataType.Date; // Add a valueset translation ValueSet vs = new ValueSet("VS1"); newMappings.AddValueSet(vs); // Add a few definitions for (int a = 0; a < 10; a++) { vs.Define("Value" + a, "SifValue" + a, "Title" + a); } vs.Define("AppDefault", "0000", "Default App Value"); vs.SetAppDefault("AppDefault", true); vs.Define("0000", "SifDefault", "Default Sif Value"); vs.SetSifDefault("SifDefault", false); // Add a valueset translation vs = new ValueSet("VS2"); newMappings.AddValueSet(vs); // Add a few definitions for (int a = 0; a < 3; a++) { vs.Define("q" + a, "w" + a, "t" + a); } vs.Define("AppDefault", "0000", "Default Value"); vs.SetAppDefault("AppDefault", true); vs.SetSifDefault("0000", true); return(fCfg); }