use of org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore in project ddf by codice.
the class TestCatalog method testDefaultValuesUpdate.
@Test
// DDF-2743
@ConditionalIgnore(condition = SkipUnstableTest.class)
public void testDefaultValuesUpdate() throws Exception {
final String customMetacardTypeName = "custom";
File file = ingestDefinitionJsonWithWaitCondition("defaults.json", () -> {
await("Service to be available: " + MetacardType.class.getName()).atMost(30, TimeUnit.SECONDS).until(() -> getServiceManager().getServiceReferences(MetacardType.class, "(name=" + customMetacardTypeName + ")"), not(empty()));
return null;
});
String metacard1Xml = getFileContent("metacard1.xml");
final String id1 = ingest(metacard1Xml, MediaType.APPLICATION_XML);
String metacard2Xml = getFileContent("metacard2.xml");
metacard2Xml = metacard2Xml.replaceFirst("ddf\\.metacard", customMetacardTypeName);
final String id2 = ingest(metacard2Xml, MediaType.APPLICATION_XML);
try {
final String updatedTitle1 = "Metacard-1 (Updated)";
final String updatedTitle2 = "Metacard-2 (Updated)";
metacard1Xml = metacard1Xml.replaceFirst("Metacard-1", updatedTitle1);
metacard2Xml = metacard2Xml.replaceFirst("Metacard-2", updatedTitle2);
verifyMetacardDoesNotContainAttribute(metacard1Xml, Metacard.DESCRIPTION);
verifyMetacardDoesNotContainAttribute(metacard1Xml, Metacard.EXPIRATION);
verifyMetacardDoesNotContainAttribute(metacard2Xml, Metacard.DESCRIPTION);
verifyMetacardDoesNotContainAttribute(metacard2Xml, Metacard.EXPIRATION);
update(id1, metacard1Xml, MediaType.APPLICATION_XML);
update(id2, metacard2Xml, MediaType.APPLICATION_XML);
final String defaultDescription = "Default description";
final String defaultCustomMetacardDescription = "Default custom description";
final String defaultExpiration = getDefaultExpirationAsString();
final String metacard1XPath = format(METACARD_X_PATH, id1);
final String metacard2XPath = format(METACARD_X_PATH, id2);
getOpenSearch("xml", null, null, "q=*").log().ifValidationFails().assertThat().body(hasXPath(metacard1XPath + "/string[@name='title']/value", is(updatedTitle1))).body(hasXPath(metacard1XPath + "/string[@name='description']/value", is(defaultDescription))).body(hasXPath(metacard1XPath + "/dateTime[@name='expiration']/value", is(defaultExpiration))).body(hasXPath(metacard2XPath + "/string[@name='title']/value", is(updatedTitle2))).body(hasXPath(metacard2XPath + "/string[@name='description']/value", is(defaultCustomMetacardDescription))).body(hasXPath(metacard2XPath + "/dateTime[@name='expiration']/value", is(defaultExpiration)));
} finally {
delete(id1);
delete(id2);
uninstallDefinitionJson(file, () -> {
DefaultAttributeValueRegistry defaultsRegistry = getServiceManager().getService(DefaultAttributeValueRegistry.class);
await("Defaults to be unregistered").atMost(10, TimeUnit.SECONDS).until(() -> !defaultsRegistry.getDefaultValue(customMetacardTypeName, Metacard.DESCRIPTION).isPresent());
return null;
});
}
}
use of org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore in project ddf by codice.
the class TestCatalog method testInjectAttributesOnCreate.
@Test
// DDF-2743
@ConditionalIgnore(condition = SkipUnstableTest.class)
public void testInjectAttributesOnCreate() {
final String id = ingestXmlFromResource("/metacard-injections.xml");
final String originalMetacardXml = getFileContent("metacard-injections.xml");
final String basicMetacardTypeName = DEFAULT_METACARD_TYPE_NAME;
final String otherMetacardTypeName = "other.metacard.type";
final String otherMetacardXml = originalMetacardXml.replaceFirst(Pattern.quote(basicMetacardTypeName), otherMetacardTypeName);
final String id2 = ingest(otherMetacardXml, MediaType.APPLICATION_XML);
try {
final String basicMetacardXpath = format(METACARD_X_PATH, id);
final String otherMetacardXpath = format(METACARD_X_PATH, id2);
getOpenSearch("xml", null, null, "q=*").log().ifValidationFails().assertThat().body(hasXPath(basicMetacardXpath + "/type", is(basicMetacardTypeName))).body(hasXPath(basicMetacardXpath + "/int[@name='page-count']/value", is("55"))).body(not(hasXPath(basicMetacardXpath + "/double[@name='temperature']"))).body(hasXPath(otherMetacardXpath + "/type", is(otherMetacardTypeName))).body(hasXPath(otherMetacardXpath + "/int[@name='page-count']/value", is("55"))).body(hasXPath(otherMetacardXpath + "/double[@name='temperature']/value", is("-12.541")));
} finally {
delete(id);
delete(id2);
}
}
Aggregations