}
@Test
public void testValidationWarnings() throws InvalidDDMSException {
for (String sVersion : getSupportedVersions()) {
DDMSVersion version = DDMSVersion.setCurrentVersion(sVersion);
SubjectCoverage component = getInstance(getValidElement(sVersion), SUCCESS);
if (!"4.1".equals(sVersion)) {
// No warnings
assertEquals(0, component.getValidationWarnings().size());
}
else {
// 4.1 ddms:qualifier element used
assertEquals(1, component.getValidationWarnings().size());
String text = "The ddms:qualifier attribute in this DDMS component";
String locator = "ddms:subjectCoverage/ddms:nonStateActor";
assertWarningEquality(text, locator, component.getValidationWarnings().get(0));
}
// Identical keywords
SubjectCoverage.Builder builder = getBaseBuilder();
builder.getNonStateActors().clear();
builder.getKeywords().add(builder.getKeywords().get(0));
component = getInstance(builder, SUCCESS);
assertEquals(1, component.getValidationWarnings().size());
String text = "1 or more keywords have the same value.";
String locator = version.isAtLeast("4.0.1") ? "ddms:subjectCoverage" : "ddms:subjectCoverage/ddms:Subject";
assertWarningEquality(text, locator, component.getValidationWarnings().get(0));
// Identical categories
builder = getBaseBuilder();
builder.getNonStateActors().clear();
builder.getCategories().add(builder.getCategories().get(0));
component = getInstance(builder, SUCCESS);
assertEquals(1, component.getValidationWarnings().size());
text = "1 or more categories have the same value.";
locator = version.isAtLeast("4.0.1") ? "ddms:subjectCoverage" : "ddms:subjectCoverage/ddms:Subject";
assertWarningEquality(text, locator, component.getValidationWarnings().get(0));
// Identical productionMetrics
if (version.isAtLeast("4.0.1")) {
builder = getBaseBuilder();
builder.getNonStateActors().clear();
builder.getProductionMetrics().add(builder.getProductionMetrics().get(0));
component = getInstance(builder, SUCCESS);
assertEquals(1, component.getValidationWarnings().size());