}
@Test
public void testValidationWarnings() throws InvalidDDMSException {
for (String sVersion : getSupportedVersions()) {
DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
createComponents();
boolean is41 = "4.1".equals(version.getVersion());
Resource component = getInstance(getValidElement(sVersion), SUCCESS);
if (!is41) {
// No warnings
assertEquals(0, component.getValidationWarnings().size());
}
else {
// 4.1 ism:Notice used
assertEquals(1, component.getValidationWarnings().size());
String text = "The ism:externalNotice attribute in this DDMS component";
String locator = "ddms:resource";
assertWarningEquality(text, locator, component.getValidationWarnings().get(0));
}
int countIndex = is41 ? 1 : 0;
// Nested warnings
Resource.Builder builder = getBaseBuilder();
builder.getFormat().getExtent().setQualifier("test");
builder.getFormat().getExtent().setValue(null);
component = getInstance(builder, SUCCESS);
assertEquals(countIndex + 1, component.getValidationWarnings().size());
String resourceName = Resource.getName(version);
String text = "A qualifier has been set without an accompanying value attribute.";
String locator = (version.isAtLeast("4.0.1")) ? "ddms:" + resourceName + "/ddms:format/ddms:extent"
: "ddms:" + resourceName + "/ddms:format/ddms:Media/ddms:extent";
assertWarningEquality(text, locator, component.getValidationWarnings().get(countIndex));
if (is41) {
text = "The ism:externalNotice attribute";
locator = "ddms:resource";