use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestCswRecordConverter method testMarshalEmptyInput.
@Test
public void testMarshalEmptyInput() throws CatalogTransformerException {
Metacard expectedMetacard = getTestMetacard();
BinaryContent bc = converter.transform(expectedMetacard, new HashMap<>());
assertThat(bc, notNullValue());
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestPlugin method setup.
@Before
public void setup() {
// given
plugin = new RestReplicatorPlugin(ENDPOINT_ADDRESS);
transformer = mock(MetacardTransformer.class);
BinaryContent bc = mock(BinaryContent.class);
byte[] bytes = { 86 };
try {
when(bc.getByteArray()).thenReturn(bytes);
when(transformer.transform(isA(Metacard.class), isA(Map.class))).thenReturn(bc);
} catch (Exception e) {
Assert.fail(e.getLocalizedMessage());
}
plugin.setTransformer(transformer);
metacard = getMockMetacard();
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class MetacardBackupPlugin method processRequest.
private void processRequest(ProcessRequest<? extends ProcessResourceItem> processRequest) throws PluginExecutionException {
if (CollectionUtils.isEmpty(storageBackupPlugins)) {
throw new PluginExecutionException("Unable to backup ingested metacard; no metacard backup storage provider configured.");
}
if (metacardTransformer == null) {
throw new PluginExecutionException("Unable to backup ingested metacard; no Metacard Transformer found.");
}
List<? extends ProcessResourceItem> processResourceItems = processRequest.getProcessItems();
for (ProcessResourceItem processResourceItem : processResourceItems) {
Metacard metacard = processResourceItem.getMetacard();
if (shouldBackupMetacard(metacard)) {
try {
LOGGER.trace("Backing up metacard : {}", metacard.getId());
BinaryContent binaryContent = metacardTransformer.transform(metacard, Collections.emptyMap());
backupData(binaryContent, metacard.getId());
} catch (CatalogTransformerException e) {
LOGGER.debug("Unable to transform metacard with id {}.", metacard.getId(), e);
throw new PluginExecutionException(String.format("Unable to transform metacard with id %s.", metacard.getId()));
}
}
}
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class MetacardBackupPluginTest method testGetContentBytesNoContentBytes.
@Test(expected = PluginExecutionException.class)
public void testGetContentBytesNoContentBytes() throws Exception {
BinaryContent binaryContent = mock(BinaryContent.class);
when(binaryContent.getByteArray()).thenReturn(null);
metacardBackupPlugin.getContentBytes(binaryContent, "metacard");
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class MetacardBackupPluginTest method testCreateRequestWithNullContentInputStream.
@Test(expected = PluginExecutionException.class)
public void testCreateRequestWithNullContentInputStream() throws Exception {
BinaryContent binaryContent = mock(BinaryContent.class);
when(binaryContent.getInputStream()).thenReturn(null);
when(metacardTransformer.transform(any(Metacard.class), anyMap())).thenReturn(binaryContent);
metacardBackupPlugin.processCreate(createRequest);
}
Aggregations