Search in sources :

Example 11 with WorkspaceMetacardImpl

use of org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl in project ddf by codice.

the class TestWorkspaceServiceImpl method testGetQueryMetacards.

@Test
public void testGetQueryMetacards() {
    Metacard metacard = mock(Metacard.class);
    when(metacard.getMetacardType()).thenReturn(BasicTypes.BASIC_METACARD);
    String xml = "<xml/>";
    when(workspaceTransformer.toMetacardFromXml(xml)).thenReturn(metacard);
    WorkspaceMetacardImpl workspaceMetacard = mock(WorkspaceMetacardImpl.class);
    when(workspaceMetacard.getQueries()).thenReturn(Collections.singletonList(xml));
    List<QueryMetacardImpl> metacards = workspaceService.getQueryMetacards(workspaceMetacard);
    assertThat(metacards, hasSize(1));
}
Also used : Metacard(ddf.catalog.data.Metacard) QueryMetacardImpl(org.codice.ddf.catalog.ui.metacard.workspace.QueryMetacardImpl) WorkspaceMetacardImpl(org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl) Test(org.junit.Test)

Example 12 with WorkspaceMetacardImpl

use of org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl in project ddf by codice.

the class TestWorkspaceServiceImpl method testGetWorkspaceMetacardsWithException.

/**
     * If the catalog framework throws an exception, then getWoekspaceMetacards should return an empty
     * list.
     *
     * @throws UnsupportedQueryException
     * @throws SourceUnavailableException
     * @throws FederationException
     */
@SuppressWarnings("unchecked")
@Test
public void testGetWorkspaceMetacardsWithException() throws UnsupportedQueryException, SourceUnavailableException, FederationException {
    when(catalogFramework.query(any())).thenThrow(UnsupportedQueryException.class);
    Filter filter = mock(Filter.class);
    when(filterService.buildWorkspaceTagFilter()).thenReturn(filter);
    List<WorkspaceMetacardImpl> workspaceMetacards = workspaceService.getWorkspaceMetacards();
    assertThat(workspaceMetacards, hasSize(0));
}
Also used : WorkspaceMetacardFilter(org.codice.ddf.catalog.ui.query.monitor.api.WorkspaceMetacardFilter) Filter(org.opengis.filter.Filter) WorkspaceMetacardImpl(org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl) Test(org.junit.Test)

Example 13 with WorkspaceMetacardImpl

use of org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl in project ddf by codice.

the class TestWorkspaceServiceImpl method testGetWorkspaceMetacardsByWorkspaceIdWithException.

@SuppressWarnings("unchecked")
@Test
public void testGetWorkspaceMetacardsByWorkspaceIdWithException() throws UnsupportedQueryException, SourceUnavailableException, FederationException {
    String id = "123";
    when(catalogFramework.query(any())).thenThrow(UnsupportedQueryException.class);
    Filter workspaceTagFilter = mockWorkspaceTagFilter();
    Filter metacardIdFilter = mock(Filter.class);
    when(filterService.buildMetacardIdFilter(id)).thenReturn(metacardIdFilter);
    And andFilter = mock(And.class);
    when(filterBuilder.allOf(metacardIdFilter, workspaceTagFilter)).thenReturn(andFilter);
    Or orFilter = mock(Or.class);
    when(filterBuilder.anyOf(Collections.singletonList(andFilter))).thenReturn(orFilter);
    List<WorkspaceMetacardImpl> workspaceMetacards = workspaceService.getWorkspaceMetacards(Collections.singleton(id));
    assertThat(workspaceMetacards, hasSize(0));
}
Also used : Or(org.opengis.filter.Or) WorkspaceMetacardFilter(org.codice.ddf.catalog.ui.query.monitor.api.WorkspaceMetacardFilter) Filter(org.opengis.filter.Filter) And(org.opengis.filter.And) WorkspaceMetacardImpl(org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl) Test(org.junit.Test)

Example 14 with WorkspaceMetacardImpl

use of org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl in project ddf by codice.

the class TestAttributeMetacardFormatter method testComplex.

@Test
public void testComplex() {
    String template = "The workspace '%[attribute=title]' (id: %[attribute=id]) contains up to %[hitCount] query hits.";
    String id = "the-id";
    WorkspaceMetacardImpl workspaceMetacard = new WorkspaceMetacardImpl(id);
    workspaceMetacard.setAttribute("title", "the-title");
    AttributeMetacardFormatter attributeMetacardFormatter = new AttributeMetacardFormatter("n/a");
    String result = attributeMetacardFormatter.format(template, workspaceMetacard, 1L);
    assertThat(result, is("The workspace 'the-title' (id: the-id) contains up to %[hitCount] query hits."));
}
Also used : WorkspaceMetacardImpl(org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl) Test(org.junit.Test)

Example 15 with WorkspaceMetacardImpl

use of org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl in project ddf by codice.

the class WorkspacePreIngestPluginTest method testUnsuccessfulIngest.

@Test(expected = StopProcessingException.class)
public void testUnsuccessfulIngest() throws Exception {
    WorkspacePreIngestPlugin wpip = makePlugin(null, null);
    wpip.process(new CreateRequestImpl(new WorkspaceMetacardImpl()));
}
Also used : CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) WorkspaceMetacardImpl(org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl) Test(org.junit.Test)

Aggregations

WorkspaceMetacardImpl (org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl)15 Test (org.junit.Test)15 Filter (org.opengis.filter.Filter)4 UpdateRequest (ddf.catalog.operation.UpdateRequest)3 KeyValueCollectionPermission (ddf.security.permission.KeyValueCollectionPermission)3 KeyValuePermission (ddf.security.permission.KeyValuePermission)3 Permission (org.apache.shiro.authz.Permission)3 WorkspaceMetacardFilter (org.codice.ddf.catalog.ui.query.monitor.api.WorkspaceMetacardFilter)3 And (org.opengis.filter.And)3 Or (org.opengis.filter.Or)3 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)2 PolicyResponse (ddf.catalog.plugin.PolicyResponse)2 QueryMetacardImpl (org.codice.ddf.catalog.ui.metacard.workspace.QueryMetacardImpl)2 CatalogFramework (ddf.catalog.CatalogFramework)1 Attribute (ddf.catalog.data.Attribute)1 Metacard (ddf.catalog.data.Metacard)1 FederationException (ddf.catalog.federation.FederationException)1 FilterBuilder (ddf.catalog.filter.FilterBuilder)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1