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);
}
}
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());
}
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);
}
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);
}
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));
}
Aggregations