Exemple #1
0
        public void CreateReport_Empty(string newLine)
        {
            CompletedExtractJobInfo jobInfo = TestJobInfo();

            var mockJobStore = new Mock <IExtractJobStore>(MockBehavior.Strict);

            mockJobStore.Setup(x => x.GetCompletedJobInfo(It.IsAny <Guid>())).Returns(jobInfo);
            mockJobStore.Setup(x => x.GetCompletedJobRejections(It.IsAny <Guid>())).Returns(new List <ExtractionIdentifierRejectionInfo>());
            mockJobStore.Setup(x => x.GetCompletedJobAnonymisationFailures(It.IsAny <Guid>())).Returns(new List <FileAnonFailureInfo>());
            mockJobStore.Setup(x => x.GetCompletedJobVerificationFailures(It.IsAny <Guid>())).Returns(new List <FileVerificationFailureInfo>());

            TestJobReporter reporter;

            using (reporter = new TestJobReporter(mockJobStore.Object, ReportFormat.Combined, newLine))
            {
                reporter.CreateReport(Guid.Empty);
            }

            Assert.True(reporter.Disposed);

            ReportEqualityHelpers.AssertReportsAreEqual(
                jobInfo,
                _dateTimeProvider,
                verificationFailuresExpected: null,
                blockedFilesExpected: null,
                anonFailuresExpected: null,
                isIdentifiableExtraction: false,
                isJoinedReport: false,
                newLine,
                reporter.Report
                );
        }
Exemple #2
0
        public void CreateReport_IdentifiableExtraction()
        {
            CompletedExtractJobInfo jobInfo = TestJobInfo(isIdentifiableExtraction: true);

            var missingFiles = new List <string>
            {
                "missing.dcm",
            };

            var mockJobStore = new Mock <IExtractJobStore>(MockBehavior.Strict);

            mockJobStore.Setup(x => x.GetCompletedJobInfo(It.IsAny <Guid>())).Returns(jobInfo);
            mockJobStore.Setup(x => x.GetCompletedJobMissingFileList(It.IsAny <Guid>())).Returns(missingFiles);

            TestJobReporter reporter;

            using (reporter = new TestJobReporter(mockJobStore.Object, ReportFormat.Combined, LinuxNewLine))
            {
                reporter.CreateReport(Guid.Empty);
            }

            Assert.True(reporter.Disposed);

            var missingFilesExpected = new List <Tuple <string, string> >
            {
                new Tuple <string, string>("missing.dcm", null),
            };

            ReportEqualityHelpers.AssertReportsAreEqual(
                jobInfo,
                _dateTimeProvider,
                verificationFailuresExpected: null,
                blockedFilesExpected: null,
                missingFilesExpected,
                isIdentifiableExtraction: true,
                isJoinedReport: false,
                LinuxNewLine,
                reporter.Report
                );
        }
Exemple #3
0
        public void CreateReport_WithPixelData()
        {
            CompletedExtractJobInfo jobInfo = TestJobInfo();

            // NOTE(rkm 2020-08-25) Tests that the "Z" tag is ordered before PixelData, and that PixelData items are ordered by decreasing length not by occurrence
            const string report = @"
[
     {
        'Parts': [],
        'Resource': 'unused',
        'ResourcePrimaryKey': 'unused',
        'ProblemField': 'PixelData',
        'ProblemValue': 'aaaaaaaaaaa'
    },
    {
        'Parts': [],
        'Resource': 'unused',
        'ResourcePrimaryKey': 'unused',
        'ProblemField': 'PixelData',
        'ProblemValue': 'a'
    },
    {
        'Parts': [],
        'Resource': 'unused',
        'ResourcePrimaryKey': 'unused',
        'ProblemField': 'PixelData',
        'ProblemValue': 'a'
    },
    {
        'Parts': [],
        'Resource': 'unused',
        'ResourcePrimaryKey': 'unused',
        'ProblemField': 'Z',
        'ProblemValue': 'bar'
    },
]";

            var verificationFailures = new List <FileVerificationFailureInfo>
            {
                new FileVerificationFailureInfo(anonFilePath: "foo1.dcm", report),
            };

            var mockJobStore = new Mock <IExtractJobStore>(MockBehavior.Strict);

            mockJobStore.Setup(x => x.GetCompletedJobInfo(It.IsAny <Guid>())).Returns(jobInfo);
            mockJobStore.Setup(x => x.GetCompletedJobRejections(It.IsAny <Guid>())).Returns(new List <ExtractionIdentifierRejectionInfo>());
            mockJobStore.Setup(x => x.GetCompletedJobAnonymisationFailures(It.IsAny <Guid>())).Returns(new List <FileAnonFailureInfo>());
            mockJobStore.Setup(x => x.GetCompletedJobVerificationFailures(It.IsAny <Guid>())).Returns(verificationFailures);

            TestJobReporter reporter;

            using (reporter = new TestJobReporter(mockJobStore.Object, ReportFormat.Combined, LinuxNewLine))
            {
                reporter.CreateReport(Guid.Empty);
            }

            Assert.True(reporter.Disposed);

            var verificationFailuresExpected = new Dictionary <string, Dictionary <string, List <string> > >
            {
                {
                    "Z", new Dictionary <string, List <string> >
                    {
                        {
                            "bar",
                            new List <string>
                            {
                                "foo1.dcm"
                            }
                        }
                    }
                },
                {
                    "PixelData", new Dictionary <string, List <string> >
                    {
                        {
                            "aaaaaaaaaaa",
                            new List <string>
                            {
                                "foo1.dcm"
                            }
                        },
                        {
                            "a",
                            new List <string>
                            {
                                "foo1.dcm",
                                "foo1.dcm"
                            }
                        },
                    }
                },
            };

            ReportEqualityHelpers.AssertReportsAreEqual(
                jobInfo,
                _dateTimeProvider,
                verificationFailuresExpected,
                blockedFilesExpected: null,
                anonFailuresExpected: null,
                isIdentifiableExtraction: false,
                isJoinedReport: false,
                LinuxNewLine,
                reporter.Report
                );
        }
