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));
}
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));
}
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));
}
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."));
}
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()));
}
Aggregations