Search in sources :

Example 11 with UuidGenerator

use of org.codice.ddf.platform.util.uuidgenerator.UuidGenerator in project ddf by codice.

the class CatalogServiceImplTest method testAddDocumentWithMetadataMetacardId.

@Test
@SuppressWarnings({ "unchecked" })
public void testAddDocumentWithMetadataMetacardId() throws Exception {
    String inputMcardId = "123456789987654321";
    MetacardImpl inputMcard = new MetacardImpl();
    inputMcard.setId(inputMcardId);
    UuidGenerator uuidGenerator = mock(UuidGenerator.class);
    String response = mcardIdTest(inputMcard, uuidGenerator);
    assertThat(response, equalTo(inputMcardId));
    verify(uuidGenerator, never()).generateUuid();
}
Also used : UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 12 with UuidGenerator

use of org.codice.ddf.platform.util.uuidgenerator.UuidGenerator in project ddf by codice.

the class FanoutCatalogFrameworkTest method initFramework.

@Before
public void initFramework() {
    // Mock register the provider in the container
    SourcePollerRunner runner = new SourcePollerRunner();
    SourcePoller poller = new SourcePoller(runner);
    ArrayList<PostIngestPlugin> postIngestPlugins = new ArrayList<PostIngestPlugin>();
    frameworkProperties = new FrameworkProperties();
    frameworkProperties.setSourcePoller(poller);
    frameworkProperties.setFederationStrategy(new MockFederationStrategy());
    frameworkProperties.setPostIngest(postIngestPlugins);
    uuidGenerator = mock(UuidGenerator.class);
    when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
    framework = createCatalogFramework(frameworkProperties);
}
Also used : UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) SourcePollerRunner(ddf.catalog.util.impl.SourcePollerRunner) ArrayList(java.util.ArrayList) SourcePoller(ddf.catalog.util.impl.SourcePoller) PostIngestPlugin(ddf.catalog.plugin.PostIngestPlugin) Before(org.junit.Before)

Example 13 with UuidGenerator

use of org.codice.ddf.platform.util.uuidgenerator.UuidGenerator in project ddf by codice.

the class IdentificationPluginTest method setUp.

@Before
public void setUp() {
    UuidGenerator uuidGenerator = mock(UuidGenerator.class);
    when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
    parser = new XmlParser();
    identificationPlugin = new IdentificationPlugin(uuidGenerator);
    identificationPlugin.setMetacardMarshaller(new MetacardMarshaller(parser));
    identificationPlugin.setRegistryIdPostIngestPlugin(new RegistryIdPostIngestPlugin());
    setParser(parser);
    sampleData = new MetacardImpl();
    sampleData.setId("testNewMetacardId");
    sampleData.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "testNewRegistryId");
    sampleData.setAttribute(Metacard.MODIFIED, new Date().from(Instant.now()));
    Set<String> tags = new HashSet<>();
    tags.add("registry");
    sampleData.setTags(tags);
    System.setProperty(RegistryConstants.REGISTRY_ID_PROPERTY, "systemRegistryId");
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) MetacardMarshaller(org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Date(java.util.Date) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 14 with UuidGenerator

use of org.codice.ddf.platform.util.uuidgenerator.UuidGenerator 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)

Example 15 with UuidGenerator

use of org.codice.ddf.platform.util.uuidgenerator.UuidGenerator in project ddf by codice.

the class ContentProducerTest method testProcess.

@Test
public void testProcess() throws Exception {
    File testFile = testDir.newFile();
    mockEndpoint = mock(ContentEndpoint.class);
    UuidGenerator uuidGenerator = mock(UuidGenerator.class);
    ContentComponent contentComponent = mock(ContentComponent.class);
    when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
    when(mockEndpoint.getComponent()).thenReturn(contentComponent);
    Message mockMessage = mock(Message.class);
    doReturn(ImmutableMap.of(Constants.STORE_REFERENCE_KEY, true)).when(mockMessage).getHeaders();
    mockContentProducerDao = mock(ContentProducerDataAccessObject.class);
    doReturn(testFile).when(mockContentProducerDao).getFileUsingRefKey(true, mockMessage);
    doReturn(null).when(mockContentProducerDao).getEventType(true, mockMessage);
    doReturn("xml").when(mockContentProducerDao).getMimeType(mockEndpoint, testFile);
    contentProducer = new ContentProducer(mockEndpoint);
    contentProducer.contentProducerDataAccessObject = mockContentProducerDao;
    Exchange mockExchange = mock(Exchange.class);
    doReturn(ExchangePattern.InOnly).when(mockExchange).getPattern();
    doReturn(mockMessage).when(mockExchange).getIn();
    contentProducer.process(mockExchange);
    verify(mockContentProducerDao, times(1)).getFileUsingRefKey(true, mockMessage);
    verify(mockContentProducerDao, times(1)).getEventType(true, mockMessage);
    verify(mockContentProducerDao, times(1)).getMimeType(mockEndpoint, testFile);
}
Also used : Exchange(org.apache.camel.Exchange) UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) Message(org.apache.camel.Message) File(java.io.File) Test(org.junit.Test)

Aggregations

UuidGenerator (org.codice.ddf.platform.util.uuidgenerator.UuidGenerator)20 Before (org.junit.Before)11 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)10 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 CatalogFramework (ddf.catalog.CatalogFramework)6 InputTransformer (ddf.catalog.transform.InputTransformer)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ActionRegistry (ddf.action.ActionRegistry)3 Metacard (ddf.catalog.data.Metacard)3 DefaultAttributeValueRegistryImpl (ddf.catalog.data.defaultvalues.DefaultAttributeValueRegistryImpl)3 Historian (ddf.catalog.history.Historian)3 CreateOperations (ddf.catalog.impl.operations.CreateOperations)3 DeleteOperations (ddf.catalog.impl.operations.DeleteOperations)3 MetacardFactory (ddf.catalog.impl.operations.MetacardFactory)3 OperationsCatalogStoreSupport (ddf.catalog.impl.operations.OperationsCatalogStoreSupport)3 QueryResponse (ddf.catalog.operation.QueryResponse)3 PostIngestPlugin (ddf.catalog.plugin.PostIngestPlugin)3