use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class RemoveAllCommandTest method getResultList.
private java.util.List<Result> getResultList(int amount) {
java.util.List<Result> results = new ArrayList<>();
for (int i = 0; i < amount; i++) {
String id = UUID.randomUUID().toString();
MetacardImpl metacard = new MetacardImpl();
metacard.setId(id);
Result result = new ResultImpl(metacard);
results.add(result);
}
return results;
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class ReplicateCommandTest method getResultList.
private List<Result> getResultList(int size) {
return Stream.generate(() -> {
MetacardImpl metacard = new MetacardImpl();
metacard.setId(UUID.randomUUID().toString());
return new ResultImpl(metacard);
}).limit(size).collect(Collectors.toList());
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class ValidateCommandTest method setupNonEmptyCatalog.
private void setupNonEmptyCatalog() throws Exception {
QueryResponse mockResponse = mock(QueryResponseImpl.class);
ArrayList<Result> results = new ArrayList<>();
ResultImpl fakeResult = new ResultImpl();
MetacardImpl fakeMetacard = new MetacardImpl();
fakeMetacard.setTitle("fakeMetacard");
fakeResult.setMetacard(fakeMetacard);
results.add(fakeResult);
doReturn(results).when(mockResponse).getResults();
doReturn(mockResponse).when(mockCatalog).query(anyObject());
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class MigrationFileWriterTest method loadList.
private List<Result> loadList() {
final List<Result> results = new ArrayList<>();
for (int i = 0; i < RESULT_COUNT; i++) {
MetacardImpl metacard = new MetacardImpl();
metacard.setId("id" + String.valueOf(i));
results.add(new ResultImpl(metacard));
}
return results;
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class TestMetacardResourceSizePlugin method testMetacardResourceSizePopulatedButNoProduct.
/**
* Verifies case where product has been cached previously but has since
* been deleted from the product-cache directory, so there is still an
* entry in the cache map but no cache file on disk.
*
* @throws Exception
*/
@Test
public void testMetacardResourceSizePopulatedButNoProduct() throws Exception {
ResourceCacheInterface cache = mock(ResourceCacheInterface.class);
ReliableResource cachedResource = mock(ReliableResource.class);
when(cachedResource.getSize()).thenReturn(999L);
when(cachedResource.hasProduct()).thenReturn(false);
when(cache.getValid(anyString(), (Metacard) anyObject())).thenReturn(cachedResource);
MetacardImpl metacard = new MetacardImpl();
metacard.setId("abc123");
metacard.setSourceId("ddf-1");
metacard.setResourceSize("N/A");
Result result = new ResultImpl(metacard);
List<Result> results = new ArrayList<Result>();
results.add(result);
QueryResponse input = mock(QueryResponse.class);
when(input.getResults()).thenReturn(results);
MetacardResourceSizePlugin plugin = new MetacardResourceSizePlugin(cache);
QueryResponse queryResponse = plugin.process(input);
assertThat(queryResponse.getResults().size(), is(1));
Metacard resultMetacard = queryResponse.getResults().get(0).getMetacard();
assertThat(metacard, is(notNullValue()));
// Since using Metacard vs. MetacardImpl have to get resource-size as an
// Attribute vs. String
Attribute resourceSizeAttr = resultMetacard.getAttribute(Metacard.RESOURCE_SIZE);
assertThat((String) resourceSizeAttr.getValue(), equalTo("N/A"));
}
Aggregations