Beispiel #1
0
        public void TestPersistMessageToStoreImpl_ExtractFileCollectionInfoMessage_NoIdentifiers()
        {
            Guid jobId = Guid.NewGuid();
            var  testExtractFileCollectionInfoMessage = new ExtractFileCollectionInfoMessage
            {
                ExtractionJobIdentifier = jobId,
                ProjectNumber           = "1234-5678",
                RejectionReasons        = new Dictionary <string, int>
                {
                    { "ImageType is not ORIGINAL", 1 },
                },
                JobSubmittedAt                = DateTime.UtcNow,
                ExtractionDirectory           = "1234-5678/testExtract",
                ExtractFileMessagesDispatched = new JsonCompatibleDictionary <MessageHeader, string>(), // No files were extractable for this key
                KeyValue = "series-1",
            };
            var header = new MessageHeader
            {
                MessageGuid = Guid.NewGuid(),
                OriginalPublishTimestamp = MessageHeader.UnixTimeNow(),
                Parents = new[] { Guid.NewGuid(), },
                ProducerExecutableName = "MongoExtractStoreTests",
                ProducerProcessID      = 1234,
            };

            var client = new TestMongoClient();
            var store  = new MongoExtractJobStore(client, ExtractionDatabaseName, _dateTimeProvider);

            Assert.DoesNotThrow(() => store.PersistMessageToStore(testExtractFileCollectionInfoMessage, header));
        }
Beispiel #2
0
        public void TestPersistMessageToStoreImpl_ExtractionRequestInfoMessage()
        {
            Guid guid = Guid.NewGuid();
            var  testExtractionRequestInfoMessage = new ExtractionRequestInfoMessage
            {
                ExtractionJobIdentifier = guid,
                ProjectNumber           = "1234-5678",
                ExtractionDirectory     = "1234-5678/testExtract",
                JobSubmittedAt          = _dateTimeProvider.UtcNow(),
                KeyTag                   = "StudyInstanceUID",
                KeyValueCount            = 1,
                ExtractionModality       = "CT",
                IsIdentifiableExtraction = true,
                IsNoFilterExtraction     = true,
            };
            var testHeader = new MessageHeader
            {
                MessageGuid = Guid.NewGuid(),
                OriginalPublishTimestamp = MessageHeader.UnixTime(_dateTimeProvider.UtcNow()),
                Parents = new[] { Guid.NewGuid(), },
                ProducerExecutableName = "MongoExtractStoreTests",
                ProducerProcessID      = 1234,
            };

            var client = new TestMongoClient();
            var store  = new MongoExtractJobStore(client, ExtractionDatabaseName, _dateTimeProvider);

            store.PersistMessageToStore(testExtractionRequestInfoMessage, testHeader);

            Dictionary <Guid, MongoExtractJobDoc> docs = client.ExtractionDatabase.InProgressCollection.Documents;

            Assert.AreEqual(docs.Count, 1);
            MongoExtractJobDoc extractJob = docs.Values.ToList()[0];

            var expected = new MongoExtractJobDoc(
                guid,
                MongoExtractionMessageHeaderDoc.FromMessageHeader(guid, testHeader, _dateTimeProvider),
                "1234-5678",
                ExtractJobStatus.WaitingForCollectionInfo,
                "1234-5678/testExtract",
                _dateTimeProvider.UtcNow(),
                "StudyInstanceUID",
                1,
                "CT",
                isIdentifiableExtraction: true,
                isNoFilterExtraction: true,
                null);

            Assert.AreEqual(expected, extractJob);
        }
Beispiel #3
0
        public void TestPersistMessageToStoreImpl_IsIdentifiableMessage()
        {
            var client = new TestMongoClient();
            var store  = new MongoExtractJobStore(client, ExtractionDatabaseName, _dateTimeProvider);

            Guid jobId = Guid.NewGuid();
            var  testIsIdentifiableMessage = new ExtractedFileVerificationMessage
            {
                OutputFilePath          = "anon.dcm",
                JobSubmittedAt          = _dateTimeProvider.UtcNow(),
                ProjectNumber           = "1234",
                ExtractionJobIdentifier = jobId,
                ExtractionDirectory     = "1234/test",
                DicomFilePath           = "original.dcm",
                IsIdentifiable          = false,
                Report = "[]", // NOTE(rkm 2020-03-10) An "empty" report from IsIdentifiable
            };
            var header = new MessageHeader();

            store.PersistMessageToStore(testIsIdentifiableMessage, header);

            Dictionary <Guid, MongoFileStatusDoc> docs = client.ExtractionDatabase.StatusCollections[$"statuses_{jobId}"].Documents;

            Assert.AreEqual(docs.Count, 1);
            MongoFileStatusDoc statusDoc = docs.Values.ToList()[0];

            var expected = new MongoFileStatusDoc(
                MongoExtractionMessageHeaderDoc.FromMessageHeader(jobId, header, _dateTimeProvider),
                "original.dcm",
                "anon.dcm",
                true,
                false,
                ExtractedFileStatus.Anonymised,
                "[]");

            Assert.True(statusDoc.Equals(expected));
        }
