/** * Test SIF Query Pattern support in the ADK * * @param objectDef * The IElementDef representing the root SIF Object * @param def * The IElementDef representing the field being queried (e.g. * CommonDTD.NAME_FIRSTNAME) * @param sqp * The expected SIF Query Pattern (e.g. "Name/FirstName") for the * above field def * @param version * The version of SIF to test */ private Query testSQP( IElementDef objectDef, IElementDef def, String sqp, SifVersion version ) { Adk.SifVersion = version; IElementDef lookedUp = Adk.Dtd.LookupElementDefBySQP( objectDef, sqp ); Assert.AreEqual( def.Name, lookedUp.Name, "IElementDef" ); testResolveBySQP( objectDef, sqp, version, def ); Query q = new Query( objectDef ); q.AddCondition( def, ComparisonOperators.EQ, "foo" ); String sifQueryXML = q.ToXml(); Console.WriteLine( sifQueryXML ); String searchFor = "<SIF_Element>" + sqp + "</SIF_Element>"; Assert.IsTrue( sifQueryXML.Contains( searchFor ), "SQP in XML" ); SifParser parser = SifParser.NewInstance(); SIF_Request sifR = (SIF_Request) parser.Parse( "<SIF_Request>" + sifQueryXML + "</SIF_Request>", null ); Query newQuery = new Query( sifR.SIF_Query ); Condition cond = newQuery.HasCondition( sqp ); Assert.IsNotNull( cond, "hasCondition" ); Assert.AreEqual( sqp, cond.GetXPath(), "SQP" ); Assert.AreEqual( def, cond.Field, "IElementDef" ); return newQuery; }
private Query testResolveBySQP( IElementDef objectDef, String sqp, SifVersion version, IElementDef resolvedNestedElement ) { Adk.SifVersion = version; Query q = new Query( objectDef ); q.AddCondition( sqp, ComparisonOperators.EQ, "foo" ); String sifQueryXML = q.ToXml(); Console.WriteLine( sifQueryXML ); String searchFor = "<SIF_Element>" + sqp + "</SIF_Element>"; // The .Net ADK doesn't encode apostrophes when they are in // element content, so the following line is different than // the java test //searchFor = searchFor.Replace( "'", "'" ); Assert.IsTrue( sifQueryXML.Contains( searchFor ), "SQP in XML" ); SifParser parser = SifParser.NewInstance(); SIF_Request sifR = (SIF_Request) parser.Parse( "<SIF_Request>" + sifQueryXML + "</SIF_Request>", null ); Query newQuery = new Query( sifR.SIF_Query ); Condition cond = newQuery.HasCondition( sqp ); Assert.IsNotNull( cond, "hasCondition" ); Assert.AreEqual( sqp, cond.GetXPath(), "SQP" ); Assert.AreEqual( sqp, cond.GetXPath( newQuery, version ), "Version-Specific SQP" ); return newQuery; }
public void testSQP060() { // TT 217 Presumptive Query Syntax support Query q = new Query( ReportingDTD.STUDENTLOCATOR ); q.AddCondition( "RequestingAgencyId/@Type", ComparisonOperators.EQ, "LEA" ); q.AddCondition( "RequestingAgencyId", ComparisonOperators.EQ, "0001" ); q = SaveToXMLAndReparse( q, SifVersion.LATEST ); Condition c = q.HasCondition( ReportingDTD.REQUESTINGAGENCYID_TYPE ); Assert.IsNotNull( c ); String xPath = c.GetXPath( q, SifVersion.LATEST ); Assert.AreEqual( "RequestingAgencyId/@Type", xPath, "RequestingAgencyID/@Type XPath" ); c = q.HasCondition( ReportingDTD.REQUESTINGAGENCYID ); Assert.IsNotNull( c ); xPath = c.GetXPath( q, SifVersion.LATEST ); Assert.AreEqual( "RequestingAgencyId", xPath, "RequestingAgencyIDe XPath" ); }
public void testSQP050() { Query q = new Query( StudentDTD.STUDENTPERSONAL ); q.AddCondition( "OtherIdList/OtherId[@Type='ZZ']", ComparisonOperators.EQ, "SCHOOL:997" ); Condition c = q.HasCondition( CommonDTD.OTHERID ); Assert.IsNotNull( c ); String xPath = c.GetXPath( q, SifVersion.SIF15r1 ); Assert.AreEqual( xPath, "OtherId[@Type='ZZ']", "SIF 1.5 XPath" ); xPath = c.GetXPath( q, SifVersion.SIF20 ); Assert.AreEqual( "OtherIdList/OtherId[@Type='ZZ']", xPath, "SIF 2.0 XPath" ); }
public void testSQP040() { Query q = new Query( StudentDTD.STUDENTSCHOOLENROLLMENT ); q.AddCondition( StudentDTD.STUDENTSCHOOLENROLLMENT_SCHOOLYEAR, ComparisonOperators.EQ, "2001" ); Condition c = q .HasCondition( StudentDTD.STUDENTSCHOOLENROLLMENT_SCHOOLYEAR ); Assert.IsNotNull( c ); String xPath = c.GetXPath( q, SifVersion.SIF15r1 ); Assert.AreEqual( "SchoolYear", xPath, "SIF 1.5 XPath" ); xPath = c.GetXPath( q, SifVersion.SIF20 ); Assert.AreEqual( "@SchoolYear", xPath, "SIF 2.0 XPath" ); }
public void testQuery010() { Query q = new Query( StudentDTD.STUDENTPERSONAL ); q.AddCondition( "Demographics/Ethnicity", ComparisonOperators.EQ, "W" ); Console.WriteLine( q.ToXml() ); q = SaveToXMLAndReparse( q, SifVersion.SIF15r1 ); Condition c = q.HasCondition( "Demographics/Ethnicity" ); Assert.IsNotNull( c, "Condition didn't resolve" ); }