// Test an attribute with constant value (as opposed to an xpath)
// ***************************************************************************************
List<Attribute> attPurposeList = getAttributesForProperty(f, "purpose");
assertEquals(1, attPurposeList.size());
Attribute at = attPurposeList.get(0);
assertEquals("CONSTANT", getValueForAttribute(at));
assertFalse(at.getUserData().containsKey(Attributes.class));
// ***************************************************************************************
// Test an attribute with null value (ie unset) but User data is an xpath
// ***************************************************************************************
List<Attribute> attGUTypeList = getAttributesForProperty(f, "rank");
assertEquals(1, attGUTypeList.size());
at = attGUTypeList.get(0);
assertEquals("", getValueForAttribute(at));
assertEquals(1, ((Map<Object, Object>) at.getUserData().get(Attributes.class)).size());
assertEquals("urn:cgi:classifier:GSV:LithostratigraphicUnitRank:formation",
getUserDataForAttribute(at, new NameImpl("http://www.w3.org/1999/xlink", "href")));
// ***************************************************************************************
// Test that a nested complex type is created correctly
// ***************************************************************************************
List<Attribute> attObMethList = getAttributesForProperty(f, "observationMethod");
assertEquals(1, attObMethList.size());
at = attObMethList.get(0);
assertEquals(null, at.getIdentifier());
assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "observationMethod"), at.getName());
assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "CGI_TermValuePropertyType"), at.getDescriptor()
.getType().getName());
ComplexAttribute ob = getNestedComplexValueForAttribute(at);
assertEquals(null, ob.getIdentifier());
assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "CGI_TermValue"), ob.getName());
assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "CGI_TermValueType"), ob.getDescriptor().getType()
.getName());
ComplexAttribute ob2 = getNestedComplexValueForAttribute(ob);
assertEquals(null, ob2.getIdentifier());
assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "value"), ob2.getName());
assertEquals(new NameImpl(CGINS, "CodeWithAuthorityType"), ob2
.getDescriptor().getType().getName());
assertEquals("CONSTANT", getValueForAttribute(ob2));
assertEquals("gsv:NameSpace", getUserDataForAttribute(ob2, new NameImpl("codeSpace")));
}
Feature feature = results.get(0);
// ***************************************************************************************
// Test an attribute that occurs once, set via xpaths. Also has no userData
// ***************************************************************************************
List<Attribute> attDescList = getAttributesForProperty(feature, "description");
assertEquals(1, attDescList.size());
Attribute at = attDescList.get(0);
assertEquals("Test description 1", getValueForAttribute(at));
assertFalse(at.getUserData().containsKey(Attributes.class));
// ***************************************************************************************
// Test an attribute with two values. Also has userData, set with constants instead of
// xpaths
// ***************************************************************************************
List<Attribute> attNameList = getAttributesForProperty(feature, "name");
assertEquals(2, attNameList.size());
// First one has a value and a single attribute--codeSpace
at = attNameList.get(0);
assertEquals("Unit Name1248396531312 UC1248396531312 description name",
getValueForAttribute(at));
assertEquals(1, ((Map) at.getUserData().get(Attributes.class)).size());
assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
// Second one has a value and a single attribute--codeSpace
at = attNameList.get(1);
assertEquals("urn:cgi:feature:GSV:1679161021439131319", getValueForAttribute(at));
assertTrue(at.getUserData() != null && ((Map) at.getUserData().get(Attributes.class)).size() == 1);
assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
// second feature
feature = results.get(1);
attDescList = getAttributesForProperty(feature, "description");
assertEquals(1, attDescList.size());
at = attDescList.get(0);
assertEquals("Test description 1", getValueForAttribute(at));
assertFalse(at.getUserData().containsKey(Attributes.class));
attNameList = getAttributesForProperty(feature, "name");
assertEquals(2, attNameList.size());
at = attNameList.get(0);
assertEquals("Unit Name1233811724109 UC1233811724109 description name",
getValueForAttribute(at));
assertEquals(1, ((Map) at.getUserData().get(Attributes.class)).size());
assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
at = attNameList.get(1);
assertEquals("urn:cgi:feature:GSV:1679161041155866313", getValueForAttribute(at));
assertTrue(at.getUserData() != null && ((Map) at.getUserData().get(Attributes.class)).size() == 1);
assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
// third feature
feature = results.get(2);
attDescList = getAttributesForProperty(feature, "description");
assertEquals(1, attDescList.size());
at = attDescList.get(0);
assertEquals("Test description 2", getValueForAttribute(at));
assertFalse(at.getUserData().containsKey(Attributes.class));
attNameList = getAttributesForProperty(feature, "name");
assertEquals(2, attNameList.size());
at = attNameList.get(0);
assertEquals("Unit Name1248396020281 UC1248396020281 description name 2",
getValueForAttribute(at));
assertEquals(1, ((Map) at.getUserData().get(Attributes.class)).size());
assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
at = attNameList.get(1);
assertEquals("urn:cgi:feature:GSV:1679161021439938381", getValueForAttribute(at));
assertTrue(at.getUserData() != null && ((Map) at.getUserData().get(Attributes.class)).size() == 1);
assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
}