use of org.codice.ddf.platform.util.SortedServiceList in project ddf by codice.
the class ListConverter method convert.
/**
* Converts (casts) the sourceObject to a SortedServiceList.
*
* @parameter sourceObject object being converted
* @parameter targetType
* @return sourceObject cast to a SortedServiceList
*/
@Override
public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
LOGGER.trace("Converting {}", sourceObject);
SortedServiceList list = ((SortedServiceList) sourceObject);
return list;
}
use of org.codice.ddf.platform.util.SortedServiceList in project ddf by codice.
the class GeoJsonExtensibleTest method testEmptyPropertyTypeWithNonNullTransformers.
@Test
public void testEmptyPropertyTypeWithNonNullTransformers() throws IOException, CatalogTransformerException {
transformer.setInputTransformers(new SortedServiceList());
Metacard metacard = transformer.transform(new ByteArrayInputStream(sampleBasicMetacardNoMetacardType().getBytes()), DEFAULT_ID);
assertThat(metacard.getMetacardType().getName(), is("ddf.metacard"));
assertThat(metacard.getTitle(), is(DEFAULT_TITLE));
}
use of org.codice.ddf.platform.util.SortedServiceList in project ddf by codice.
the class GeoJsonInputTransformerTest method testGuessTransformer.
@Test
public void testGuessTransformer() throws IOException, CatalogTransformerException {
SortedServiceList mockSortedServiceList = mock(SortedServiceList.class);
InputTransformer mockInputTransformer = mock(InputTransformer.class);
when(mockInputTransformer.transform(mock(InputStream.class))).thenThrow(new CatalogTransformerException());
when(mockSortedServiceList.stream()).thenReturn(Stream.of(mockInputTransformer));
transformer.setInputTransformers(mockSortedServiceList);
Metacard metacard = transformer.transform(new ByteArrayInputStream(samplePointJsonText().getBytes()));
ArgumentCaptor<ByteArrayInputStream> inputStreamCaptor = ArgumentCaptor.forClass(ByteArrayInputStream.class);
verify(mockSortedServiceList).stream();
verify(mockInputTransformer).transform(inputStreamCaptor.capture());
assertThat(metacard.getMetacardType().getName(), is("ddf.metacard"));
assertThat(metacard.getTitle(), is(DEFAULT_TITLE));
}
use of org.codice.ddf.platform.util.SortedServiceList in project ddf by codice.
the class GeoJsonExtensibleTest method testNullMetacardTypesWithNonNullTransformers.
@Test
public void testNullMetacardTypesWithNonNullTransformers() throws IOException, CatalogTransformerException {
transformer.setInputTransformers(new SortedServiceList());
// tests the branch conditional for null metacard types in the getMetacard() method
transformer.setMetacardTypes(null);
Metacard metacard1 = transformer.transform(new ByteArrayInputStream(sampleBasicMetacardNoMetacardType().getBytes()), DEFAULT_ID);
assertThat(metacard1.getMetacardType().getName(), is("ddf.metacard"));
assertThat(metacard1.getTitle(), is(DEFAULT_TITLE));
transformer.setMetacardTypes(prepareMetacardTypes());
Metacard metacard2 = transformer.transform(new ByteArrayInputStream(sampleBasicMetacardNoMetacardType().getBytes()), DEFAULT_ID);
// tests that metacards created with null metacard types and empty property types are the same
assertThat(metacard2, is(metacard1));
}
Aggregations