use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class CqlResultTest method distanceCheck.
private void distanceCheck(Double input, Double output) {
MetacardImpl metacard = new MetacardImpl(BasicTypes.BASIC_METACARD);
ResultImpl result = new ResultImpl(metacard);
result.setDistanceInMeters(input);
ActionRegistry actionRegistry = mock(ActionRegistry.class);
when(actionRegistry.list(any())).thenReturn(Collections.emptyList());
QueryRequest request = new QueryRequestImpl(new QueryImpl(filterBuilder.attribute("test").equalTo().text("value")));
CqlResult cqlResult = new CqlResult(result, null, request, false, filterAdapter, actionRegistry);
assertThat(cqlResult.getDistance(), is(output));
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class TestMetacardResourceSizePlugin method testWhenNoCachedResourceFound.
@Test
public void testWhenNoCachedResourceFound() throws Exception {
ResourceCacheInterface cache = mock(ResourceCacheInterface.class);
when(cache.getValid(anyString(), (Metacard) anyObject())).thenReturn(null);
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. Long
Attribute resourceSizeAttr = resultMetacard.getAttribute(Metacard.RESOURCE_SIZE);
assertThat((String) resourceSizeAttr.getValue(), equalTo("N/A"));
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class MigrationFileWriterTest method testWriteMetacardsWriteObjectFails.
@Test(expected = IOException.class)
public void testWriteMetacardsWriteObjectFails() throws Exception {
whenNew(ObjectOutputStream.class).withAnyArguments().thenReturn(mockObjectOutputStream);
doThrow(IOException.class).when(mockObjectOutputStream).writeObject(anyObject());
List<Result> results = new ArrayList<>();
results.add(new ResultImpl(new MetacardImpl()));
mockFile = testFolder.newFile("mockFile");
fileWriter.writeMetacards(mockFile, results);
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class SolrMetacardClientImpl method createResult.
private ResultImpl createResult(SolrDocument doc) throws MetacardCreationException {
ResultImpl result = new ResultImpl(createMetacard(doc));
if (doc.get(RELEVANCE_SORT_FIELD) != null) {
result.setRelevanceScore(((Float) (doc.get(RELEVANCE_SORT_FIELD))).doubleValue());
}
if (doc.get(DISTANCE_SORT_FIELD) != null) {
Object distance = doc.getFieldValue(DISTANCE_SORT_FIELD);
if (distance != null) {
LOGGER.debug("Distance returned from Solr [{}]", distance);
double convertedDistance = new Distance(Double.valueOf(distance.toString()), Distance.LinearUnit.KILOMETER).getAs(Distance.LinearUnit.METER);
result.setDistanceInMeters(convertedDistance);
}
}
return result;
}
use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.
the class Jpeg2000ThumbnailConverterTest method testEmptyThumbnail.
@Test
public void testEmptyThumbnail() throws Exception {
Metacard metacard = new MetacardImpl();
metacard.setAttribute(new AttributeImpl(Metacard.THUMBNAIL, new byte[0]));
List<Result> resultList = new ArrayList<>();
resultList.add(new ResultImpl(metacard));
QueryResponseImpl queryResponse = new QueryResponseImpl(null, resultList, 1);
jpeg2000ThumbnailConverter.process(queryResponse);
}
Aggregations