Exemple #4
0
        public void CreateReport_AggregateData(string newLine)
        {
            CompletedExtractJobInfo jobInfo = TestJobInfo();

            var verificationFailures = new List <FileVerificationFailureInfo>
            {
                new FileVerificationFailureInfo(anonFilePath: "ccc/ddd/foo1.dcm", failureData: @"
                    [
                        {
                             'Parts': [],
                            'Resource': 'unused',
                            'ResourcePrimaryKey': 'unused',
                            'ProblemField': 'SomeOtherTag',
                            'ProblemValue': 'BAZ'
                        }
                    ]"
                                                ),
                new FileVerificationFailureInfo(anonFilePath: "ccc/ddd/foo2.dcm", failureData: @"
                    [
                        {
                             'Parts': [],
                            'Resource': 'unused',
                            'ResourcePrimaryKey': 'unused',
                            'ProblemField': 'SomeOtherTag',
                            'ProblemValue': 'BAZ'
                        }
                    ]"
                                                ),
                new FileVerificationFailureInfo(anonFilePath: "aaa/bbb/foo1.dcm", failureData: @"
                    [
                        {
                            'Parts': [],
                            'Resource': 'unused',
                            'ResourcePrimaryKey': 'unused',
                            'ProblemField': 'ScanOptions',
                            'ProblemValue': 'FOO'
                        }
                    ]"
                                                ),
                new FileVerificationFailureInfo(anonFilePath: "aaa/bbb/foo2.dcm", failureData: @"
                    [
                        {
                            'Parts': [],
                            'Resource': 'unused',
                            'ResourcePrimaryKey': 'unused',
                            'ProblemField': 'ScanOptions',
                            'ProblemValue': 'FOO'
                        }
                    ]"
                                                ),
                new FileVerificationFailureInfo(anonFilePath: "aaa/bbb/foo2.dcm", failureData: @"
                    [
                         {
                            'Parts': [],
                            'Resource': 'unused',
                            'ResourcePrimaryKey': 'unused',
                            'ProblemField': 'ScanOptions',
                            'ProblemValue': 'BAR'
                        }
                    ]"
                                                ),
            };

            var mockJobStore = new Mock <IExtractJobStore>(MockBehavior.Strict);

            mockJobStore.Setup(x => x.GetCompletedJobInfo(It.IsAny <Guid>())).Returns(jobInfo);
            mockJobStore.Setup(x => x.GetCompletedJobRejections(It.IsAny <Guid>())).Returns(new List <ExtractionIdentifierRejectionInfo>());
            mockJobStore.Setup(x => x.GetCompletedJobAnonymisationFailures(It.IsAny <Guid>())).Returns(new List <FileAnonFailureInfo>());
            mockJobStore.Setup(x => x.GetCompletedJobVerificationFailures(It.IsAny <Guid>()))
            .Returns(verificationFailures);

            TestJobReporter reporter;

            using (reporter = new TestJobReporter(mockJobStore.Object, ReportFormat.Combined, newLine))
            {
                reporter.CreateReport(Guid.Empty);
            }

            Assert.True(reporter.Disposed);

            var verificationFailuresExpected = new Dictionary <string, Dictionary <string, List <string> > >
            {
                {
                    "ScanOptions", new Dictionary <string, List <string> >
                    {
                        {
                            "FOO",
                            new List <string>
                            {
                                "aaa/bbb/foo1.dcm",
                                "aaa/bbb/foo2.dcm",
                            }
                        },
                        {
                            "BAR",
                            new List <string>
                            {
                                "aaa/bbb/foo2.dcm",
                            }
                        },
                    }
                },
                {
                    "SomeOtherTag", new Dictionary <string, List <string> >
                    {
                        {
                            "BAZ",
                            new List <string>
                            {
                                "ccc/ddd/foo1.dcm",
                                "ccc/ddd/foo2.dcm",
                            }
                        },
                    }
                },
            };

            ReportEqualityHelpers.AssertReportsAreEqual(
                jobInfo,
                _dateTimeProvider,
                verificationFailuresExpected,
                blockedFilesExpected: null,
                anonFailuresExpected: null,
                isIdentifiableExtraction: false,
                isJoinedReport: false,
                newLine,
                reporter.Report
                );
        }
