Search in sources :

Example 6 with ConditionalIgnore

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", () -> {
        expect("Service to be available: " + MetacardType.class.getName()).within(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);
        executeOpenSearch("xml", "q=*").log().all().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 {
        deleteMetacard(id1);
        deleteMetacard(id2);
        uninstallDefinitionJson(file, () -> {
            DefaultAttributeValueRegistry defaultsRegistry = getServiceManager().getService(DefaultAttributeValueRegistry.class);
            expect("Defaults to be unregistered").within(10, TimeUnit.SECONDS).until(() -> !defaultsRegistry.getDefaultValue(customMetacardTypeName, Metacard.DESCRIPTION).isPresent());
            return null;
        });
    }
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) MetacardType(ddf.catalog.data.MetacardType) DefaultAttributeValueRegistry(ddf.catalog.data.DefaultAttributeValueRegistry) ConditionalIgnore(org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 7 with ConditionalIgnore

use of org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore in project ddf by codice.

the class TestFederation method testAsyncDownloadActionPresentUsingCometDClient.

/**
     * Tests that the async download action's URL is returned in the CometD search results.
     *
     * @throws Exception
     */
@Test
// TODO: DDF-2581
@ConditionalIgnore(condition = SkipUnstableTest.class)
public void testAsyncDownloadActionPresentUsingCometDClient() throws Exception {
    getCatalogBundle().setupCaching(true);
    String src = "ddf.distribution";
    String metacardId = ingestXmlWithProduct(String.format("%s.txt", testName.getMethodName()));
    String responseChannelId = "0193d9e7f9ed4f8f8bd02103143c41d6";
    String responseChannelPath = String.format("/%s", responseChannelId);
    String expectedUrl = String.format("%s?source=%s&metacard=%s", RESOURCE_DOWNLOAD_ENDPOINT_ROOT.getUrl(), src, metacardId);
    String actionTitle = "Copy resource to local site";
    cometDClient = setupCometDClient(Collections.singletonList(responseChannelPath));
    cometDClient.searchByMetacardId(responseChannelId, src, metacardId);
    expect("CometD query response").within(20, SECONDS).until(() -> cometDClient.getMessages(responseChannelPath).size() >= 1);
    Optional<String> searchResult = cometDClient.searchMessages(metacardId);
    assertThat("Async download action not found", searchResult.isPresent(), is(true));
    JsonPath path = JsonPath.from(searchResult.get());
    assertThat(path.getString(String.format(FIND_ACTION_URL_BY_TITLE_PATTERN, actionTitle)), is(expectedUrl));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) JsonPath(com.jayway.restassured.path.json.JsonPath) ConditionalIgnore(org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Aggregations

AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)7 ConditionalIgnore (org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore)7 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)7 Test (org.junit.Test)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 MetacardType (ddf.catalog.data.MetacardType)4 File (java.io.File)3 DefaultAttributeValueRegistry (ddf.catalog.data.DefaultAttributeValueRegistry)2 JsonPath (com.jayway.restassured.path.json.JsonPath)1 AttributeRegistry (ddf.catalog.data.AttributeRegistry)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1