use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestXmlResponseQueueTransformer method testNoIdNoSourceId.
@Test
public void testNoIdNoSourceId() throws CatalogTransformerException, IOException, XpathException, SAXException {
// given
transformer.setThreshold(2);
SourceResponse response = givenSourceResponse(null, null);
// when
BinaryContent binaryContent = transformer.transform(response, null);
// then
assertThat(binaryContent.getMimeType(), is(mimeType));
byte[] bytes = binaryContent.getByteArray();
String output = new String(bytes);
print(output, verboseDebug);
assertXpathNotExists("/mc:metacards/mc:metacard/mc:source", output);
assertXpathNotExists("/mc:metacards/mc:metacard/@gml:id", output);
verifyDefaults("1", output);
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestZipCompression method testCompressionWithDerivedContentInvalidURI.
@Test
public void testCompressionWithDerivedContentInvalidURI() throws Exception {
String invalidUri = "^";
SourceResponse sourceResponse = createSourceResponseWithURISchemes(CONTENT_SCHEME, invalidUri);
BinaryContent binaryContent = zipCompression.transform(sourceResponse, filePathArgument);
assertThat(binaryContent, notNullValue());
assertZipContents(binaryContent, METACARD_RESULT_LIST_WITH_CONTENT);
}
use of ddf.catalog.data.BinaryContent in project alliance by codice.
the class OverviewSupplierTest method setUp.
@Before
public void setUp() throws CatalogTransformerException {
final BinaryContent overviewContent = mock(BinaryContent.class);
doAnswer(invocationOnMock -> getClass().getClassLoader().getResourceAsStream("flower.jpg")).when(overviewContent).getInputStream();
final MetacardTransformer resourceMetacardTransformer = mock(MetacardTransformer.class);
doReturn(overviewContent).when(resourceMetacardTransformer).transform(argThat(isMetacardWithDerivedOverviewResource()), eq(Collections.singletonMap(ContentItem.QUALIFIER_KEYWORD, "overview")));
doThrow(CatalogTransformerException.class).when(resourceMetacardTransformer).transform(argThat(not(isMetacardWithDerivedOverviewResource())), eq(Collections.singletonMap(ContentItem.QUALIFIER_KEYWORD, "overview")));
supplier = new OverviewSupplier(resourceMetacardTransformer);
}
use of ddf.catalog.data.BinaryContent in project alliance by codice.
the class OverviewSupplier method apply.
@Override
public Optional<BufferedImage> apply(Metacard metacard, Map<String, Serializable> arguments) {
try {
final Map<String, Serializable> resourceTransformerArguments = new HashMap<>();
resourceTransformerArguments.put(ContentItem.QUALIFIER_KEYWORD, "overview");
final BinaryContent overviewContent = resourceMetacardTransformer.transform(metacard, resourceTransformerArguments);
try (final InputStream inputStream = overviewContent.getInputStream()) {
return Optional.ofNullable(ImageIO.read(inputStream));
}
} catch (IOException | CatalogTransformerException e) {
LOGGER.debug("Could not get the overview image.", e);
}
return Optional.empty();
}
use of ddf.catalog.data.BinaryContent in project alliance by codice.
the class CatalogOutputAdapterTest method testGrayscale.
@Test
public void testGrayscale() throws MimeTypeParseException, NitfFormatException, IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
int originalWidth = 200;
int originalHeight = 100;
int chipWidth = 160;
int chipHeight = 80;
NitfSegmentsFlow nitfSegmentsFlow = createGenericNitfSegmentFlow(originalWidth, originalHeight);
BufferedImage chipImage = new BufferedImage(chipWidth, chipHeight, BufferedImage.TYPE_BYTE_GRAY);
BinaryContent binaryContent = catalogOutputAdapter.getNitfBinaryContent(chipImage, nitfSegmentsFlow, 0, 0);
NitfSegmentsFlow chipNitfSegmentFlow = new NitfParserInputFlowImpl().inputStream(binaryContent.getInputStream()).allData();
chipNitfSegmentFlow.forEachImageSegment(imageSegment1 -> {
assertThat(imageSegment1.getPixelValueType(), is(PixelValueType.INTEGER));
assertThat(imageSegment1.getImageRepresentation(), is(ImageRepresentation.MONOCHROME));
assertThat(imageSegment1.getActualBitsPerPixelPerBand(), is(8));
assertThat(imageSegment1.getNumberOfBitsPerPixelPerBand(), is(8));
assertThat(imageSegment1.getImageBand(1).getImageRepresentation(), is("M"));
});
}
Aggregations