Search in sources :

Example 1 with SortedServiceList

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;
}
Also used : SortedServiceList(org.codice.ddf.platform.util.SortedServiceList)

Example 2 with SortedServiceList

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) SortedServiceList(org.codice.ddf.platform.util.SortedServiceList) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 3 with SortedServiceList

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) SortedServiceList(org.codice.ddf.platform.util.SortedServiceList) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) InputTransformer(ddf.catalog.transform.InputTransformer) Test(org.junit.Test)

Example 4 with SortedServiceList

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) SortedServiceList(org.codice.ddf.platform.util.SortedServiceList) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Aggregations

SortedServiceList (org.codice.ddf.platform.util.SortedServiceList)4 Metacard (ddf.catalog.data.Metacard)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Test (org.junit.Test)3 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1 InputTransformer (ddf.catalog.transform.InputTransformer)1 InputStream (java.io.InputStream)1