use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class CatalogComponentTest method getSimpleMetacard.
protected Metacard getSimpleMetacard() {
MetacardImpl generatedMetacard = new MetacardImpl();
generatedMetacard.setMetadata(getSample());
generatedMetacard.setId(SAMPLE_ID);
return generatedMetacard;
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class ContentProducerDataAccessObjectTest method testCreateContentItem.
@Test
public void testCreateContentItem() throws Exception {
File testFile = temporaryFolder.newFile("testCreateContentItem.txt");
//make sample list of metacard and set of keys
List<MetacardImpl> metacardList = ImmutableList.of(new MetacardImpl());
Set<String> keys = ImmutableSet.of(String.valueOf(testFile.getAbsolutePath().hashCode()));
//mock out responses for create, delete, update
CreateResponse mockCreateResponse = mock(CreateResponse.class);
doReturn(metacardList).when(mockCreateResponse).getCreatedMetacards();
DeleteResponse mockDeleteResponse = mock(DeleteResponse.class);
doReturn(metacardList).when(mockDeleteResponse).getDeletedMetacards();
UpdateResponse mockUpdateResponse = mock(UpdateResponse.class);
doReturn(metacardList).when(mockUpdateResponse).getUpdatedMetacards();
//setup mockFileSystemPersistenceProvider
FileSystemPersistenceProvider mockFileSystemPersistenceProvider = mock(FileSystemPersistenceProvider.class);
doReturn(keys).when(mockFileSystemPersistenceProvider).loadAllKeys();
doReturn("sample").when(mockFileSystemPersistenceProvider).loadFromPersistence(any(String.class));
//setup mockCatalogFramework
CatalogFramework mockCatalogFramework = mock(CatalogFramework.class);
doReturn(mockCreateResponse).when(mockCatalogFramework).create(any(CreateStorageRequest.class));
doReturn(mockDeleteResponse).when(mockCatalogFramework).delete(any(DeleteRequest.class));
//setup mockComponent
ContentComponent mockComponent = mock(ContentComponent.class);
doReturn(mockCatalogFramework).when(mockComponent).getCatalogFramework();
//setup mockEndpoint
ContentEndpoint mockEndpoint = mock(ContentEndpoint.class);
doReturn(mockComponent).when(mockEndpoint).getComponent();
WatchEvent.Kind<Path> kind;
String mimeType = "txt";
Map<String, Object> headers = new HashedMap();
Map<String, Serializable> attributeOverrides = new HashMap<>();
attributeOverrides.put("example", ImmutableList.of("something", "something1"));
attributeOverrides.put("example2", ImmutableList.of("something2"));
headers.put(Constants.ATTRIBUTE_OVERRIDES_KEY, attributeOverrides);
kind = StandardWatchEventKinds.ENTRY_CREATE;
contentProducerDataAccessObject.createContentItem(mockFileSystemPersistenceProvider, mockEndpoint, testFile, kind, mimeType, headers);
kind = StandardWatchEventKinds.ENTRY_DELETE;
contentProducerDataAccessObject.createContentItem(mockFileSystemPersistenceProvider, mockEndpoint, testFile, kind, mimeType, headers);
kind = StandardWatchEventKinds.ENTRY_MODIFY;
contentProducerDataAccessObject.createContentItem(mockFileSystemPersistenceProvider, mockEndpoint, testFile, kind, mimeType, headers);
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class DumpCommandTest method testNormalOperationWithContent.
/**
* Check for normal operation when there is local content associated with metacards
*
* @throws Exception
*/
@Test
public void testNormalOperationWithContent() throws Exception {
// given
List<Result> resultList = getResultList("id1", "id2");
MetacardImpl metacard1 = new MetacardImpl(resultList.get(0).getMetacard());
MetacardImpl metacard2 = new MetacardImpl(resultList.get(1).getMetacard());
metacard1.setResourceURI(new URI("content:" + metacard1.getId()));
metacard2.setResourceURI(new URI("content:" + metacard2.getId() + "#preview"));
DumpCommand dumpCommand = new DumpCommand();
dumpCommand.catalogFramework = givenCatalogFramework(resultList);
dumpCommand.filterBuilder = new GeotoolsFilterBuilder();
File outputDirectory = testFolder.newFolder("somedirectory");
String outputDirectoryPath = outputDirectory.getAbsolutePath();
dumpCommand.dirPath = outputDirectoryPath;
dumpCommand.transformerId = CatalogCommands.SERIALIZED_OBJECT_ID;
// when
dumpCommand.executeWithSubject();
// then
assertThat(consoleOutput.getOutput(), containsString(" 2 file(s) dumped in "));
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class RemoveCommandTest method getMetacardList.
private java.util.List<Metacard> getMetacardList(int amount) {
List<Metacard> metacards = new ArrayList<>();
for (int i = 0; i < amount; i++) {
String id = UUID.randomUUID().toString();
MetacardImpl metacard = new MetacardImpl();
metacard.setId(id);
metacards.add(metacard);
}
return metacards;
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class ValidateCommand method createMetacardsFromFiles.
private List<Metacard> createMetacardsFromFiles() throws IOException {
Collection<File> files = getFiles();
List<Metacard> metacards = new ArrayList<>();
for (File file : files) {
Metacard metacard = new MetacardImpl();
String metadata = IOUtils.toString(file.toURI());
metacard.setAttribute(new AttributeImpl(Metacard.METADATA, metadata));
metacard.setAttribute(new AttributeImpl(Metacard.TITLE, file.getName()));
metacards.add(metacard);
}
return metacards;
}
Aggregations