Search in sources :

Example 56 with ResultImpl

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;
}
Also used : ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result)

Example 57 with ResultImpl

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());
}
Also used : ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 58 with ResultImpl

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());
}
Also used : QueryResponse(ddf.catalog.operation.QueryResponse) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result)

Example 59 with ResultImpl

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;
}
Also used : ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result)

Example 60 with ResultImpl

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"));
}
Also used : Metacard(ddf.catalog.data.Metacard) Attribute(ddf.catalog.data.Attribute) QueryResponse(ddf.catalog.operation.QueryResponse) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) ResourceCacheInterface(ddf.catalog.cache.ResourceCacheInterface) ReliableResource(ddf.catalog.resource.data.ReliableResource) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Aggregations

ResultImpl (ddf.catalog.data.impl.ResultImpl)91 Result (ddf.catalog.data.Result)59 Test (org.junit.Test)56 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)47 Metacard (ddf.catalog.data.Metacard)46 ArrayList (java.util.ArrayList)35 SourceResponse (ddf.catalog.operation.SourceResponse)30 QueryRequest (ddf.catalog.operation.QueryRequest)28 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)20 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)18 QueryResponse (ddf.catalog.operation.QueryResponse)15 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)15 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)12 BinaryContent (ddf.catalog.data.BinaryContent)10 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)10 QueryImpl (ddf.catalog.operation.impl.QueryImpl)9 Query (ddf.catalog.operation.Query)7 PolicyResponse (ddf.catalog.plugin.PolicyResponse)7 File (java.io.File)7 Before (org.junit.Before)7