Search in sources :

Example 71 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class SolrProviderTest method testDeletePendingNrtIndex.

@Test
public void testDeletePendingNrtIndex() throws Exception {
    deleteAllIn(provider);
    ConfigurationStore.getInstance().setForceAutoCommit(false);
    try {
        MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
        CreateResponse createResponse = create(metacard);
        DeleteResponse deleteResponse = delete(createResponse.getCreatedMetacards().get(0).getId());
        Metacard deletedMetacard = deleteResponse.getDeletedMetacards().get(0);
        verifyDeletedRecord(metacard, createResponse, deleteResponse, deletedMetacard);
    } finally {
        ConfigurationStore.getInstance().setForceAutoCommit(true);
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) CreateResponse(ddf.catalog.operation.CreateResponse) Test(org.junit.Test)

Example 72 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class SolrProviderTest method testCreatedDates.

@Test
public void testCreatedDates() throws Exception {
    deleteAllIn(provider);
    /* ALL NULL */
    MockMetacard mockMetacard = new MockMetacard(Library.getFlagstaffRecord());
    mockMetacard.setEffectiveDate(null);
    mockMetacard.setExpirationDate(null);
    mockMetacard.setCreatedDate(null);
    mockMetacard.setModifiedDate(null);
    List<Metacard> list = Arrays.asList((Metacard) mockMetacard);
    CreateResponse createResponse = create(list);
    assertEquals(1, createResponse.getCreatedMetacards().size());
    Metacard createdMetacard = createResponse.getCreatedMetacards().get(0);
    assertNotNull(createdMetacard.getId());
    assertEquals(MockMetacard.DEFAULT_TITLE, createdMetacard.getTitle());
    assertEquals(MockMetacard.DEFAULT_LOCATION, createdMetacard.getLocation());
    assertEquals(MockMetacard.DEFAULT_TYPE, createdMetacard.getContentTypeName());
    assertEquals(MockMetacard.DEFAULT_VERSION, createdMetacard.getContentTypeVersion());
    assertNotNull(createdMetacard.getMetadata());
    assertTrue(!createdMetacard.getMetadata().isEmpty());
    // DATES
    assertEquals(mockMetacard.getCreatedDate(), createdMetacard.getCreatedDate());
    assertThat(createdMetacard.getCreatedDate(), nullValue());
    assertEquals(mockMetacard.getModifiedDate(), createdMetacard.getModifiedDate());
    assertThat(createdMetacard.getModifiedDate(), nullValue());
    assertEquals(mockMetacard.getEffectiveDate(), createdMetacard.getEffectiveDate());
    assertThat(createdMetacard.getEffectiveDate(), nullValue());
    assertEquals(mockMetacard.getExpirationDate(), createdMetacard.getExpirationDate());
    assertThat(createdMetacard.getExpirationDate(), nullValue());
    assertTrue(Arrays.equals(mockMetacard.getThumbnail(), createdMetacard.getThumbnail()));
    assertEquals(mockMetacard.getLocation(), createdMetacard.getLocation());
    assertEquals(MASKED_ID, createdMetacard.getSourceId());
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) Test(org.junit.Test)

Example 73 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class FtpRequestHandlerTest method setupIngest.

@SuppressWarnings("unchecked")
private void setupIngest() throws FtpException, SourceUnavailableException, IngestException {
    Subject subject = mock(Subject.class);
    FtpFile ftpFile = mock(FtpFile.class);
    CreateResponse createResponse = mock(CreateResponse.class);
    Metacard metacard = mock(Metacard.class);
    when(metacard.getId()).thenReturn(METACARD_ID);
    when(createResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(metacard));
    when(session.getAttribute(SUBJECT)).thenReturn(subject);
    when(request.getArgument()).thenReturn(FILE_NAME);
    when(session.getFileSystemView().getFile(FILE_NAME)).thenReturn(ftpFile);
    when(ftpFile.isWritable()).thenReturn(true);
    when(ftpFile.getAbsolutePath()).thenReturn(FILE_NAME);
    when(subject.execute(any(Callable.class))).thenAnswer(invocationOnMock -> ((Callable) invocationOnMock.getArguments()[0]).call());
    when(catalogFramework.create(any(CreateStorageRequest.class))).thenReturn(createResponse);
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) FtpFile(org.apache.ftpserver.ftplet.FtpFile) Subject(ddf.security.Subject) Callable(java.util.concurrent.Callable) CreateStorageRequest(ddf.catalog.content.operation.CreateStorageRequest)

Example 74 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project alliance by codice.

the class ParentMetacardStreamCreationPluginTest method setup.

@Before
public void setup() throws SourceUnavailableException, IngestException {
    context = mock(Context.class);
    uri = URI.create("udp://127.0.0.1:10000");
    title = "theTitleString";
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    when(udpStreamProcessor.getStreamUri()).thenReturn(Optional.of(uri));
    when(udpStreamProcessor.getTitle()).thenReturn(Optional.of(title));
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    Security security = mock(Security.class);
    Subject subject = mock(Subject.class);
    when(security.getSystemSubject()).thenReturn(subject);
    catalogFramework = mock(CatalogFramework.class);
    parentMetacardStreamCreationPlugin = new ParentMetacardStreamCreationPlugin(catalogFramework, Collections.singletonList(mock(MetacardType.class)));
    CreateResponse createResponse = mock(CreateResponse.class);
    Metacard createdParentMetacard = mock(Metacard.class);
    context.setParentMetacard(createdParentMetacard);
    when(createResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(createdParentMetacard));
    when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequest(ddf.catalog.operation.CreateRequest) CatalogFramework(ddf.catalog.CatalogFramework) Security(org.codice.ddf.security.common.Security) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Subject(ddf.security.Subject) MetacardType(ddf.catalog.data.MetacardType) Before(org.junit.Before)

Example 75 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project alliance by codice.

the class CatalogRolloverActionTest method setup.

@Before
public void setup() throws SourceUnavailableException, IngestException {
    FilenameGenerator filenameGenerator = mock(FilenameGenerator.class);
    String filenameTemplate = "filenameTemplate";
    StreamProcessor streamProcessor = mock(StreamProcessor.class);
    when(streamProcessor.getMetacardUpdateInitialDelay()).thenReturn(1L);
    catalogFramework = mock(CatalogFramework.class);
    MetacardType metacardType = mock(MetacardType.class);
    tempFile = new File("someTempFile");
    URI uri = URI.create("udp://127.0.0.1:10000");
    String title = "theTitleString";
    childWkt = "POLYGON (( 0.5 0.5, 1.5 0.5, 1.5 1.5, 0.5 1.5, 0.5 0.5 ))";
    when(metacardType.getAttributeDescriptor(AttributeNameConstants.TEMPORAL_START)).thenReturn(mock(AttributeDescriptor.class));
    when(metacardType.getAttributeDescriptor(AttributeNameConstants.TEMPORAL_END)).thenReturn(mock(AttributeDescriptor.class));
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    when(udpStreamProcessor.getSubject()).thenReturn(new SimpleSubject());
    Context context = new Context(udpStreamProcessor);
    when(udpStreamProcessor.getMetacardTypeList()).thenReturn(Collections.singletonList(metacardType));
    when(udpStreamProcessor.getStreamUri()).thenReturn(Optional.of(uri));
    when(udpStreamProcessor.getTitle()).thenReturn(Optional.of(title));
    Security security = mock(Security.class);
    Subject subject = mock(Subject.class);
    when(security.getSystemSubject()).thenReturn(subject);
    GeometryOperator postUnionGeometryOperator = new GeometryOperatorList(Arrays.asList(new SimplifyGeometryFunction(), new NormalizeGeometry()));
    UuidGenerator uuidGenerator = mock(UuidGenerator.class);
    when(uuidGenerator.generateUuid()).thenReturn("anId");
    catalogRolloverAction = new CatalogRolloverAction(filenameGenerator, filenameTemplate, catalogFramework, context, new ListMetacardUpdater(Arrays.asList(new LocationMetacardUpdater(postUnionGeometryOperator, GeometryOperator.IDENTITY), new TemporalStartMetacardUpdater(), new TemporalEndMetacardUpdater(), new ModifiedDateMetacardUpdater(), new FrameCenterMetacardUpdater(postUnionGeometryOperator))), uuidGenerator);
    createdParentMetacard = mock(Metacard.class);
    when(createdParentMetacard.getMetacardType()).thenReturn(metacardType);
    context.setParentMetacard(createdParentMetacard);
    context.getGeometryOperatorContext().setDistanceTolerance(0.0025);
    createdChildMetacard = mock(Metacard.class);
    when(createdChildMetacard.getMetacardType()).thenReturn(metacardType);
    Metacard updatedParentMetacard = mock(Metacard.class);
    when(updatedParentMetacard.getMetacardType()).thenReturn(metacardType);
    Metacard updatedChildMetacard = mock(Metacard.class);
    when(updatedChildMetacard.getMetacardType()).thenReturn(metacardType);
    CreateResponse createResponse = mock(CreateResponse.class);
    CreateResponse storageCreateResponse = mock(CreateResponse.class);
    Update childUpdate = mock(Update.class);
    childUpdateResponse = mock(UpdateResponse.class);
    Update parentUpdate = mock(Update.class);
    parentUpdateResponse = mock(UpdateResponse.class);
    when(createResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(createdParentMetacard));
    when(storageCreateResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(createdChildMetacard));
    when(childUpdate.getNewMetacard()).thenReturn(updatedChildMetacard);
    when(childUpdateResponse.getUpdatedMetacards()).thenReturn(Collections.singletonList(childUpdate));
    when(parentUpdate.getNewMetacard()).thenReturn(updatedParentMetacard);
    when(parentUpdateResponse.getUpdatedMetacards()).thenReturn(Collections.singletonList(parentUpdate));
    when(filenameGenerator.generateFilename(any())).thenReturn("someFileName");
    when(streamProcessor.getStreamUri()).thenReturn(Optional.of(uri));
    when(streamProcessor.getTitle()).thenReturn(Optional.of(title));
    when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
    when(catalogFramework.create(any(CreateStorageRequest.class))).thenReturn(storageCreateResponse);
    when(catalogFramework.update(any(UpdateRequest.class))).thenReturn(childUpdateResponse).thenReturn(parentUpdateResponse);
    when(createdChildMetacard.getLocation()).thenReturn(childWkt);
    when(createdChildMetacard.getAttribute(AttributeNameConstants.TEMPORAL_START)).thenReturn(new AttributeImpl(AttributeNameConstants.TEMPORAL_START, TEMPORAL_START_DATE));
    when(createdChildMetacard.getAttribute(AttributeNameConstants.TEMPORAL_END)).thenReturn(new AttributeImpl(AttributeNameConstants.TEMPORAL_END, TEMPORAL_END_DATE));
}
Also used : UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) ModifiedDateMetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.ModifiedDateMetacardUpdater) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequest(ddf.catalog.operation.CreateRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) TemporalEndMetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.TemporalEndMetacardUpdater) SimpleSubject(org.codice.alliance.video.stream.mpegts.SimpleSubject) Security(org.codice.ddf.security.common.Security) Update(ddf.catalog.operation.Update) URI(java.net.URI) TemporalStartMetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.TemporalStartMetacardUpdater) UpdateResponse(ddf.catalog.operation.UpdateResponse) GeometryOperator(org.codice.alliance.libs.klv.GeometryOperator) NormalizeGeometry(org.codice.alliance.libs.klv.NormalizeGeometry) CatalogFramework(ddf.catalog.CatalogFramework) SimplifyGeometryFunction(org.codice.alliance.libs.klv.SimplifyGeometryFunction) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Context(org.codice.alliance.video.stream.mpegts.Context) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) StreamProcessor(org.codice.alliance.video.stream.mpegts.netty.StreamProcessor) ListMetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.ListMetacardUpdater) FrameCenterMetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.FrameCenterMetacardUpdater) MetacardType(ddf.catalog.data.MetacardType) SimpleSubject(org.codice.alliance.video.stream.mpegts.SimpleSubject) Subject(ddf.security.Subject) LocationMetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.LocationMetacardUpdater) GeometryOperatorList(org.codice.alliance.libs.klv.GeometryOperatorList) Metacard(ddf.catalog.data.Metacard) FilenameGenerator(org.codice.alliance.video.stream.mpegts.filename.FilenameGenerator) File(java.io.File) CreateStorageRequest(ddf.catalog.content.operation.CreateStorageRequest) Before(org.junit.Before)

Aggregations

CreateResponse (ddf.catalog.operation.CreateResponse)111 Test (org.junit.Test)82 Metacard (ddf.catalog.data.Metacard)76 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)44 ArrayList (java.util.ArrayList)42 CreateRequest (ddf.catalog.operation.CreateRequest)36 QueryImpl (ddf.catalog.operation.impl.QueryImpl)29 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)29 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)27 HashMap (java.util.HashMap)25 Serializable (java.io.Serializable)23 List (java.util.List)23 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 DeleteResponse (ddf.catalog.operation.DeleteResponse)22 UpdateResponse (ddf.catalog.operation.UpdateResponse)21 Filter (org.opengis.filter.Filter)21 IngestException (ddf.catalog.source.IngestException)20 SourceResponse (ddf.catalog.operation.SourceResponse)18 QueryRequest (ddf.catalog.operation.QueryRequest)17 MetacardType (ddf.catalog.data.MetacardType)16