Beispiel #4
0
        public void TestPersistMessageToStoreImpl_ExtractFileStatusMessage()
        {
            var client = new TestMongoClient();
            var store  = new MongoExtractJobStore(client, ExtractionDatabaseName, _dateTimeProvider);

            Guid jobId = Guid.NewGuid();
            var  testExtractFileStatusMessage = new ExtractedFileStatusMessage
            {
                OutputFilePath          = "anon.dcm",
                JobSubmittedAt          = _dateTimeProvider.UtcNow(),
                Status                  = ExtractedFileStatus.ErrorWontRetry,
                ProjectNumber           = "1234",
                ExtractionJobIdentifier = jobId,
                ExtractionDirectory     = "1234/test",
                StatusMessage           = "Could not anonymise",
                DicomFilePath           = "original.dcm",
            };
            var header = new MessageHeader();

            store.PersistMessageToStore(testExtractFileStatusMessage, header);

            Dictionary <Guid, MongoFileStatusDoc> docs = client.ExtractionDatabase.StatusCollections[$"statuses_{jobId}"].Documents;

            Assert.AreEqual(docs.Count, 1);
            MongoFileStatusDoc statusDoc = docs.Values.ToList()[0];

            var expected = new MongoFileStatusDoc(
                MongoExtractionMessageHeaderDoc.FromMessageHeader(jobId, header, _dateTimeProvider),
                "original.dcm",
                "anon.dcm",
                false,
                true,
                ExtractedFileStatus.ErrorWontRetry,
                "Could not anonymise");

            Assert.True(statusDoc.Equals(expected));
        }
Beispiel #5
0
        public void TestPersistMessageToStoreImpl_ExtractFileCollectionInfoMessage()
        {
            Guid jobId   = Guid.NewGuid();
            var  header1 = new MessageHeader();
            var  header2 = new MessageHeader();
            var  testExtractFileCollectionInfoMessage = new ExtractFileCollectionInfoMessage
            {
                ExtractionJobIdentifier = jobId,
                ProjectNumber           = "1234-5678",
                RejectionReasons        = new Dictionary <string, int>
                {
                    { "reject1", 1 },
                    { "reject2", 2 },
                },
                JobSubmittedAt                = DateTime.UtcNow,
                ExtractionDirectory           = "1234-5678/testExtract",
                ExtractFileMessagesDispatched = new JsonCompatibleDictionary <MessageHeader, string>
                {
                    { header1, "file1" },
                    { header2, "file2" }
                },
                KeyValue = "series-1",
            };
            var header = new MessageHeader
            {
                MessageGuid = Guid.NewGuid(),
                OriginalPublishTimestamp = MessageHeader.UnixTimeNow(),
                Parents = new[] { Guid.NewGuid(), },
                ProducerExecutableName = "MongoExtractStoreTests",
                ProducerProcessID      = 1234,
            };

            var client = new TestMongoClient();
            var store  = new MongoExtractJobStore(client, ExtractionDatabaseName, _dateTimeProvider);

            store.PersistMessageToStore(testExtractFileCollectionInfoMessage, header);

            Dictionary <Guid, MongoExpectedFilesDoc> docs = client.ExtractionDatabase.ExpectedFilesCollections[$"expectedFiles_{jobId}"].Documents;

            Assert.AreEqual(docs.Count, 1);
            MongoExpectedFilesDoc extractJob = docs.Values.ToList()[0];

            var expected = new MongoExpectedFilesDoc(
                MongoExtractionMessageHeaderDoc.FromMessageHeader(jobId, header, _dateTimeProvider),
                "series-1",
                new HashSet <MongoExpectedFileInfoDoc>
            {
                new MongoExpectedFileInfoDoc(header1.MessageGuid, "file1"),
                new MongoExpectedFileInfoDoc(header2.MessageGuid, "file2"),
            },
                new MongoRejectedKeyInfoDoc(
                    MongoExtractionMessageHeaderDoc.FromMessageHeader(jobId, header, _dateTimeProvider),
                    new Dictionary <string, int>
            {
                { "reject1", 1 },
                { "reject2", 2 },
            })
                );

            Assert.True(extractJob.Equals(expected));
        }