Search in sources :

Example 6 with MetacardImpl

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;
}
Also used : MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 7 with MetacardImpl

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);
}
Also used : Path(java.nio.file.Path) Serializable(java.io.Serializable) HashMap(java.util.HashMap) CreateResponse(ddf.catalog.operation.CreateResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) UpdateResponse(ddf.catalog.operation.UpdateResponse) DeleteResponse(ddf.catalog.operation.DeleteResponse) CatalogFramework(ddf.catalog.CatalogFramework) WatchEvent(java.nio.file.WatchEvent) HashedMap(org.apache.commons.collections.map.HashedMap) GenericFile(org.apache.camel.component.file.GenericFile) File(java.io.File) DeleteRequest(ddf.catalog.operation.DeleteRequest) CreateStorageRequest(ddf.catalog.content.operation.CreateStorageRequest) Test(org.junit.Test)

Example 8 with MetacardImpl

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 "));
}
Also used : GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) URI(java.net.URI) File(java.io.File) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 9 with MetacardImpl

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;
}
Also used : Metacard(ddf.catalog.data.Metacard) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 10 with MetacardImpl

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;
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList) File(java.io.File) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Aggregations

MetacardImpl (ddf.catalog.data.impl.MetacardImpl)384 Test (org.junit.Test)247 Metacard (ddf.catalog.data.Metacard)144 ArrayList (java.util.ArrayList)102 Result (ddf.catalog.data.Result)62 HashMap (java.util.HashMap)59 Date (java.util.Date)52 ResultImpl (ddf.catalog.data.impl.ResultImpl)51 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)49 URI (java.net.URI)38 Matchers.anyString (org.mockito.Matchers.anyString)38 QueryRequest (ddf.catalog.operation.QueryRequest)36 QueryResponse (ddf.catalog.operation.QueryResponse)35 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)35 Serializable (java.io.Serializable)33 HashSet (java.util.HashSet)31 QueryImpl (ddf.catalog.operation.impl.QueryImpl)29 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)28 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)27 List (java.util.List)27