478 lines
19 KiB
C#
478 lines
19 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
using Moq;
|
|
using Newtonsoft.Json;
|
|
using LCU.API.Internal.DocumentIngestor.Services.AttributeDeterminingServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.DocumentProcessorServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.MicroApiServices;
|
|
using LCU.Library.DocumentType.Enums;
|
|
using LCU.Library.DocumentType.Models.Requests.Attributes;
|
|
using LCU.Library.DocumentType.Models.Requests.PrimaryOwner;
|
|
using LCU.Library.DocumentType.Models.Requests.Generic;
|
|
using LCU.Library.Internal.DocumentIngestorModels.Entities;
|
|
using LCU.Library.Internal.DocumentIngestorModels.Models;
|
|
using LCU.Library.Internal.DocumentIngestorModels.Models.IndexFileDocuments;
|
|
using LCU.Library.Internal.LCUServiceFactory.Configurations;
|
|
|
|
namespace LCU.API.Internal.DocumentIngestorTests.Services.DocumentProcessorServices;
|
|
|
|
public class OsgTaxStatementProcessingServiceTest
|
|
{
|
|
private OsgTaxStatementProcessingService _osgTaxStatementProcessingService;
|
|
private Mock<IPrimaryOwnerDeterminingService> _mockPrimaryOwnerDeterminingService;
|
|
private Mock<IFileOperationsApiService> _mockFileOperationsApiService;
|
|
private Mock<IDocumentTypeUploaderApiService> _mockDocumentTypeUploaderApiService;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_mockPrimaryOwnerDeterminingService = new Mock<IPrimaryOwnerDeterminingService>();
|
|
_mockFileOperationsApiService = new Mock<IFileOperationsApiService>();
|
|
_mockDocumentTypeUploaderApiService = new Mock<IDocumentTypeUploaderApiService>();
|
|
var serviceFactoryConfiguration = new ServicesFactoryConfiguration
|
|
{
|
|
ServiceFactoryRegistrations = new List<ServiceFactoryRegistration>
|
|
{
|
|
new()
|
|
{
|
|
ServiceInterfaceName = "IIndexParserService",
|
|
ServiceRegistrations = new List<ServiceRegistration>
|
|
{
|
|
new()
|
|
{
|
|
ServiceName = "IndexParserService",
|
|
ServiceId = "8"
|
|
},
|
|
new()
|
|
{
|
|
ServiceName = "IndexParserService",
|
|
ServiceId = "1"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
_osgTaxStatementProcessingService = new OsgTaxStatementProcessingService(_mockPrimaryOwnerDeterminingService.Object,
|
|
_mockFileOperationsApiService.Object,
|
|
_mockDocumentTypeUploaderApiService.Object,
|
|
serviceFactoryConfiguration);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_ProcessingRequest_Null_ProcessResult_Failure()
|
|
{
|
|
ProcessingRequest request = null;
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsFalse(result.Success);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(), It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Never);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()),
|
|
Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(
|
|
x => x.UploadGenericDocument(It.IsAny<GenericDocumentRequest>(), It.IsAny<ProcessingRequest>(), It.IsAny<ProcessResult>()), Times.Never);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_Null_ProcessResult_Failure()
|
|
{
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = null
|
|
};
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.IsFalse(result.EntityIsUnknown);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(), It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Never);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()),
|
|
Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(
|
|
x => x.UploadGenericDocument(It.IsAny<GenericDocumentRequest>(), It.IsAny<ProcessingRequest>(), It.IsAny<ProcessResult>()), Times.Never);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_OneValidationFailures_Failure()
|
|
{
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "0",
|
|
NoticeName = "test",
|
|
RecipientName = "test",
|
|
PdfName = "test",
|
|
SSN = "1"
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument)
|
|
};
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.IsNull(result.EntityIsUnknown);
|
|
Assert.AreEqual(1, result.MessageStack.Count);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(), It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Never);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()),
|
|
Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(
|
|
x => x.UploadGenericDocument(It.IsAny<GenericDocumentRequest>(), It.IsAny<ProcessingRequest>(), It.IsAny<ProcessResult>()), Times.Never);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_FiveValidationFailures_Failure()
|
|
{
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "0",
|
|
NoticeName = "",
|
|
RecipientName = "",
|
|
PdfName = "",
|
|
SSN = ""
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument)
|
|
};
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.IsNull(result.EntityIsUnknown);
|
|
Assert.AreEqual(5, result.MessageStack.Count);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(), It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Never);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()),
|
|
Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(
|
|
x => x.UploadGenericDocument(It.IsAny<GenericDocumentRequest>(), It.IsAny<ProcessingRequest>(), It.IsAny<ProcessResult>()), Times.Never);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_NumberIsNull_Failure()
|
|
{
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "1",
|
|
NoticeName = "1099-INT",
|
|
RecipientName = "test",
|
|
PdfName = "test",
|
|
SSN = "11",
|
|
CreationDate = DateTime.Now.Date.ToString("MMddyyyy")
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument)
|
|
};
|
|
|
|
var primaryOwnerAttribute =
|
|
ErrorCaptureResult<PrimaryOwnerAttribute>.CreateErrorPayload("Error from unit test", null);
|
|
_mockPrimaryOwnerDeterminingService.Setup(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>())).ReturnsAsync(primaryOwnerAttribute);
|
|
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.IsNull(result.EntityIsUnknown);
|
|
Assert.AreEqual(1, result.MessageStack.Count);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(), It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Once);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()),
|
|
Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(
|
|
x => x.UploadGenericDocument(It.IsAny<GenericDocumentRequest>(), It.IsAny<ProcessingRequest>(), It.IsAny<ProcessResult>()), Times.Never);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_NumberNotNull_Upload_Success()
|
|
{
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "1",
|
|
NoticeName = "1099-INT",
|
|
RecipientName = "test",
|
|
PdfName = "test",
|
|
SSN = "11",
|
|
CreationDate = DateTime.Now.Date.ToString("MMddyyyy")
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument),
|
|
IngestorRequest = new IngestorRequest
|
|
{
|
|
RootPath = "\\Tester\\"
|
|
},
|
|
DocumentFileName = "test.pdf"
|
|
};
|
|
|
|
var attribute = new PrimaryOwnerAttribute
|
|
{
|
|
PersonNumber = "2"
|
|
};
|
|
var primaryOwnerAttribute = ErrorCaptureResult<PrimaryOwnerAttribute>.CreateSuccessPayload(attribute);
|
|
_mockPrimaryOwnerDeterminingService.Setup(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>())).ReturnsAsync(primaryOwnerAttribute);
|
|
var content = new byte[1024];
|
|
_mockFileOperationsApiService.Setup(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()))
|
|
.ReturnsAsync(content);
|
|
_mockDocumentTypeUploaderApiService.Setup(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()));
|
|
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsTrue(result.Success);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Once);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
|
_mockDocumentTypeUploaderApiService.Verify(x =>
|
|
x.UploadPrimaryOwnerDocument(It.Is<PrimaryOwnerDocumentRequest>(request =>
|
|
request.PrimaryOwnerDocumentMetadata.Source == SourceTypes.OSG &&
|
|
request.PrimaryOwnerDocumentMetadata.DataSource == DataSourceTypes.DNA),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_GenericDocument_NumberNotNull_Upload_Success()
|
|
{
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "1",
|
|
NoticeName = "1099-MISC",
|
|
RecipientName = "test",
|
|
PdfName = "test",
|
|
SSN = "11",
|
|
CreationDate = DateTime.Now.Date.ToString("MMddyyyy")
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument),
|
|
IngestorRequest = new IngestorRequest
|
|
{
|
|
RootPath = "\\Tester\\"
|
|
},
|
|
DocumentFileName = "test.pdf"
|
|
};
|
|
|
|
var attribute = new GenericDocumentAttribute
|
|
{
|
|
EntityName = "test"
|
|
};
|
|
var genericAttribute = ErrorCaptureResult<GenericDocumentAttribute>.CreateSuccessPayload(attribute);
|
|
var content = new byte[1024];
|
|
_mockFileOperationsApiService.Setup(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()))
|
|
.ReturnsAsync(content);
|
|
|
|
var documentTypeArchiveDeleteInfo = new DocumentTypeArchiveDeleteInfo
|
|
{
|
|
DocumentTypeName = "OneThousandNinetyNineMiscelanneous",
|
|
ArchiveDays = 2000,
|
|
DeleteDays = 4000
|
|
};
|
|
_mockDocumentTypeUploaderApiService.Setup(x =>
|
|
x.UploadGenericDocument(It.IsAny<GenericDocumentRequest>(), It.IsAny<ProcessingRequest>(), It.IsAny<ProcessResult>()));
|
|
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsTrue(result.Success);
|
|
Assert.IsNull(result.EntityIsUnknown);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()),
|
|
Times.Once);
|
|
_mockDocumentTypeUploaderApiService.Verify(
|
|
x => x.UploadGenericDocument(It.Is<GenericDocumentRequest>(request =>
|
|
request.GenericDocumentMetadata.Source == SourceTypes.OSG &&
|
|
request.GenericDocumentMetadata.DataSource == DataSourceTypes.DNA),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_NumberNotNull_GetContentBytesThrowException_Failure()
|
|
{
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "1",
|
|
NoticeName = "1099-INT",
|
|
RecipientName = "test",
|
|
PdfName = "test",
|
|
SSN = "11",
|
|
CreationDate = DateTime.Now.Date.ToString("MMddyyyy")
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument),
|
|
IngestorRequest = new IngestorRequest
|
|
{
|
|
RootPath = "\\Tester\\"
|
|
},
|
|
DocumentFileName = "test.pdf"
|
|
};
|
|
|
|
var attribute = new PrimaryOwnerAttribute
|
|
{
|
|
PersonNumber = "2"
|
|
};
|
|
var primaryOwnerAttribute = ErrorCaptureResult<PrimaryOwnerAttribute>.CreateSuccessPayload(attribute);
|
|
|
|
_mockPrimaryOwnerDeterminingService.Setup(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>())).ReturnsAsync(primaryOwnerAttribute);
|
|
_mockFileOperationsApiService.Setup(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()))
|
|
.ThrowsAsync(new Exception("Error"));
|
|
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.IsFalse(result.EntityIsUnknown);
|
|
Assert.AreEqual(1, result.MessageStack.Count);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Once);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()),
|
|
Times.Once);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Never);
|
|
_mockDocumentTypeUploaderApiService.Verify(
|
|
x => x.UploadGenericDocument(It.IsAny<GenericDocumentRequest>(), It.IsAny<ProcessingRequest>(), It.IsAny<ProcessResult>()), Times.Never);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_NumberNotNull_UploadDocumentThrowException_Failure()
|
|
{
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "1",
|
|
NoticeName = "1099-INT",
|
|
RecipientName = "test",
|
|
PdfName = "test",
|
|
SSN = "11",
|
|
CreationDate = DateTime.Now.Date.ToString("MMddyyyy")
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument),
|
|
IngestorRequest = new IngestorRequest
|
|
{
|
|
RootPath = "\\Tester\\"
|
|
},
|
|
DocumentFileName = "test.pdf"
|
|
};
|
|
|
|
var attribute = new PrimaryOwnerAttribute
|
|
{
|
|
PersonNumber = "2"
|
|
};
|
|
var primaryOwnerAttribute = ErrorCaptureResult<PrimaryOwnerAttribute>.CreateSuccessPayload(attribute);
|
|
|
|
_mockPrimaryOwnerDeterminingService.Setup(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>())).ReturnsAsync(primaryOwnerAttribute);
|
|
var content = new byte[1024];
|
|
_mockFileOperationsApiService.Setup(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()))
|
|
.ReturnsAsync(content);
|
|
_mockDocumentTypeUploaderApiService.Setup(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()))
|
|
.ThrowsAsync(new Exception("Error"));
|
|
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.IsFalse(result.EntityIsUnknown);
|
|
Assert.AreEqual(1, result.MessageStack.Count);
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Once);
|
|
_mockFileOperationsApiService.Verify(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ProcessRequest_OsgTaxStatementDocument_GetCreatedDateFromDocumentType_Success()
|
|
{
|
|
var createdDate = DateTime.Now.Date;
|
|
var osgTaxStatementDocument = new OsgTaxStatement
|
|
{
|
|
AccountNumber = "1",
|
|
NoticeName = "1099-INT",
|
|
RecipientName = "test",
|
|
CreationDate = DateTime.Now.Date.ToString("MMddyyyy"),
|
|
PdfName = "test",
|
|
SSN = "11"
|
|
};
|
|
|
|
var request = new ProcessingRequest
|
|
{
|
|
DocumentValuePayload = JsonConvert.SerializeObject(osgTaxStatementDocument),
|
|
IngestorRequest = new IngestorRequest
|
|
{
|
|
RootPath = "\\Tester\\"
|
|
},
|
|
DocumentFileName = "test.pdf"
|
|
};
|
|
|
|
var attribute = new PrimaryOwnerAttribute
|
|
{
|
|
PersonNumber = "2"
|
|
};
|
|
var primaryOwnerAttribute = ErrorCaptureResult<PrimaryOwnerAttribute>.CreateSuccessPayload(attribute);
|
|
_mockPrimaryOwnerDeterminingService.Setup(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(), It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>())).ReturnsAsync(primaryOwnerAttribute);
|
|
var content = new byte[1024];
|
|
_mockFileOperationsApiService.Setup(x => x.GetContentBytes(It.IsAny<string>(), It.IsAny<string>()))
|
|
.ReturnsAsync(content);
|
|
|
|
var builtRequest = await _osgTaxStatementProcessingService.BuildUploadRequest(request, osgTaxStatementDocument, attribute, DateTime.Now.Date);
|
|
Assert.AreEqual(createdDate, builtRequest.PrimaryOwnerDocumentMetadata.CreatedDate);
|
|
|
|
_mockDocumentTypeUploaderApiService.Setup(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()));
|
|
|
|
var result = await _osgTaxStatementProcessingService.ProcessRequest(request);
|
|
Assert.IsTrue(result.Success);
|
|
Assert.IsNull(result.EntityIsUnknown);
|
|
|
|
_mockPrimaryOwnerDeterminingService.Verify(x => x.DeterminePrimaryOwnerAttribute(It.IsAny<string>(),
|
|
It.IsAny<string>(), It.IsAny<string>(),
|
|
It.IsAny<OwnerOverrideInfo>()), Times.Once);
|
|
_mockDocumentTypeUploaderApiService.Verify(x => x.UploadPrimaryOwnerDocument(It.IsAny<PrimaryOwnerDocumentRequest>(),
|
|
It.IsAny<ProcessingRequest>(),
|
|
It.IsAny<ProcessResult>()), Times.Once);
|
|
}
|
|
} |