Exemple #5
0
        public void CreateReport_BasicData(string newLine)
        {
            CompletedExtractJobInfo jobInfo = TestJobInfo();

            var rejections = new List <ExtractionIdentifierRejectionInfo>
            {
                new ExtractionIdentifierRejectionInfo(
                    keyValue: "1.2.3.4",
                    new Dictionary <string, int>
                {
                    { "image is in the deny list for extraction", 123 },
                    { "foo bar", 456 },
                }),
            };

            var anonFailures = new List <FileAnonFailureInfo>
            {
                new FileAnonFailureInfo(expectedAnonFile: "foo1.dcm", reason: "image was corrupt"),
            };

            const string report = @"
[
    {
        'Parts': [],
        'Resource': '/foo1.dcm',
        'ResourcePrimaryKey': '1.2.3.4',
        'ProblemField': 'ScanOptions',
        'ProblemValue': 'FOO'
    }
]";

            var verificationFailures = new List <FileVerificationFailureInfo>
            {
                new FileVerificationFailureInfo(anonFilePath: "foo1.dcm", report),
            };

            var mockJobStore = new Mock <IExtractJobStore>(MockBehavior.Strict);

            mockJobStore.Setup(x => x.GetCompletedJobInfo(It.IsAny <Guid>())).Returns(jobInfo);
            mockJobStore.Setup(x => x.GetCompletedJobRejections(It.IsAny <Guid>())).Returns(rejections);
            mockJobStore.Setup(x => x.GetCompletedJobAnonymisationFailures(It.IsAny <Guid>())).Returns(anonFailures);
            mockJobStore.Setup(x => x.GetCompletedJobVerificationFailures(It.IsAny <Guid>())).Returns(verificationFailures);

            TestJobReporter reporter;

            using (reporter = new TestJobReporter(mockJobStore.Object, ReportFormat.Combined, newLine))
            {
                reporter.CreateReport(Guid.Empty);
            }

            var verificationFailuresExpected = new Dictionary <string, Dictionary <string, List <string> > >
            {
                {
                    "ScanOptions", new Dictionary <string, List <string> >
                    {
                        {
                            "FOO",
                            new List <string>
                            {
                                "foo1.dcm"
                            }
                        }
                    }
                },
            };
            var blockedFilesExpected = new Dictionary <string, List <Tuple <int, string> > >
            {
                {
                    "1.2.3.4",
                    new List <Tuple <int, string> >
                    {
                        new Tuple <int, string>(123, "image is in the deny list for extraction"),
                        new Tuple <int, string>(456, "foo bar"),
                    }
                },
            };
            var anonFailuresExpected = new List <Tuple <string, string> >
            {
                new Tuple <string, string>("foo1.dcm", "image was corrupt"),
            };

            Assert.True(reporter.Disposed);

            ReportEqualityHelpers.AssertReportsAreEqual(
                jobInfo,
                _dateTimeProvider,
                verificationFailuresExpected,
                blockedFilesExpected,
                anonFailuresExpected,
                isIdentifiableExtraction: false,
                isJoinedReport: false,
                newLine,
                reporter.Report
                );
        }