diff --git a/FIleProcessor.Models/FileImportLog.cs b/FIleProcessor.Models/FileImportLog.cs
new file mode 100644
index 0000000..525ab30
--- /dev/null
+++ b/FIleProcessor.Models/FileImportLog.cs
@@ -0,0 +1,47 @@
+namespace FIleProcessor.Models
+{
+ using System;
+ using System.Collections.Generic;
+
+ ///
+ ///
+ ///
+ public class FileImportLog
+ {
+ #region Properties
+
+ ///
+ /// Gets or sets the estate identifier.
+ ///
+ ///
+ /// The estate identifier.
+ ///
+ public Guid EstateId { get; set; }
+
+ ///
+ /// Gets or sets the file import log date time.
+ ///
+ ///
+ /// The file import log date time.
+ ///
+ public DateTime FileImportLogDateTime { get; set; }
+
+ ///
+ /// Gets or sets the file import log identifier.
+ ///
+ ///
+ /// The file import log identifier.
+ ///
+ public Guid FileImportLogId { get; set; }
+
+ ///
+ /// Gets or sets the files.
+ ///
+ ///
+ /// The files.
+ ///
+ public List Files { get; set; }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FIleProcessor.Models/ImportLogFile.cs b/FIleProcessor.Models/ImportLogFile.cs
index 71c391d..0e5e287 100644
--- a/FIleProcessor.Models/ImportLogFile.cs
+++ b/FIleProcessor.Models/ImportLogFile.cs
@@ -1,15 +1,7 @@
namespace FIleProcessor.Models
{
using System;
- using System.Collections.Generic;
- public class FileImportLog
- {
- public Guid EstateId { get; set; }
- public DateTime FileImportLogDateTime { get; set; }
- public Guid FileImportLogId { get; set; }
- public List Files { get; set; }
- }
public class ImportLogFile
{
///
diff --git a/FileProcessor.BusinessLogic.Tests/FileProcessingManagerTests.cs b/FileProcessor.BusinessLogic.Tests/FileProcessingManagerTests.cs
index 2cbaa66..94ef401 100644
--- a/FileProcessor.BusinessLogic.Tests/FileProcessingManagerTests.cs
+++ b/FileProcessor.BusinessLogic.Tests/FileProcessingManagerTests.cs
@@ -7,10 +7,19 @@
namespace FileProcessor.BusinessLogic.Tests
{
using System.Threading;
+ using Common;
+ using EstateReporting.Database;
+ using EstateReporting.Database.Entities;
+ using FIleProcessor.Models;
using Managers;
+ using Microsoft.EntityFrameworkCore;
+ using Microsoft.EntityFrameworkCore.Diagnostics;
+ using Moq;
+ using Shared.EntityFramework;
using Shouldly;
using Testing;
using Xunit;
+ using FileImportLog = EstateReporting.Database.Entities.FileImportLog;
public class FileProcessingManagerTests
{
@@ -18,7 +27,9 @@ public class FileProcessingManagerTests
public async Task FileProcessingManager_GetAllFileProfiles_AllFileProfilesReturned()
{
var fileProfiles = TestData.FileProfiles;
- FileProcessorManager manager = new FileProcessorManager(fileProfiles);
+ var contextFactory = this.CreateMockContextFactory();
+ Mock modelFactory = new Mock();
+ FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object,modelFactory.Object);
var allFileProfiles = await manager.GetAllFileProfiles(CancellationToken.None);
allFileProfiles.ShouldNotBeNull();
@@ -29,11 +40,121 @@ public async Task FileProcessingManager_GetAllFileProfiles_AllFileProfilesReturn
public async Task FileProcessingManager_GetFileProfile_FIleProfileReturned()
{
var fileProfiles = TestData.FileProfiles;
- FileProcessorManager manager = new FileProcessorManager(fileProfiles);
+ var contextFactory = this.CreateMockContextFactory();
+ Mock modelFactory = new Mock();
+ FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory.Object);
var fileProfile = await manager.GetFileProfile(TestData.SafaricomFileProfileId, CancellationToken.None);
fileProfile.ShouldNotBeNull();
fileProfile.FileProfileId.ShouldBe(TestData.SafaricomFileProfileId);
}
+
+ [Fact]
+ public async Task FileProcessingManager_GetFileImportLogs_NoMerchantId_ImportLogsReturned()
+ {
+ var fileProfiles = TestData.FileProfiles;
+ var context = await this.GetContext(Guid.NewGuid().ToString("N"));
+ var contextFactory = this.CreateMockContextFactory();
+ contextFactory.Setup(c => c.GetContext(It.IsAny(), It.IsAny())).ReturnsAsync(context);
+ IModelFactory modelFactory = new ModelFactory();
+
+ context.FileImportLogs.AddRange(TestData.FileImportLogs);
+ context.FileImportLogFiles.AddRange(TestData.FileImportLog1Files);
+ context.FileImportLogFiles.AddRange(TestData.FileImportLog2Files);
+ context.SaveChanges();
+
+ FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory);
+
+ var importLogs = await manager.GetFileImportLogs(TestData.EstateId, TestData.ImportLogStartDate, TestData.ImportLogEndDate, null, CancellationToken.None);
+
+ this.VerifyImportLogs(importLogs);
+ }
+
+ [Fact]
+ public async Task FileProcessingManager_GetFileImportLogs_WithMerchantId_ImportLogsReturned()
+ {
+ var fileProfiles = TestData.FileProfiles;
+ var context = await this.GetContext(Guid.NewGuid().ToString("N"));
+ var contextFactory = this.CreateMockContextFactory();
+ contextFactory.Setup(c => c.GetContext(It.IsAny(), It.IsAny())).ReturnsAsync(context);
+ IModelFactory modelFactory = new ModelFactory();
+
+ context.FileImportLogs.AddRange(TestData.FileImportLogs);
+ context.FileImportLogFiles.AddRange(TestData.FileImportLog1Files);
+ context.FileImportLogFiles.AddRange(TestData.FileImportLog2Files);
+ context.SaveChanges();
+
+ FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory);
+
+ var importLogs = await manager.GetFileImportLogs(TestData.EstateId, TestData.ImportLogStartDate, TestData.ImportLogEndDate, TestData.MerchantId, CancellationToken.None);
+
+ this.VerifyImportLogs(importLogs, TestData.MerchantId);
+ }
+
+ private void VerifyImportLogs(List importLogs, Guid? merchantId = null)
+ {
+ importLogs.ShouldNotBeNull();
+ importLogs.ShouldNotBeEmpty();
+ importLogs.Count.ShouldBe(TestData.FileImportLogs.Count);
+ foreach (FileImportLog fileImportLog in TestData.FileImportLogs)
+ {
+ var importLog = importLogs.SingleOrDefault(i => i.FileImportLogId == fileImportLog.FileImportLogId);
+ importLog.ShouldNotBeNull();
+ importLog.FileImportLogDateTime.ShouldBe(fileImportLog.ImportLogDateTime);
+ importLog.Files.Count.ShouldBe(importLog.Files.Count);
+
+ List filesToVerify = importLog.Files;
+ if (merchantId.HasValue)
+ {
+ filesToVerify = filesToVerify.Where(f => f.MerchantId == merchantId.Value).ToList();
+ }
+
+ foreach (ImportLogFile importLogFile in filesToVerify)
+ {
+ var file = importLog.Files.SingleOrDefault(impfile => impfile.FileId == importLogFile.FileId);
+ file.ShouldNotBeNull();
+ file.MerchantId.ShouldBe(importLogFile.MerchantId);
+ file.FilePath.ShouldBe(importLogFile.FilePath);
+ file.FileProfileId.ShouldBe(importLogFile.FileProfileId);
+ file.OriginalFileName.ShouldBe(importLogFile.OriginalFileName);
+ file.UserId.ShouldBe(importLogFile.UserId);
+ }
+ }
+ }
+
+ //[Fact]
+ //public async Task FileProcessingManager_GetFileImportLogs_WithMerchantId_ImportLogsReturned()
+ //{
+ // var fileProfiles = TestData.FileProfiles;
+ // var contextFactory = this.CreateMockContextFactory();
+ // IModelFactory modelFactory = new ModelFactory();
+ // FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory);
+
+ // var importLogs = await manager.GetFileImportLogs(TestData.EstateId, TestData.ImportLogStartDate, TestData.ImportLogEndDate, TestData.MerchantId, CancellationToken.None);
+
+ // importLogs.ShouldNotBeNull();
+ // importLogs.ShouldNotBeEmpty();
+ // importLogs.Count.ShouldBe(2);
+
+
+ //}
+
+ private Mock> CreateMockContextFactory()
+ {
+ return new Mock>();
+ }
+
+ private async Task GetContext(String databaseName)
+ {
+ EstateReportingContext context = null;
+
+ DbContextOptionsBuilder builder = new DbContextOptionsBuilder()
+ .UseInMemoryDatabase(databaseName)
+ .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning));
+ context = new EstateReportingContext(builder.Options);
+
+
+ return context;
+ }
}
}
diff --git a/FileProcessor.BusinessLogic.Tests/FileProcessor.BusinessLogic.Tests.csproj b/FileProcessor.BusinessLogic.Tests/FileProcessor.BusinessLogic.Tests.csproj
index 526e21b..53e4e38 100644
--- a/FileProcessor.BusinessLogic.Tests/FileProcessor.BusinessLogic.Tests.csproj
+++ b/FileProcessor.BusinessLogic.Tests/FileProcessor.BusinessLogic.Tests.csproj
@@ -7,7 +7,8 @@
-
+
+
diff --git a/FileProcessor.BusinessLogic.Tests/ModelFactoryTests.cs b/FileProcessor.BusinessLogic.Tests/ModelFactoryTests.cs
new file mode 100644
index 0000000..0d543b3
--- /dev/null
+++ b/FileProcessor.BusinessLogic.Tests/ModelFactoryTests.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FileProcessor.BusinessLogic.Tests
+{
+ using Common;
+ using EstateReporting.Database.Entities;
+ using FIleProcessor.Models;
+ using Shouldly;
+ using Testing;
+ using Xunit;
+ using FileImportLog = FIleProcessor.Models.FileImportLog;
+
+ public class ModelFactoryTests
+ {
+ [Fact]
+ public void ModelFactory_ConvertFrom_FileImportLog_IsConverted()
+ {
+ IModelFactory modelFactory = new ModelFactory();
+ List files = new List();
+ files.AddRange(TestData.FileImportLog1Files);
+ files.AddRange(TestData.FileImportLog2Files);
+ List result = modelFactory.ConvertFrom(TestData.FileImportLogs, files);
+
+ this.VerifyImportLogs(result);
+ }
+
+ [Fact]
+ public void ModelFactory_ConvertFrom_FileImportLog_NoFiles_IsConverted()
+ {
+ IModelFactory modelFactory = new ModelFactory();
+ List files = new List();
+ List result = modelFactory.ConvertFrom(TestData.FileImportLogs, files);
+
+ this.VerifyImportLogs(result);
+ }
+
+ [Fact]
+ public void ModelFactory_ConvertFrom_FileImportLog_NoImportLogs_IsConverted()
+ {
+ IModelFactory modelFactory = new ModelFactory();
+ List fileImportLogs = new List();
+ List files = new List();
+ List result = modelFactory.ConvertFrom(fileImportLogs, files);
+
+ result.ShouldNotBeNull();
+ result.ShouldBeEmpty();
+ }
+
+ private void VerifyImportLogs(List importLogs)
+ {
+ importLogs.ShouldNotBeNull();
+ importLogs.ShouldNotBeEmpty();
+ importLogs.Count.ShouldBe(TestData.FileImportLogs.Count);
+ foreach (EstateReporting.Database.Entities.FileImportLog fileImportLog in TestData.FileImportLogs)
+ {
+ var importLog = importLogs.SingleOrDefault(i => i.FileImportLogId == fileImportLog.FileImportLogId);
+ importLog.ShouldNotBeNull();
+ importLog.FileImportLogDateTime.ShouldBe(fileImportLog.ImportLogDateTime);
+ importLog.Files.Count.ShouldBe(importLog.Files.Count);
+
+ foreach (ImportLogFile importLogFile in importLog.Files)
+ {
+ var file = importLog.Files.SingleOrDefault(impfile => impfile.FileId == importLogFile.FileId);
+ file.ShouldNotBeNull();
+ file.MerchantId.ShouldBe(importLogFile.MerchantId);
+ file.FilePath.ShouldBe(importLogFile.FilePath);
+ file.FileProfileId.ShouldBe(importLogFile.FileProfileId);
+ file.OriginalFileName.ShouldBe(importLogFile.OriginalFileName);
+ file.UserId.ShouldBe(importLogFile.UserId);
+ }
+ }
+ }
+ }
+}
diff --git a/FileProcessor.BusinessLogic/Common/IModelFactory.cs b/FileProcessor.BusinessLogic/Common/IModelFactory.cs
new file mode 100644
index 0000000..c7d9dea
--- /dev/null
+++ b/FileProcessor.BusinessLogic/Common/IModelFactory.cs
@@ -0,0 +1,25 @@
+namespace FileProcessor.BusinessLogic.Common
+{
+ using System.Collections.Generic;
+ using EstateReporting.Database.Entities;
+ using FileImportLogModel = FIleProcessor.Models.FileImportLog;
+
+ ///
+ ///
+ ///
+ public interface IModelFactory
+ {
+ #region Methods
+
+ ///
+ /// Converts from.
+ ///
+ /// The import logs.
+ /// The import log files list.
+ ///
+ List ConvertFrom(List importLogs,
+ List importLogFilesList);
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FileProcessor.BusinessLogic/Common/ModelFactory.cs b/FileProcessor.BusinessLogic/Common/ModelFactory.cs
new file mode 100644
index 0000000..38a8508
--- /dev/null
+++ b/FileProcessor.BusinessLogic/Common/ModelFactory.cs
@@ -0,0 +1,61 @@
+namespace FileProcessor.BusinessLogic.Common
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using EstateReporting.Database.Entities;
+ using FIleProcessor.Models;
+ using FileImportLog = FIleProcessor.Models.FileImportLog;
+
+ ///
+ ///
+ ///
+ ///
+ public class ModelFactory : IModelFactory
+ {
+ #region Methods
+
+ ///
+ /// Converts from.
+ ///
+ /// The import logs.
+ /// The import log files list.
+ ///
+ public List ConvertFrom(List importLogs,
+ List importLogFilesList)
+ {
+ List models = new List();
+
+ foreach (EstateReporting.Database.Entities.FileImportLog fileImportLog in importLogs)
+ {
+ var model = new FileImportLog();
+
+ model.FileImportLogId = fileImportLog.FileImportLogId;
+ model.FileImportLogDateTime = fileImportLog.ImportLogDateTime;
+ model.EstateId = fileImportLog.EstateId;
+ model.Files = new List();
+
+ var currentImportLogFiles = importLogFilesList.Where(fi => fi.FileImportLogId == fileImportLog.FileImportLogId);
+
+ foreach (var importLogFile in currentImportLogFiles)
+ {
+ model.Files.Add(new ImportLogFile
+ {
+ MerchantId = importLogFile.MerchantId,
+ EstateId = importLogFile.EstateId,
+ FileId = importLogFile.FileId,
+ FilePath = importLogFile.FilePath,
+ FileProfileId = importLogFile.FileProfileId,
+ OriginalFileName = importLogFile.OriginalFileName,
+ UserId = importLogFile.UserId
+ });
+ }
+
+ models.Add(model);
+ }
+
+ return models;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj b/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj
index 3f8400a..75199c3 100644
--- a/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj
+++ b/FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj
@@ -6,6 +6,8 @@
+
+
@@ -16,6 +18,7 @@
+
diff --git a/FileProcessor.BusinessLogic/Managers/FileProcessorManager.cs b/FileProcessor.BusinessLogic/Managers/FileProcessorManager.cs
index 00b04f7..9beff61 100644
--- a/FileProcessor.BusinessLogic/Managers/FileProcessorManager.cs
+++ b/FileProcessor.BusinessLogic/Managers/FileProcessorManager.cs
@@ -3,9 +3,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
+ using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
+ using Common;
+ using EstateReporting.Database;
+ using EstateReporting.Database.Entities;
+ using EstateReporting.Database.ViewEntities;
using FIleProcessor.Models;
+ using Microsoft.EntityFrameworkCore;
+ using FileImportLog = FIleProcessor.Models.FileImportLog;
///
///
@@ -20,17 +27,27 @@ public class FileProcessorManager : IFileProcessorManager
///
private readonly List FileProfiles;
+ private readonly Shared.EntityFramework.IDbContextFactory DbContextFactory;
+
+ private readonly IModelFactory ModelFactory;
+
#endregion
#region Constructors
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The file profiles.
- public FileProcessorManager(List fileProfiles)
+ /// The database context factory.
+ /// The model factory.
+ public FileProcessorManager(List fileProfiles,
+ Shared.EntityFramework.IDbContextFactory dbContextFactory,
+ IModelFactory modelFactory)
{
this.FileProfiles = fileProfiles;
+ this.DbContextFactory = dbContextFactory;
+ this.ModelFactory = modelFactory;
}
#endregion
@@ -59,6 +76,38 @@ public async Task GetFileProfile(Guid fileProfileId,
return this.FileProfiles.SingleOrDefault(f => f.FileProfileId == fileProfileId);
}
+ ///
+ /// Gets the file import logs.
+ ///
+ ///
+ /// The start date time.
+ /// The end date time.
+ /// The merchant identifier.
+ /// The cancellation token.
+ ///
+ public async Task> GetFileImportLogs(Guid estateId,
+ DateTime startDateTime,
+ DateTime endDateTime,
+ Guid? merchantId,
+ CancellationToken cancellationToken)
+ {
+ EstateReportingContext context = await this.DbContextFactory.GetContext(estateId, cancellationToken);
+
+ List importLogQuery =
+ await context.FileImportLogs.AsAsyncEnumerable().Where(f => f.ImportLogDateTime >= startDateTime).ToListAsync(cancellationToken);
+
+ List importLogFileQuery = await context.FileImportLogFiles.AsAsyncEnumerable()
+ .Where(fi => importLogQuery.Select(f => f.FileImportLogId).Contains(fi.FileImportLogId))
+ .ToListAsync(cancellationToken);
+
+ if (merchantId.HasValue)
+ {
+ importLogFileQuery = importLogFileQuery.Where(i => i.MerchantId == merchantId.Value).ToList();
+ }
+
+ return this.ModelFactory.ConvertFrom(importLogQuery, importLogFileQuery);
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/FileProcessor.BusinessLogic/Managers/IFileProcessorManager.cs b/FileProcessor.BusinessLogic/Managers/IFileProcessorManager.cs
index 03d2960..68404e5 100644
--- a/FileProcessor.BusinessLogic/Managers/IFileProcessorManager.cs
+++ b/FileProcessor.BusinessLogic/Managers/IFileProcessorManager.cs
@@ -29,6 +29,17 @@ public interface IFileProcessorManager
Task GetFileProfile(Guid fileProfileId,
CancellationToken cancellationToken);
+ ///
+ /// Gets the file import logs.
+ ///
+ ///
+ /// The start date time.
+ /// The end date time.
+ /// The merchant identifier.
+ /// The cancellation token.
+ ///
+ Task> GetFileImportLogs(Guid estateId, DateTime startDateTime, DateTime endDateTime, Guid? merchantId, CancellationToken cancellationToken);
+
#endregion
}
}
\ No newline at end of file
diff --git a/FileProcessor.DataTransferObjects/UploadFileRequest.cs b/FileProcessor.DataTransferObjects/Requests/UploadFileRequest.cs
similarity index 100%
rename from FileProcessor.DataTransferObjects/UploadFileRequest.cs
rename to FileProcessor.DataTransferObjects/Requests/UploadFileRequest.cs
diff --git a/FileProcessor.DataTransferObjects/Responses/FileImportLog.cs b/FileProcessor.DataTransferObjects/Responses/FileImportLog.cs
new file mode 100644
index 0000000..c8998d9
--- /dev/null
+++ b/FileProcessor.DataTransferObjects/Responses/FileImportLog.cs
@@ -0,0 +1,48 @@
+namespace FileProcessor.DataTransferObjects.Responses
+{
+ using System;
+
+ ///
+ ///
+ ///
+ public class FileImportLog
+ {
+ ///
+ /// Gets or sets the file import log identifier.
+ ///
+ ///
+ /// The file import log identifier.
+ ///
+ public Guid FileImportLogId { get; set; }
+
+ ///
+ /// Gets or sets the import log date time.
+ ///
+ ///
+ /// The import log date time.
+ ///
+ public DateTime ImportLogDateTime { get; set; }
+ ///
+ /// Gets or sets the import log date.
+ ///
+ ///
+ /// The import log date.
+ ///
+ public DateTime ImportLogDate { get; set; }
+ ///
+ /// Gets or sets the import log time.
+ ///
+ ///
+ /// The import log time.
+ ///
+ public TimeSpan ImportLogTime { get; set; }
+
+ ///
+ /// Gets or sets the file count.
+ ///
+ ///
+ /// The file count.
+ ///
+ public Int32 FileCount { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/FileProcessor.DataTransferObjects/Responses/FileImportLogList.cs b/FileProcessor.DataTransferObjects/Responses/FileImportLogList.cs
new file mode 100644
index 0000000..2929e20
--- /dev/null
+++ b/FileProcessor.DataTransferObjects/Responses/FileImportLogList.cs
@@ -0,0 +1,19 @@
+namespace FileProcessor.DataTransferObjects.Responses
+{
+ using System.Collections.Generic;
+
+ ///
+ ///
+ ///
+ public class FileImportLogList
+ {
+ #region Fields
+
+ ///
+ /// The file import logs
+ ///
+ public List FileImportLogs;
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FileProcessor.IntegrationTests/Common/DockerHelper.cs b/FileProcessor.IntegrationTests/Common/DockerHelper.cs
index 0061afc..f53181f 100644
--- a/FileProcessor.IntegrationTests/Common/DockerHelper.cs
+++ b/FileProcessor.IntegrationTests/Common/DockerHelper.cs
@@ -43,6 +43,8 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper
///
public ISecurityServiceClient SecurityServiceClient;
+ public HttpClient FileProcessorClient;
+
///
/// The test identifier
///
@@ -303,13 +305,20 @@ await Retry.For(async () =>
IContainerService fileProcessorContainer = SetupFileProcessorContainer(this.FileProcessorContainerName,
this.Logger,
"fileprocessor",
- testNetwork,
+ new List
+ {
+ testNetwork,
+ Setup.DatabaseServerNetwork
+ },
traceFolder,
dockerCredentials,
this.SecurityServiceContainerName,
this.EstateManagementContainerName,
this.TransactionProcessorContainerName,
eventStoreAddress,
+ (Setup.SqlServerContainerName,
+ "sa",
+ "thisisalongpassword123!"),
("serviceClient", "Secret1"));
this.Containers.AddRange(new List
@@ -352,6 +361,8 @@ await Retry.For(async () =>
this.SecurityServiceClient = new SecurityServiceClient(SecurityServiceBaseAddressResolver, httpClient);
this.EstateReportingClient = new EstateReportingClient(EstateReportingBaseAddressResolver, httpClient);
//this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient);
+ this.FileProcessorClient = new HttpClient();
+ this.FileProcessorClient.BaseAddress = new Uri(FileProcessorBaseAddressResolver(null));
await this.LoadEventStoreProjections().ConfigureAwait(false);
}
@@ -359,13 +370,15 @@ await Retry.For(async () =>
public const Int32 FileProcessorDockerPort = 5009;
private IContainerService SetupFileProcessorContainer(String containerName, ILogger logger, String imageName,
- INetworkService networkService,
+ List networkService,
String hostFolder,
(String URL, String UserName, String Password)? dockerCredentials,
String securityServiceContainerName,
String estateManamgementContainerName,
String transactionProcessorContainerName,
String eventStoreAddress,
+ (String sqlServerContainerName, String sqlServerUserName, String sqlServerPassword)
+ sqlServerDetails,
(String clientId, String clientSecret) clientDetails,
Boolean forceLatestImage = false,
Int32 securityServicePort = DockerHelper.SecurityServiceDockerPort,
@@ -381,7 +394,8 @@ private IContainerService SetupFileProcessorContainer(String containerName, ILog
environmentVariables.Add($"AppSettings:EstateManagementApi=http://{estateManamgementContainerName}:{DockerHelper.EstateManagementDockerPort}");
environmentVariables.Add($"AppSettings:ClientId={clientDetails.clientId}");
environmentVariables.Add($"AppSettings:ClientSecret={clientDetails.clientSecret}");
-
+ environmentVariables
+ .Add($"ConnectionStrings:EstateReportingReadModel=\"server={sqlServerDetails.sqlServerContainerName};user id={sqlServerDetails.sqlServerUserName};password={sqlServerDetails.sqlServerPassword};database=EstateReportingReadModel\"");
var ciEnvVar = Environment.GetEnvironmentVariable("CI");
if ((String.IsNullOrEmpty(ciEnvVar) == false) && String.Compare(ciEnvVar, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0)
{
@@ -400,10 +414,7 @@ private IContainerService SetupFileProcessorContainer(String containerName, ILog
ContainerBuilder fileProcessorContainer = new Builder().UseContainer().WithName(containerName).WithEnvironment(environmentVariables.ToArray())
.UseImage(imageName, forceLatestImage)
.ExposePort(DockerHelper.FileProcessorDockerPort)
- .UseNetwork(new List
- {
- networkService
- }.ToArray());
+ .UseNetwork(networkService.ToArray());
if (String.IsNullOrEmpty(hostFolder) == false)
{
@@ -437,6 +448,9 @@ protected async Task PopulateSubscriptionServiceConfiguration()
await client.CreateAsync("$ce-MerchantAggregate", "Reporting", settings);
await client.CreateAsync("$ce-ContractAggregate", "Reporting", settings);
await client.CreateAsync("$ce-TransactionAggregate", "Reporting", settings);
+ await client.CreateAsync("$ce-FileImportLogAggregate", "Reporting", settings);
+ await client.CreateAsync("$ce-FileAggregate", "Reporting", settings);
+
await client.CreateAsync("$et-TransactionHasBeenCompletedEvent", "TransactionProcessor", settings);
await client.CreateAsync("$ce-FileImportLogAggregate", "FileProcessor", settings);
await client.CreateAsync("$ce-FileAggregate", "FileProcessor", settings);
diff --git a/FileProcessor.IntegrationTests/Common/SharedSteps.cs b/FileProcessor.IntegrationTests/Common/SharedSteps.cs
index ffa1f31..e0707df 100644
--- a/FileProcessor.IntegrationTests/Common/SharedSteps.cs
+++ b/FileProcessor.IntegrationTests/Common/SharedSteps.cs
@@ -528,9 +528,13 @@ public async Task GivenIMakeTheFollowingManualMerchantDeposits(Table table)
this.TestingContext.Logger.LogInformation($"Deposit Reference {makeMerchantDepositRequest.Reference} made for Merchant {merchantName}");
// Check the merchant balance
- MerchantBalanceResponse currentMerchantBalance = await this.TestingContext.DockerHelper.EstateClient.GetMerchantBalance(token, estateDetails.EstateId, merchantId, CancellationToken.None);
+ await Retry.For(async () =>
+ {
+ MerchantBalanceResponse currentMerchantBalance = await this.TestingContext.DockerHelper.EstateClient.GetMerchantBalance(token, estateDetails.EstateId, merchantId, CancellationToken.None);
- currentMerchantBalance.AvailableBalance.ShouldBe(previousMerchantBalance.AvailableBalance + makeMerchantDepositRequest.Amount);
+ currentMerchantBalance.AvailableBalance.ShouldBe(previousMerchantBalance.AvailableBalance + makeMerchantDepositRequest.Amount);
+ }, TimeSpan.FromMinutes(2));
+
}
}
diff --git a/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature
new file mode 100644
index 0000000..a60e146
--- /dev/null
+++ b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature
@@ -0,0 +1,95 @@
+@base @shared @processtopupcsv @getfileimportdetails
+Feature: GetFileImportDetails
+
+Background:
+ Given I create the following api scopes
+ | Name | DisplayName | Description |
+ | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST |
+ | transactionProcessor | Transaction Processor REST Scope | A scope for Transaction Processor REST |
+ | voucherManagement | Voucher Management REST Scope | A scope for Voucher Management REST |
+ | fileProcessor | File Processor REST Scope | A scope for File Processor REST |
+
+ Given the following api resources exist
+ | ResourceName | DisplayName | Secret | Scopes | UserClaims |
+ | estateManagement | Estate Managememt REST | Secret1 | estateManagement | MerchantId, EstateId, role |
+ | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | |
+ | voucherManagement | Voucher Management REST | Secret1 | voucherManagement | |
+ | fileProcessor | File Processor REST | Secret1 | fileProcessor | |
+
+ Given the following clients exist
+ | ClientId | ClientName | Secret | AllowedScopes | AllowedGrantTypes |
+ | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor,voucherManagement,fileProcessor | client_credentials |
+
+ Given I have a token to access the estate management and transaction processor resources
+ | ClientId |
+ | serviceClient |
+
+ Given I have created the following estates
+ | EstateName |
+ | Test Estate 1 |
+
+ Given I have created the following operators
+ | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
+ | Test Estate 1 | Safaricom | True | True |
+ | Test Estate 1 | Voucher | True | True |
+
+ Given I create a contract with the following values
+ | EstateName | OperatorName | ContractDescription |
+ | Test Estate 1 | Safaricom | Safaricom Contract |
+ | Test Estate 1 | Voucher | Hospital 1 Contract |
+
+ When I create the following Products
+ | EstateName | OperatorName | ContractDescription | ProductName | DisplayText | Value |
+ | Test Estate 1 | Safaricom | Safaricom Contract | Variable Topup | Custom | |
+ | Test Estate 1 | Voucher | Hospital 1 Contract | 10 KES | 10 KES | |
+
+ When I add the following Transaction Fees
+ | EstateName | OperatorName | ContractDescription | ProductName | CalculationType | FeeDescription | Value |
+ | Test Estate 1 | Safaricom | Safaricom Contract | Variable Topup | Fixed | Merchant Commission | 2.50 |
+
+ Given I create the following merchants
+ | MerchantName | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName |
+ | Test Merchant 1 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate 1 |
+ | Test Merchant 2 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant2.co.uk | Test Estate 1 |
+
+ Given I have assigned the following operator to the merchants
+ | OperatorName | MerchantName | MerchantNumber | TerminalNumber | EstateName |
+ | Safaricom | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 |
+ | Voucher | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 |
+ | Safaricom | Test Merchant 2 | 00000002 | 10000002 | Test Estate 1 |
+ | Voucher | Test Merchant 2 | 00000002 | 10000002 | Test Estate 1 |
+
+ Given I have assigned the following devices to the merchants
+ | DeviceIdentifier | MerchantName | EstateName |
+ | 123456780 | Test Merchant 1 | Test Estate 1 |
+ | 123456781 | Test Merchant 2 | Test Estate 1 |
+
+ Given I make the following manual merchant deposits
+ | Reference | Amount | DateTime | MerchantName | EstateName |
+ | Deposit1 | 300.00 | Today | Test Merchant 1 | Test Estate 1 |
+ | Deposit1 | 300.00 | Today | Test Merchant 2 | Test Estate 1 |
+
+@PRTest
+Scenario: Get File Import Log Details
+ Given I have a safaricom topup file with the following contents
+ | Column1 | Column2 | Column3 |
+ | H | 20210508 | |
+ | D | 07777777775 | 100 |
+ | T | 1 | |
+ And I upload this file for processing
+ | EstateName | MerchantName | FileProfileId | UserId |
+ | Test Estate 1 | Test Merchant 1 | B2A59ABF-293D-4A6B-B81B-7007503C3476 | ABA59ABF-293D-4A6B-B81B-7007503C3476 |
+
+ Given I have a safaricom topup file with the following contents
+ | Column1 | Column2 | Column3 |
+ | H | 20210508 | |
+ | D | 07777777775 | 150 |
+ | T | 1 | |
+ And I upload this file for processing
+ | EstateName | MerchantName | FileProfileId | UserId |
+ | Test Estate 1 | Test Merchant 2 | B2A59ABF-293D-4A6B-B81B-7007503C3476 | ABA59ABF-293D-4A6B-B81B-7007503C3476 |
+
+ When I get the 'Test Estate 1' import log for 'Today' the following data is returned
+ | ImportLogDate | FileCount |
+ | Today | 2 |
+
\ No newline at end of file
diff --git a/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature.cs b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature.cs
new file mode 100644
index 0000000..d92410e
--- /dev/null
+++ b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature.cs
@@ -0,0 +1,490 @@
+// ------------------------------------------------------------------------------
+//
+// This code was generated by SpecFlow (https://www.specflow.org/).
+// SpecFlow Version:3.7.0.0
+// SpecFlow Generator Version:3.7.0.0
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+// ------------------------------------------------------------------------------
+#region Designer generated code
+#pragma warning disable
+namespace FileProcessor.IntegrationTests.Features
+{
+ using TechTalk.SpecFlow;
+ using System;
+ using System.Linq;
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.7.0.0")]
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [Xunit.TraitAttribute("Category", "base")]
+ [Xunit.TraitAttribute("Category", "shared")]
+ [Xunit.TraitAttribute("Category", "processtopupcsv")]
+ [Xunit.TraitAttribute("Category", "getfileimportdetails")]
+ public partial class GetFileImportDetailsFeature : object, Xunit.IClassFixture, System.IDisposable
+ {
+
+ private static TechTalk.SpecFlow.ITestRunner testRunner;
+
+ private string[] _featureTags = new string[] {
+ "base",
+ "shared",
+ "processtopupcsv",
+ "getfileimportdetails"};
+
+ private Xunit.Abstractions.ITestOutputHelper _testOutputHelper;
+
+#line 1 "GetFileImportDetails.feature"
+#line hidden
+
+ public GetFileImportDetailsFeature(GetFileImportDetailsFeature.FixtureData fixtureData, FileProcessor_IntegrationTests_XUnitAssemblyFixture assemblyFixture, Xunit.Abstractions.ITestOutputHelper testOutputHelper)
+ {
+ this._testOutputHelper = testOutputHelper;
+ this.TestInitialize();
+ }
+
+ public static void FeatureSetup()
+ {
+ testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
+ TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "GetFileImportDetails", null, ProgrammingLanguage.CSharp, new string[] {
+ "base",
+ "shared",
+ "processtopupcsv",
+ "getfileimportdetails"});
+ testRunner.OnFeatureStart(featureInfo);
+ }
+
+ public static void FeatureTearDown()
+ {
+ testRunner.OnFeatureEnd();
+ testRunner = null;
+ }
+
+ public virtual void TestInitialize()
+ {
+ }
+
+ public virtual void TestTearDown()
+ {
+ testRunner.OnScenarioEnd();
+ }
+
+ public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
+ {
+ testRunner.OnScenarioInitialize(scenarioInfo);
+ testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(_testOutputHelper);
+ }
+
+ public virtual void ScenarioStart()
+ {
+ testRunner.OnScenarioStart();
+ }
+
+ public virtual void ScenarioCleanup()
+ {
+ testRunner.CollectScenarioErrors();
+ }
+
+ public virtual void FeatureBackground()
+ {
+#line 4
+#line hidden
+ TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
+ "Name",
+ "DisplayName",
+ "Description"});
+ table1.AddRow(new string[] {
+ "estateManagement",
+ "Estate Managememt REST Scope",
+ "A scope for Estate Managememt REST"});
+ table1.AddRow(new string[] {
+ "transactionProcessor",
+ "Transaction Processor REST Scope",
+ "A scope for Transaction Processor REST"});
+ table1.AddRow(new string[] {
+ "voucherManagement",
+ "Voucher Management REST Scope",
+ "A scope for Voucher Management REST"});
+ table1.AddRow(new string[] {
+ "fileProcessor",
+ "File Processor REST Scope",
+ "A scope for File Processor REST"});
+#line 5
+ testRunner.Given("I create the following api scopes", ((string)(null)), table1, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
+ "ResourceName",
+ "DisplayName",
+ "Secret",
+ "Scopes",
+ "UserClaims"});
+ table2.AddRow(new string[] {
+ "estateManagement",
+ "Estate Managememt REST",
+ "Secret1",
+ "estateManagement",
+ "MerchantId, EstateId, role"});
+ table2.AddRow(new string[] {
+ "transactionProcessor",
+ "Transaction Processor REST",
+ "Secret1",
+ "transactionProcessor",
+ ""});
+ table2.AddRow(new string[] {
+ "voucherManagement",
+ "Voucher Management REST",
+ "Secret1",
+ "voucherManagement",
+ ""});
+ table2.AddRow(new string[] {
+ "fileProcessor",
+ "File Processor REST",
+ "Secret1",
+ "fileProcessor",
+ ""});
+#line 12
+ testRunner.Given("the following api resources exist", ((string)(null)), table2, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
+ "ClientId",
+ "ClientName",
+ "Secret",
+ "AllowedScopes",
+ "AllowedGrantTypes"});
+ table3.AddRow(new string[] {
+ "serviceClient",
+ "Service Client",
+ "Secret1",
+ "estateManagement,transactionProcessor,voucherManagement,fileProcessor",
+ "client_credentials"});
+#line 19
+ testRunner.Given("the following clients exist", ((string)(null)), table3, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
+ "ClientId"});
+ table4.AddRow(new string[] {
+ "serviceClient"});
+#line 23
+ testRunner.Given("I have a token to access the estate management and transaction processor resource" +
+ "s", ((string)(null)), table4, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
+ "EstateName"});
+ table5.AddRow(new string[] {
+ "Test Estate 1"});
+#line 27
+ testRunner.Given("I have created the following estates", ((string)(null)), table5, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] {
+ "EstateName",
+ "OperatorName",
+ "RequireCustomMerchantNumber",
+ "RequireCustomTerminalNumber"});
+ table6.AddRow(new string[] {
+ "Test Estate 1",
+ "Safaricom",
+ "True",
+ "True"});
+ table6.AddRow(new string[] {
+ "Test Estate 1",
+ "Voucher",
+ "True",
+ "True"});
+#line 31
+ testRunner.Given("I have created the following operators", ((string)(null)), table6, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] {
+ "EstateName",
+ "OperatorName",
+ "ContractDescription"});
+ table7.AddRow(new string[] {
+ "Test Estate 1",
+ "Safaricom",
+ "Safaricom Contract"});
+ table7.AddRow(new string[] {
+ "Test Estate 1",
+ "Voucher",
+ "Hospital 1 Contract"});
+#line 36
+ testRunner.Given("I create a contract with the following values", ((string)(null)), table7, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
+ "EstateName",
+ "OperatorName",
+ "ContractDescription",
+ "ProductName",
+ "DisplayText",
+ "Value"});
+ table8.AddRow(new string[] {
+ "Test Estate 1",
+ "Safaricom",
+ "Safaricom Contract",
+ "Variable Topup",
+ "Custom",
+ ""});
+ table8.AddRow(new string[] {
+ "Test Estate 1",
+ "Voucher",
+ "Hospital 1 Contract",
+ "10 KES",
+ "10 KES",
+ ""});
+#line 41
+ testRunner.When("I create the following Products", ((string)(null)), table8, "When ");
+#line hidden
+ TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] {
+ "EstateName",
+ "OperatorName",
+ "ContractDescription",
+ "ProductName",
+ "CalculationType",
+ "FeeDescription",
+ "Value"});
+ table9.AddRow(new string[] {
+ "Test Estate 1",
+ "Safaricom",
+ "Safaricom Contract",
+ "Variable Topup",
+ "Fixed",
+ "Merchant Commission",
+ "2.50"});
+#line 46
+ testRunner.When("I add the following Transaction Fees", ((string)(null)), table9, "When ");
+#line hidden
+ TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] {
+ "MerchantName",
+ "AddressLine1",
+ "Town",
+ "Region",
+ "Country",
+ "ContactName",
+ "EmailAddress",
+ "EstateName"});
+ table10.AddRow(new string[] {
+ "Test Merchant 1",
+ "Address Line 1",
+ "TestTown",
+ "Test Region",
+ "United Kingdom",
+ "Test Contact 1",
+ "testcontact1@merchant1.co.uk",
+ "Test Estate 1"});
+ table10.AddRow(new string[] {
+ "Test Merchant 2",
+ "Address Line 1",
+ "TestTown",
+ "Test Region",
+ "United Kingdom",
+ "Test Contact 1",
+ "testcontact1@merchant2.co.uk",
+ "Test Estate 1"});
+#line 50
+ testRunner.Given("I create the following merchants", ((string)(null)), table10, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] {
+ "OperatorName",
+ "MerchantName",
+ "MerchantNumber",
+ "TerminalNumber",
+ "EstateName"});
+ table11.AddRow(new string[] {
+ "Safaricom",
+ "Test Merchant 1",
+ "00000001",
+ "10000001",
+ "Test Estate 1"});
+ table11.AddRow(new string[] {
+ "Voucher",
+ "Test Merchant 1",
+ "00000001",
+ "10000001",
+ "Test Estate 1"});
+ table11.AddRow(new string[] {
+ "Safaricom",
+ "Test Merchant 2",
+ "00000002",
+ "10000002",
+ "Test Estate 1"});
+ table11.AddRow(new string[] {
+ "Voucher",
+ "Test Merchant 2",
+ "00000002",
+ "10000002",
+ "Test Estate 1"});
+#line 55
+ testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table11, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] {
+ "DeviceIdentifier",
+ "MerchantName",
+ "EstateName"});
+ table12.AddRow(new string[] {
+ "123456780",
+ "Test Merchant 1",
+ "Test Estate 1"});
+ table12.AddRow(new string[] {
+ "123456781",
+ "Test Merchant 2",
+ "Test Estate 1"});
+#line 62
+ testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table12, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] {
+ "Reference",
+ "Amount",
+ "DateTime",
+ "MerchantName",
+ "EstateName"});
+ table13.AddRow(new string[] {
+ "Deposit1",
+ "300.00",
+ "Today",
+ "Test Merchant 1",
+ "Test Estate 1"});
+ table13.AddRow(new string[] {
+ "Deposit1",
+ "300.00",
+ "Today",
+ "Test Merchant 2",
+ "Test Estate 1"});
+#line 67
+ testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table13, "Given ");
+#line hidden
+ }
+
+ void System.IDisposable.Dispose()
+ {
+ this.TestTearDown();
+ }
+
+ [Xunit.SkippableFactAttribute(DisplayName="Get File Import Log Details")]
+ [Xunit.TraitAttribute("FeatureTitle", "GetFileImportDetails")]
+ [Xunit.TraitAttribute("Description", "Get File Import Log Details")]
+ [Xunit.TraitAttribute("Category", "PRTest")]
+ public virtual void GetFileImportLogDetails()
+ {
+ string[] tagsOfScenario = new string[] {
+ "PRTest"};
+ System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary();
+ TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get File Import Log Details", null, tagsOfScenario, argumentsOfScenario, this._featureTags);
+#line 73
+this.ScenarioInitialize(scenarioInfo);
+#line hidden
+ bool isScenarioIgnored = default(bool);
+ bool isFeatureIgnored = default(bool);
+ if ((tagsOfScenario != null))
+ {
+ isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
+ }
+ if ((this._featureTags != null))
+ {
+ isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
+ }
+ if ((isScenarioIgnored || isFeatureIgnored))
+ {
+ testRunner.SkipScenario();
+ }
+ else
+ {
+ this.ScenarioStart();
+#line 4
+this.FeatureBackground();
+#line hidden
+ TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] {
+ "Column1",
+ "Column2",
+ "Column3"});
+ table14.AddRow(new string[] {
+ "H",
+ "20210508",
+ ""});
+ table14.AddRow(new string[] {
+ "D",
+ "07777777775",
+ "100"});
+ table14.AddRow(new string[] {
+ "T",
+ "1",
+ ""});
+#line 74
+ testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table14, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table15 = new TechTalk.SpecFlow.Table(new string[] {
+ "EstateName",
+ "MerchantName",
+ "FileProfileId",
+ "UserId"});
+ table15.AddRow(new string[] {
+ "Test Estate 1",
+ "Test Merchant 1",
+ "B2A59ABF-293D-4A6B-B81B-7007503C3476",
+ "ABA59ABF-293D-4A6B-B81B-7007503C3476"});
+#line 79
+ testRunner.And("I upload this file for processing", ((string)(null)), table15, "And ");
+#line hidden
+ TechTalk.SpecFlow.Table table16 = new TechTalk.SpecFlow.Table(new string[] {
+ "Column1",
+ "Column2",
+ "Column3"});
+ table16.AddRow(new string[] {
+ "H",
+ "20210508",
+ ""});
+ table16.AddRow(new string[] {
+ "D",
+ "07777777775",
+ "150"});
+ table16.AddRow(new string[] {
+ "T",
+ "1",
+ ""});
+#line 83
+ testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table16, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table17 = new TechTalk.SpecFlow.Table(new string[] {
+ "EstateName",
+ "MerchantName",
+ "FileProfileId",
+ "UserId"});
+ table17.AddRow(new string[] {
+ "Test Estate 1",
+ "Test Merchant 2",
+ "B2A59ABF-293D-4A6B-B81B-7007503C3476",
+ "ABA59ABF-293D-4A6B-B81B-7007503C3476"});
+#line 88
+ testRunner.And("I upload this file for processing", ((string)(null)), table17, "And ");
+#line hidden
+ TechTalk.SpecFlow.Table table18 = new TechTalk.SpecFlow.Table(new string[] {
+ "ImportLogDate",
+ "FileCount"});
+ table18.AddRow(new string[] {
+ "Today",
+ "2"});
+#line 92
+ testRunner.When("I get the \'Test Estate 1\' import log for \'Today\' the following data is returned", ((string)(null)), table18, "When ");
+#line hidden
+ }
+ this.ScenarioCleanup();
+ }
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.7.0.0")]
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class FixtureData : System.IDisposable
+ {
+
+ public FixtureData()
+ {
+ GetFileImportDetailsFeature.FeatureSetup();
+ }
+
+ void System.IDisposable.Dispose()
+ {
+ GetFileImportDetailsFeature.FeatureTearDown();
+ }
+ }
+ }
+}
+#pragma warning restore
+#endregion
diff --git a/FileProcessor.IntegrationTests/Features/GetFileImportDetailsSteps.cs b/FileProcessor.IntegrationTests/Features/GetFileImportDetailsSteps.cs
new file mode 100644
index 0000000..b12a1bf
--- /dev/null
+++ b/FileProcessor.IntegrationTests/Features/GetFileImportDetailsSteps.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FileProcessor.IntegrationTests.Features
+{
+ using System.Net;
+ using System.Net.Http;
+ using System.Net.Http.Headers;
+ using Common;
+ using DataTransferObjects.Responses;
+ using Newtonsoft.Json;
+ using Shouldly;
+ using TechTalk.SpecFlow;
+
+ [Binding]
+ [Scope(Tag = "getfileimportdetails")]
+ public class GetFileImportDetailsSteps
+ {
+ private readonly ScenarioContext ScenarioContext;
+
+ private readonly TestingContext TestingContext;
+
+ public GetFileImportDetailsSteps(ScenarioContext scenarioContext,
+ TestingContext testingContext)
+ {
+ this.ScenarioContext = scenarioContext;
+ this.TestingContext = testingContext;
+ }
+
+ [When(@"I get the '(.*)' import log for '(.*)' the following data is returned")]
+ public async Task WhenIGetTheImportLogForTheFollowingDataIsReturned(String estateName,String date, Table table)
+ {
+ var queryDate = SpecflowTableHelper.GetDateForDateString(date, DateTime.Now);
+ var estateDetails = this.TestingContext.GetEstateDetails(estateName);
+
+ String requestUri =
+ $"{this.TestingContext.DockerHelper.FileProcessorClient.BaseAddress}api/fileImportLogs/{estateDetails.EstateId}/?startDate={queryDate.Date:yyyy-MM-dd}&endDate={queryDate.Date:yyyy-MM-dd}";
+ HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
+ requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", this.TestingContext.AccessToken);
+
+ var responseMessage = await this.TestingContext.DockerHelper.FileProcessorClient.SendAsync(requestMessage);
+
+ responseMessage.StatusCode.ShouldBe(HttpStatusCode.OK);
+ var content = await responseMessage.Content.ReadAsStringAsync();
+ content.ShouldNotBeNull();
+ content.ShouldNotBeEmpty();
+
+ var importLogList = JsonConvert.DeserializeObject(content);
+ importLogList.ShouldNotBeNull();
+ importLogList.FileImportLogs.ShouldNotBeNull();
+ importLogList.FileImportLogs.ShouldNotBeEmpty();
+
+ foreach (TableRow tableRow in table.Rows)
+ {
+ var importLogDateTime = SpecflowTableHelper.GetDateForDateString(SpecflowTableHelper.GetStringRowValue(tableRow, "ImportLogDate"), DateTime.Now);
+ var fileCount = SpecflowTableHelper.GetIntValue(tableRow, "FileCount");
+
+ // Find the import log now
+ var importLog = importLogList.FileImportLogs.SingleOrDefault(fil => fil.ImportLogDate == importLogDateTime.Date && fil.FileCount == fileCount);
+
+ importLog.ShouldNotBeNull();
+ }
+ }
+
+ }
+}
diff --git a/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs b/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs
index f85c5e8..6886fe6 100644
--- a/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs
+++ b/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs
@@ -88,140 +88,140 @@ public virtual void FeatureBackground()
{
#line 4
#line hidden
- TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table19 = new TechTalk.SpecFlow.Table(new string[] {
"Name",
"DisplayName",
"Description"});
- table1.AddRow(new string[] {
+ table19.AddRow(new string[] {
"estateManagement",
"Estate Managememt REST Scope",
"A scope for Estate Managememt REST"});
- table1.AddRow(new string[] {
+ table19.AddRow(new string[] {
"transactionProcessor",
"Transaction Processor REST Scope",
"A scope for Transaction Processor REST"});
- table1.AddRow(new string[] {
+ table19.AddRow(new string[] {
"voucherManagement",
"Voucher Management REST Scope",
"A scope for Voucher Management REST"});
- table1.AddRow(new string[] {
+ table19.AddRow(new string[] {
"fileProcessor",
"File Processor REST Scope",
"A scope for File Processor REST"});
#line 5
- testRunner.Given("I create the following api scopes", ((string)(null)), table1, "Given ");
+ testRunner.Given("I create the following api scopes", ((string)(null)), table19, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table20 = new TechTalk.SpecFlow.Table(new string[] {
"ResourceName",
"DisplayName",
"Secret",
"Scopes",
"UserClaims"});
- table2.AddRow(new string[] {
+ table20.AddRow(new string[] {
"estateManagement",
"Estate Managememt REST",
"Secret1",
"estateManagement",
"MerchantId, EstateId, role"});
- table2.AddRow(new string[] {
+ table20.AddRow(new string[] {
"transactionProcessor",
"Transaction Processor REST",
"Secret1",
"transactionProcessor",
""});
- table2.AddRow(new string[] {
+ table20.AddRow(new string[] {
"voucherManagement",
"Voucher Management REST",
"Secret1",
"voucherManagement",
""});
- table2.AddRow(new string[] {
+ table20.AddRow(new string[] {
"fileProcessor",
"File Processor REST",
"Secret1",
"fileProcessor",
""});
#line 12
- testRunner.Given("the following api resources exist", ((string)(null)), table2, "Given ");
+ testRunner.Given("the following api resources exist", ((string)(null)), table20, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table21 = new TechTalk.SpecFlow.Table(new string[] {
"ClientId",
"ClientName",
"Secret",
"AllowedScopes",
"AllowedGrantTypes"});
- table3.AddRow(new string[] {
+ table21.AddRow(new string[] {
"serviceClient",
"Service Client",
"Secret1",
"estateManagement,transactionProcessor,voucherManagement,fileProcessor",
"client_credentials"});
#line 19
- testRunner.Given("the following clients exist", ((string)(null)), table3, "Given ");
+ testRunner.Given("the following clients exist", ((string)(null)), table21, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table22 = new TechTalk.SpecFlow.Table(new string[] {
"ClientId"});
- table4.AddRow(new string[] {
+ table22.AddRow(new string[] {
"serviceClient"});
#line 23
testRunner.Given("I have a token to access the estate management and transaction processor resource" +
- "s", ((string)(null)), table4, "Given ");
+ "s", ((string)(null)), table22, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table23 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName"});
- table5.AddRow(new string[] {
+ table23.AddRow(new string[] {
"Test Estate 1"});
#line 27
- testRunner.Given("I have created the following estates", ((string)(null)), table5, "Given ");
+ testRunner.Given("I have created the following estates", ((string)(null)), table23, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table24 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"RequireCustomMerchantNumber",
"RequireCustomTerminalNumber"});
- table6.AddRow(new string[] {
+ table24.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"True",
"True"});
- table6.AddRow(new string[] {
+ table24.AddRow(new string[] {
"Test Estate 1",
"Voucher",
"True",
"True"});
#line 31
- testRunner.Given("I have created the following operators", ((string)(null)), table6, "Given ");
+ testRunner.Given("I have created the following operators", ((string)(null)), table24, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table25 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"ContractDescription"});
- table7.AddRow(new string[] {
+ table25.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"Safaricom Contract"});
- table7.AddRow(new string[] {
+ table25.AddRow(new string[] {
"Test Estate 1",
"Voucher",
"Hospital 1 Contract"});
#line 36
- testRunner.Given("I create a contract with the following values", ((string)(null)), table7, "Given ");
+ testRunner.Given("I create a contract with the following values", ((string)(null)), table25, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table26 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"ContractDescription",
"ProductName",
"DisplayText",
"Value"});
- table8.AddRow(new string[] {
+ table26.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"Safaricom Contract",
"Variable Topup",
"Custom",
""});
- table8.AddRow(new string[] {
+ table26.AddRow(new string[] {
"Test Estate 1",
"Voucher",
"Hospital 1 Contract",
@@ -229,9 +229,9 @@ public virtual void FeatureBackground()
"10 KES",
""});
#line 41
- testRunner.When("I create the following Products", ((string)(null)), table8, "When ");
+ testRunner.When("I create the following Products", ((string)(null)), table26, "When ");
#line hidden
- TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table27 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"ContractDescription",
@@ -239,7 +239,7 @@ public virtual void FeatureBackground()
"CalculationType",
"FeeDescription",
"Value"});
- table9.AddRow(new string[] {
+ table27.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"Safaricom Contract",
@@ -248,9 +248,9 @@ public virtual void FeatureBackground()
"Merchant Commission",
"2.50"});
#line 46
- testRunner.When("I add the following Transaction Fees", ((string)(null)), table9, "When ");
+ testRunner.When("I add the following Transaction Fees", ((string)(null)), table27, "When ");
#line hidden
- TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table28 = new TechTalk.SpecFlow.Table(new string[] {
"MerchantName",
"AddressLine1",
"Town",
@@ -259,7 +259,7 @@ public virtual void FeatureBackground()
"ContactName",
"EmailAddress",
"EstateName"});
- table10.AddRow(new string[] {
+ table28.AddRow(new string[] {
"Test Merchant 1",
"Address Line 1",
"TestTown",
@@ -269,54 +269,54 @@ public virtual void FeatureBackground()
"testcontact1@merchant1.co.uk",
"Test Estate 1"});
#line 50
- testRunner.Given("I create the following merchants", ((string)(null)), table10, "Given ");
+ testRunner.Given("I create the following merchants", ((string)(null)), table28, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table29 = new TechTalk.SpecFlow.Table(new string[] {
"OperatorName",
"MerchantName",
"MerchantNumber",
"TerminalNumber",
"EstateName"});
- table11.AddRow(new string[] {
+ table29.AddRow(new string[] {
"Safaricom",
"Test Merchant 1",
"00000001",
"10000001",
"Test Estate 1"});
- table11.AddRow(new string[] {
+ table29.AddRow(new string[] {
"Voucher",
"Test Merchant 1",
"00000001",
"10000001",
"Test Estate 1"});
#line 54
- testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table11, "Given ");
+ testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table29, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table30 = new TechTalk.SpecFlow.Table(new string[] {
"DeviceIdentifier",
"MerchantName",
"EstateName"});
- table12.AddRow(new string[] {
+ table30.AddRow(new string[] {
"123456780",
"Test Merchant 1",
"Test Estate 1"});
#line 59
- testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table12, "Given ");
+ testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table30, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table31 = new TechTalk.SpecFlow.Table(new string[] {
"Reference",
"Amount",
"DateTime",
"MerchantName",
"EstateName"});
- table13.AddRow(new string[] {
+ table31.AddRow(new string[] {
"Deposit1",
"300.00",
"Today",
"Test Merchant 1",
"Test Estate 1"});
#line 63
- testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table13, "Given ");
+ testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table31, "Given ");
#line hidden
}
@@ -356,37 +356,37 @@ public virtual void ProcessSafaricomTopupFileWith1DetailRow()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table32 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3"});
- table14.AddRow(new string[] {
+ table32.AddRow(new string[] {
"H",
"20210508",
""});
- table14.AddRow(new string[] {
+ table32.AddRow(new string[] {
"D",
"07777777775",
"100"});
- table14.AddRow(new string[] {
+ table32.AddRow(new string[] {
"T",
"1",
""});
#line 68
- testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table14, "Given ");
+ testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table32, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table15 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table33 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table15.AddRow(new string[] {
+ table33.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"B2A59ABF-293D-4A6B-B81B-7007503C3476",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 73
- testRunner.And("I upload this file for processing", ((string)(null)), table15, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table33, "And ");
#line hidden
#line 77
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 1 t" +
@@ -429,41 +429,41 @@ public virtual void ProcessSafaricomTopupFileWith2DetailRows()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table16 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table34 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3"});
- table16.AddRow(new string[] {
+ table34.AddRow(new string[] {
"H",
"20210508",
""});
- table16.AddRow(new string[] {
+ table34.AddRow(new string[] {
"D",
"07777777775",
"100"});
- table16.AddRow(new string[] {
+ table34.AddRow(new string[] {
"D",
"07777777776",
"200"});
- table16.AddRow(new string[] {
+ table34.AddRow(new string[] {
"T",
"2",
""});
#line 81
-testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table16, "Given ");
+testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table34, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table17 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table35 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table17.AddRow(new string[] {
+ table35.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"B2A59ABF-293D-4A6B-B81B-7007503C3476",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 87
- testRunner.And("I upload this file for processing", ((string)(null)), table17, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table35, "And ");
#line hidden
#line 91
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 2 t" +
@@ -504,73 +504,73 @@ public virtual void Process2SafaricomTopupFiles()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table18 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table36 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3"});
- table18.AddRow(new string[] {
+ table36.AddRow(new string[] {
"H",
"20210508",
""});
- table18.AddRow(new string[] {
+ table36.AddRow(new string[] {
"D",
"07777777775",
"100"});
- table18.AddRow(new string[] {
+ table36.AddRow(new string[] {
"T",
"1",
""});
#line 94
- testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table18, "Given ");
+ testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table36, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table19 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table37 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table19.AddRow(new string[] {
+ table37.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"B2A59ABF-293D-4A6B-B81B-7007503C3476",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 99
- testRunner.And("I upload this file for processing", ((string)(null)), table19, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table37, "And ");
#line hidden
- TechTalk.SpecFlow.Table table20 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table38 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3"});
- table20.AddRow(new string[] {
+ table38.AddRow(new string[] {
"H",
"20210508",
""});
- table20.AddRow(new string[] {
+ table38.AddRow(new string[] {
"D",
"07777777776",
"150"});
- table20.AddRow(new string[] {
+ table38.AddRow(new string[] {
"D",
"07777777777",
"50"});
- table20.AddRow(new string[] {
+ table38.AddRow(new string[] {
"T",
"2",
""});
#line 103
- testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table20, "Given ");
+ testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table38, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table21 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table39 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table21.AddRow(new string[] {
+ table39.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"B2A59ABF-293D-4A6B-B81B-7007503C3476",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 109
- testRunner.And("I upload this file for processing", ((string)(null)), table21, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table39, "And ");
#line hidden
#line 113
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 3 t" +
@@ -613,74 +613,74 @@ public virtual void ProcessDuplicateSafaricomTopupFileWith1DetailRow()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table22 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table40 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3"});
- table22.AddRow(new string[] {
+ table40.AddRow(new string[] {
"H",
"20210508",
""});
- table22.AddRow(new string[] {
+ table40.AddRow(new string[] {
"D",
"07777777775",
"100"});
- table22.AddRow(new string[] {
+ table40.AddRow(new string[] {
"T",
"1",
""});
#line 117
- testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table22, "Given ");
+ testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table40, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table23 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table41 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table23.AddRow(new string[] {
+ table41.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"B2A59ABF-293D-4A6B-B81B-7007503C3476",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 122
- testRunner.And("I upload this file for processing", ((string)(null)), table23, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table41, "And ");
#line hidden
#line 126
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 1 t" +
"ransaction should be returned", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
- TechTalk.SpecFlow.Table table24 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table42 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3"});
- table24.AddRow(new string[] {
+ table42.AddRow(new string[] {
"H",
"20210508",
""});
- table24.AddRow(new string[] {
+ table42.AddRow(new string[] {
"D",
"07777777775",
"100"});
- table24.AddRow(new string[] {
+ table42.AddRow(new string[] {
"T",
"1",
""});
#line 128
- testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table24, "Given ");
+ testRunner.Given("I have a safaricom topup file with the following contents", ((string)(null)), table42, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table25 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table43 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table25.AddRow(new string[] {
+ table43.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"B2A59ABF-293D-4A6B-B81B-7007503C3476",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 133
testRunner.And("I upload this file for processing an error should be returned indicating the file" +
- " is a duplicate", ((string)(null)), table25, "And ");
+ " is a duplicate", ((string)(null)), table43, "And ");
#line hidden
}
this.ScenarioCleanup();
diff --git a/FileProcessor.IntegrationTests/Features/ProcessTopupCSVSteps.cs b/FileProcessor.IntegrationTests/Features/ProcessTopupCSVSteps.cs
index 0001f65..2d0b0ed 100644
--- a/FileProcessor.IntegrationTests/Features/ProcessTopupCSVSteps.cs
+++ b/FileProcessor.IntegrationTests/Features/ProcessTopupCSVSteps.cs
@@ -116,6 +116,7 @@ private async Task UploadFile(Table table)
{
Content = formData
};
+ request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", this.TestingContext.AccessToken);
var response = await client.SendAsync(request);
@@ -130,7 +131,7 @@ public async Task WhenAsMerchantOnEstateIGetMyTransactionsTransactionShouldBeRet
var estate = this.TestingContext.GetEstateDetails(estateName);
Guid estateId = estate.EstateId;
var merchantId = estate.GetMerchantId(merchantName);
- String accessToken = estate.AccessToken;
+ String accessToken = this.TestingContext.AccessToken;
await Retry.For(async () =>
{
diff --git a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs
index be48f17..c00c3ff 100644
--- a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs
+++ b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs
@@ -88,140 +88,140 @@ public virtual void FeatureBackground()
{
#line 4
#line hidden
- TechTalk.SpecFlow.Table table26 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table44 = new TechTalk.SpecFlow.Table(new string[] {
"Name",
"DisplayName",
"Description"});
- table26.AddRow(new string[] {
+ table44.AddRow(new string[] {
"estateManagement",
"Estate Managememt REST Scope",
"A scope for Estate Managememt REST"});
- table26.AddRow(new string[] {
+ table44.AddRow(new string[] {
"transactionProcessor",
"Transaction Processor REST Scope",
"A scope for Transaction Processor REST"});
- table26.AddRow(new string[] {
+ table44.AddRow(new string[] {
"voucherManagement",
"Voucher Management REST Scope",
"A scope for Voucher Management REST"});
- table26.AddRow(new string[] {
+ table44.AddRow(new string[] {
"fileProcessor",
"File Processor REST Scope",
"A scope for File Processor REST"});
#line 5
- testRunner.Given("I create the following api scopes", ((string)(null)), table26, "Given ");
+ testRunner.Given("I create the following api scopes", ((string)(null)), table44, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table27 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table45 = new TechTalk.SpecFlow.Table(new string[] {
"ResourceName",
"DisplayName",
"Secret",
"Scopes",
"UserClaims"});
- table27.AddRow(new string[] {
+ table45.AddRow(new string[] {
"estateManagement",
"Estate Managememt REST",
"Secret1",
"estateManagement",
"MerchantId, EstateId, role"});
- table27.AddRow(new string[] {
+ table45.AddRow(new string[] {
"transactionProcessor",
"Transaction Processor REST",
"Secret1",
"transactionProcessor",
""});
- table27.AddRow(new string[] {
+ table45.AddRow(new string[] {
"voucherManagement",
"Voucher Management REST",
"Secret1",
"voucherManagement",
""});
- table27.AddRow(new string[] {
+ table45.AddRow(new string[] {
"fileProcessor",
"File Processor REST",
"Secret1",
"fileProcessor",
""});
#line 12
- testRunner.Given("the following api resources exist", ((string)(null)), table27, "Given ");
+ testRunner.Given("the following api resources exist", ((string)(null)), table45, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table28 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table46 = new TechTalk.SpecFlow.Table(new string[] {
"ClientId",
"ClientName",
"Secret",
"AllowedScopes",
"AllowedGrantTypes"});
- table28.AddRow(new string[] {
+ table46.AddRow(new string[] {
"serviceClient",
"Service Client",
"Secret1",
"estateManagement,transactionProcessor,voucherManagement,fileProcessor",
"client_credentials"});
#line 19
- testRunner.Given("the following clients exist", ((string)(null)), table28, "Given ");
+ testRunner.Given("the following clients exist", ((string)(null)), table46, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table29 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table47 = new TechTalk.SpecFlow.Table(new string[] {
"ClientId"});
- table29.AddRow(new string[] {
+ table47.AddRow(new string[] {
"serviceClient"});
#line 23
testRunner.Given("I have a token to access the estate management and transaction processor resource" +
- "s", ((string)(null)), table29, "Given ");
+ "s", ((string)(null)), table47, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table30 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table48 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName"});
- table30.AddRow(new string[] {
+ table48.AddRow(new string[] {
"Test Estate 1"});
#line 27
- testRunner.Given("I have created the following estates", ((string)(null)), table30, "Given ");
+ testRunner.Given("I have created the following estates", ((string)(null)), table48, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table31 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table49 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"RequireCustomMerchantNumber",
"RequireCustomTerminalNumber"});
- table31.AddRow(new string[] {
+ table49.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"True",
"True"});
- table31.AddRow(new string[] {
+ table49.AddRow(new string[] {
"Test Estate 1",
"Voucher",
"True",
"True"});
#line 31
- testRunner.Given("I have created the following operators", ((string)(null)), table31, "Given ");
+ testRunner.Given("I have created the following operators", ((string)(null)), table49, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table32 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table50 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"ContractDescription"});
- table32.AddRow(new string[] {
+ table50.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"Safaricom Contract"});
- table32.AddRow(new string[] {
+ table50.AddRow(new string[] {
"Test Estate 1",
"Voucher",
"Hospital 1 Contract"});
#line 36
- testRunner.Given("I create a contract with the following values", ((string)(null)), table32, "Given ");
+ testRunner.Given("I create a contract with the following values", ((string)(null)), table50, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table33 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table51 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"ContractDescription",
"ProductName",
"DisplayText",
"Value"});
- table33.AddRow(new string[] {
+ table51.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"Safaricom Contract",
"Variable Topup",
"Custom",
""});
- table33.AddRow(new string[] {
+ table51.AddRow(new string[] {
"Test Estate 1",
"Voucher",
"Hospital 1 Contract",
@@ -229,9 +229,9 @@ public virtual void FeatureBackground()
"Custom",
""});
#line 41
- testRunner.When("I create the following Products", ((string)(null)), table33, "When ");
+ testRunner.When("I create the following Products", ((string)(null)), table51, "When ");
#line hidden
- TechTalk.SpecFlow.Table table34 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table52 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"OperatorName",
"ContractDescription",
@@ -239,7 +239,7 @@ public virtual void FeatureBackground()
"CalculationType",
"FeeDescription",
"Value"});
- table34.AddRow(new string[] {
+ table52.AddRow(new string[] {
"Test Estate 1",
"Safaricom",
"Safaricom Contract",
@@ -247,7 +247,7 @@ public virtual void FeatureBackground()
"Fixed",
"Merchant Commission",
"2.50"});
- table34.AddRow(new string[] {
+ table52.AddRow(new string[] {
"Test Estate 1",
"Voucher",
"Hospital 1 Contract",
@@ -256,9 +256,9 @@ public virtual void FeatureBackground()
"Merchant Commission",
"2.50"});
#line 46
- testRunner.When("I add the following Transaction Fees", ((string)(null)), table34, "When ");
+ testRunner.When("I add the following Transaction Fees", ((string)(null)), table52, "When ");
#line hidden
- TechTalk.SpecFlow.Table table35 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table53 = new TechTalk.SpecFlow.Table(new string[] {
"MerchantName",
"AddressLine1",
"Town",
@@ -267,7 +267,7 @@ public virtual void FeatureBackground()
"ContactName",
"EmailAddress",
"EstateName"});
- table35.AddRow(new string[] {
+ table53.AddRow(new string[] {
"Test Merchant 1",
"Address Line 1",
"TestTown",
@@ -277,54 +277,54 @@ public virtual void FeatureBackground()
"testcontact1@merchant1.co.uk",
"Test Estate 1"});
#line 51
- testRunner.Given("I create the following merchants", ((string)(null)), table35, "Given ");
+ testRunner.Given("I create the following merchants", ((string)(null)), table53, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table36 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table54 = new TechTalk.SpecFlow.Table(new string[] {
"OperatorName",
"MerchantName",
"MerchantNumber",
"TerminalNumber",
"EstateName"});
- table36.AddRow(new string[] {
+ table54.AddRow(new string[] {
"Safaricom",
"Test Merchant 1",
"00000001",
"10000001",
"Test Estate 1"});
- table36.AddRow(new string[] {
+ table54.AddRow(new string[] {
"Voucher",
"Test Merchant 1",
"00000001",
"10000001",
"Test Estate 1"});
#line 55
- testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table36, "Given ");
+ testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table54, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table37 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table55 = new TechTalk.SpecFlow.Table(new string[] {
"DeviceIdentifier",
"MerchantName",
"EstateName"});
- table37.AddRow(new string[] {
+ table55.AddRow(new string[] {
"123456780",
"Test Merchant 1",
"Test Estate 1"});
#line 60
- testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table37, "Given ");
+ testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table55, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table38 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table56 = new TechTalk.SpecFlow.Table(new string[] {
"Reference",
"Amount",
"DateTime",
"MerchantName",
"EstateName"});
- table38.AddRow(new string[] {
+ table56.AddRow(new string[] {
"Deposit1",
"300.00",
"Today",
"Test Merchant 1",
"Test Estate 1"});
#line 64
- testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table38, "Given ");
+ testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table56, "Given ");
#line hidden
}
@@ -364,41 +364,41 @@ public virtual void ProcessVoucherFileWith1DetailRowForRecipientEmail()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table39 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table57 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3",
"Column4"});
- table39.AddRow(new string[] {
+ table57.AddRow(new string[] {
"H",
"20210508",
"",
""});
- table39.AddRow(new string[] {
+ table57.AddRow(new string[] {
"D",
"Hospital 1",
"testrecipient1@recipient.com",
"10"});
- table39.AddRow(new string[] {
+ table57.AddRow(new string[] {
"T",
"1",
"",
""});
#line 69
- testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table39, "Given ");
+ testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table57, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table40 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table58 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table40.AddRow(new string[] {
+ table58.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"8806EDBC-3ED6-406B-9E5F-A9078356BE99",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 74
- testRunner.And("I upload this file for processing", ((string)(null)), table40, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table58, "And ");
#line hidden
#line 78
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 1 t" +
@@ -439,41 +439,41 @@ public virtual void ProcessVoucherFileWith1DetailRowForRecipientMobile()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table41 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table59 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3",
"Column4"});
- table41.AddRow(new string[] {
+ table59.AddRow(new string[] {
"H",
"20210508",
"",
""});
- table41.AddRow(new string[] {
+ table59.AddRow(new string[] {
"D",
"Hospital 1",
"07777777775",
"10"});
- table41.AddRow(new string[] {
+ table59.AddRow(new string[] {
"T",
"1",
"",
""});
#line 81
- testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table41, "Given ");
+ testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table59, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table42 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table60 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table42.AddRow(new string[] {
+ table60.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"8806EDBC-3ED6-406B-9E5F-A9078356BE99",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 86
- testRunner.And("I upload this file for processing", ((string)(null)), table42, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table60, "And ");
#line hidden
#line 90
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 1 t" +
@@ -516,46 +516,46 @@ public virtual void ProcessVoucherFileWith2DetailRows()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table43 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table61 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3",
"Column4"});
- table43.AddRow(new string[] {
+ table61.AddRow(new string[] {
"H",
"20210508",
"",
""});
- table43.AddRow(new string[] {
+ table61.AddRow(new string[] {
"D",
"Hospital 1",
"07777777775",
"10"});
- table43.AddRow(new string[] {
+ table61.AddRow(new string[] {
"D",
"Hospital 1",
"testrecipient1@recipient.com",
"10"});
- table43.AddRow(new string[] {
+ table61.AddRow(new string[] {
"T",
"1",
"",
""});
#line 94
- testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table43, "Given ");
+ testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table61, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table44 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table62 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table44.AddRow(new string[] {
+ table62.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"8806EDBC-3ED6-406B-9E5F-A9078356BE99",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 100
- testRunner.And("I upload this file for processing", ((string)(null)), table44, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table62, "And ");
#line hidden
#line 104
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 2 t" +
@@ -596,87 +596,87 @@ public virtual void Process2VoucherFiles()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table45 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table63 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3",
"Column4"});
- table45.AddRow(new string[] {
+ table63.AddRow(new string[] {
"H",
"20210508",
"",
""});
- table45.AddRow(new string[] {
+ table63.AddRow(new string[] {
"D",
"Hospital 1",
"07777777775",
"10"});
- table45.AddRow(new string[] {
+ table63.AddRow(new string[] {
"D",
"Hospital 1",
"testrecipient1@recipient.com",
"10"});
- table45.AddRow(new string[] {
+ table63.AddRow(new string[] {
"T",
"1",
"",
""});
#line 107
- testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table45, "Given ");
+ testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table63, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table46 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table64 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table46.AddRow(new string[] {
+ table64.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"8806EDBC-3ED6-406B-9E5F-A9078356BE99",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 113
- testRunner.And("I upload this file for processing", ((string)(null)), table46, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table64, "And ");
#line hidden
- TechTalk.SpecFlow.Table table47 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table65 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3",
"Column4"});
- table47.AddRow(new string[] {
+ table65.AddRow(new string[] {
"H",
"20210508",
"",
""});
- table47.AddRow(new string[] {
+ table65.AddRow(new string[] {
"D",
"Hospital 1",
"07777777775",
"20"});
- table47.AddRow(new string[] {
+ table65.AddRow(new string[] {
"D",
"Hospital 1",
"testrecipient1@recipient.com",
"20"});
- table47.AddRow(new string[] {
+ table65.AddRow(new string[] {
"T",
"1",
"",
""});
#line 117
- testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table47, "Given ");
+ testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table65, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table48 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table66 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table48.AddRow(new string[] {
+ table66.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"8806EDBC-3ED6-406B-9E5F-A9078356BE99",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 123
- testRunner.And("I upload this file for processing", ((string)(null)), table48, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table66, "And ");
#line hidden
#line 127
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 4 t" +
@@ -719,82 +719,82 @@ public virtual void ProcessDuplicateVoucherTopupFileWith1DetailRow()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table49 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table67 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3",
"Column4"});
- table49.AddRow(new string[] {
+ table67.AddRow(new string[] {
"H",
"20210508",
"",
""});
- table49.AddRow(new string[] {
+ table67.AddRow(new string[] {
"D",
"Hospital 1",
"07777777775",
"10"});
- table49.AddRow(new string[] {
+ table67.AddRow(new string[] {
"T",
"1",
"",
""});
#line 131
- testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table49, "Given ");
+ testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table67, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table50 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table68 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table50.AddRow(new string[] {
+ table68.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"8806EDBC-3ED6-406B-9E5F-A9078356BE99",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 136
- testRunner.And("I upload this file for processing", ((string)(null)), table50, "And ");
+ testRunner.And("I upload this file for processing", ((string)(null)), table68, "And ");
#line hidden
#line 140
testRunner.When("As merchant \"Test Merchant 1\" on Estate \"Test Estate 1\" I get my transactions 1 t" +
"ransaction should be returned", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
- TechTalk.SpecFlow.Table table51 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table69 = new TechTalk.SpecFlow.Table(new string[] {
"Column1",
"Column2",
"Column3",
"Column4"});
- table51.AddRow(new string[] {
+ table69.AddRow(new string[] {
"H",
"20210508",
"",
""});
- table51.AddRow(new string[] {
+ table69.AddRow(new string[] {
"D",
"Hospital 1",
"07777777775",
"10"});
- table51.AddRow(new string[] {
+ table69.AddRow(new string[] {
"T",
"1",
"",
""});
#line 142
- testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table51, "Given ");
+ testRunner.Given("I have a voucher topup file with the following contents", ((string)(null)), table69, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table52 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table70 = new TechTalk.SpecFlow.Table(new string[] {
"EstateName",
"MerchantName",
"FileProfileId",
"UserId"});
- table52.AddRow(new string[] {
+ table70.AddRow(new string[] {
"Test Estate 1",
"Test Merchant 1",
"8806EDBC-3ED6-406B-9E5F-A9078356BE99",
"ABA59ABF-293D-4A6B-B81B-7007503C3476"});
#line 147
testRunner.And("I upload this file for processing an error should be returned indicating the file" +
- " is a duplicate", ((string)(null)), table52, "And ");
+ " is a duplicate", ((string)(null)), table70, "And ");
#line hidden
}
this.ScenarioCleanup();
diff --git a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSVFilesSteps.cs b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSVFilesSteps.cs
index 2628d73..32f9fec 100644
--- a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSVFilesSteps.cs
+++ b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSVFilesSteps.cs
@@ -82,7 +82,7 @@ public async Task WhenAsMerchantOnEstateIGetMyTransactionsTransactionShouldBeRet
var estate = this.TestingContext.GetEstateDetails(estateName);
Guid estateId = estate.EstateId;
var merchantId = estate.GetMerchantId(merchantName);
- String accessToken = estate.AccessToken;
+ String accessToken = this.TestingContext.AccessToken;
await Retry.For(async () =>
{
@@ -127,6 +127,7 @@ private async Task UploadFile(Table table)
{
Content = formData
};
+ request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", this.TestingContext.AccessToken);
var response = await client.SendAsync(request);
diff --git a/FileProcessor.IntegrationTests/FileProcessor.IntegrationTests.csproj b/FileProcessor.IntegrationTests/FileProcessor.IntegrationTests.csproj
index b1aedab..4f72e2b 100644
--- a/FileProcessor.IntegrationTests/FileProcessor.IntegrationTests.csproj
+++ b/FileProcessor.IntegrationTests/FileProcessor.IntegrationTests.csproj
@@ -17,7 +17,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
@@ -55,4 +55,8 @@
+
+
+
+
diff --git a/FileProcessor.Testing/TestData.cs b/FileProcessor.Testing/TestData.cs
index 608703a..aca0c76 100644
--- a/FileProcessor.Testing/TestData.cs
+++ b/FileProcessor.Testing/TestData.cs
@@ -5,6 +5,7 @@ namespace FileProcessor.Testing
using System.Collections.Generic;
using BusinessLogic.Managers;
using EstateManagement.DataTransferObjects.Responses;
+ using EstateReporting.Database.Entities;
using File.DomainEvents;
using FileImportLog.DomainEvents;
using FileAggregate;
@@ -13,6 +14,8 @@ namespace FileProcessor.Testing
using Newtonsoft.Json;
using SecurityService.DataTransferObjects.Responses;
using TransactionProcessor.DataTransferObjects;
+ using ContractProduct = EstateManagement.DataTransferObjects.Responses.ContractProduct;
+ using FileImportLog = EstateReporting.Database.Entities.FileImportLog;
public class TestData
{
@@ -142,6 +145,8 @@ public class TestData
public static String ContractProductWithNullValueDisplayText = "Custom";
public static Guid FileImportLogId = Guid.Parse("5F1149F8-0313-45E4-BE3A-3D7B07EEB414");
+ public static Guid FileImportLogId1 = Guid.Parse("7EF0D557-2148-4DED-83F5-2521E8422391");
+ public static Guid FileImportLogId2 = Guid.Parse("13931CB7-241A-472A-A8E9-213565BF2A2A");
public static DateTime ImportLogDateTime = new DateTime(2021,5,7);
@@ -425,5 +430,88 @@ public static List GetMerchantContractsResponseNoNullValueProd
public static String SafaricomFileFormatHandler = "SafaricomFileFormatHandler";
public static String VoucherFileFormatHandler = "VoucherFileFormatHandler";
+
+ public static DateTime ImportLogStartDate = new DateTime(2021,7,1);
+ public static DateTime ImportLogEndDate = new DateTime(2021,7,2);
+
+ public static List FileImportLogs =>
+ new List
+ {
+ TestData.FileImportLog1,
+ TestData.FileImportLog2
+ };
+
+
+ public static FileImportLog FileImportLog1 => new FileImportLog
+ {
+ FileImportLogId = TestData.FileImportLogId1,
+ ImportLogDateTime = TestData.ImportLogStartDate,
+ EstateId = TestData.EstateId
+ };
+
+ public static List FileImportLog1Files => new List
+ {
+ new FileImportLogFile
+ {
+ FileImportLogId = TestData.FileImportLogId1,
+ MerchantId = TestData.MerchantId,
+ EstateId = TestData.EstateId,
+ FileId = Guid.NewGuid(),
+ FilePath = "/home/txnproc/file1.csv",
+ FileProfileId = TestData.FileProfileId,
+ OriginalFileName = "Testfile1.csv",
+ UserId = TestData.UserId,
+ FileUploadedDateTime = TestData.FileUploadedDateTime
+ },
+ new FileImportLogFile
+ {
+ FileImportLogId = TestData.FileImportLogId1,
+ MerchantId = TestData.MerchantId,
+ EstateId = TestData.EstateId,
+ FileId = Guid.NewGuid(),
+ FilePath = "/home/txnproc/file2.csv",
+ FileProfileId = TestData.FileProfileId,
+ OriginalFileName = "Testfile2.csv",
+ UserId = TestData.UserId,
+ FileUploadedDateTime = TestData.FileUploadedDateTime
+ },
+
+ };
+
+ public static FileImportLog FileImportLog2 => new FileImportLog
+ {
+ FileImportLogId = TestData.FileImportLogId2,
+ ImportLogDateTime = TestData.ImportLogEndDate,
+ EstateId = TestData.EstateId
+ };
+
+ public static List FileImportLog2Files => new List
+ {
+ new FileImportLogFile
+ {
+ FileImportLogId = TestData.FileImportLogId2,
+ MerchantId = TestData.MerchantId,
+ EstateId = TestData.EstateId,
+ FileId = Guid.NewGuid(),
+ FilePath = "/home/txnproc/file3.csv",
+ FileProfileId = TestData.FileProfileId,
+ OriginalFileName = "Testfile3.csv",
+ UserId = TestData.UserId,
+ FileUploadedDateTime = TestData.FileUploadedDateTime
+ },
+ new FileImportLogFile
+ {
+ FileImportLogId = TestData.FileImportLogId2,
+ MerchantId = TestData.MerchantId,
+ EstateId = TestData.EstateId,
+ FileId = Guid.NewGuid(),
+ FilePath = "/home/txnproc/file4.csv",
+ FileProfileId = TestData.FileProfileId,
+ OriginalFileName = "Testfile4.csv",
+ UserId = TestData.UserId,
+ FileUploadedDateTime = TestData.FileUploadedDateTime
+ },
+
+ };
}
}
diff --git a/FileProcessor/Common/IModelFactory.cs b/FileProcessor/Common/IModelFactory.cs
new file mode 100644
index 0000000..20f393c
--- /dev/null
+++ b/FileProcessor/Common/IModelFactory.cs
@@ -0,0 +1,23 @@
+namespace FileProcessor.Common
+{
+ using System.Collections.Generic;
+ using DataTransferObjects.Responses;
+ using FileImportLog = FIleProcessor.Models.FileImportLog;
+
+ ///
+ ///
+ ///
+ public interface IModelFactory
+ {
+ #region Methods
+
+ ///
+ /// Converts from.
+ ///
+ /// The import logs.
+ ///
+ FileImportLogList ConvertFrom(List importLogs);
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FileProcessor/Common/ModelFactory.cs b/FileProcessor/Common/ModelFactory.cs
new file mode 100644
index 0000000..0e16d68
--- /dev/null
+++ b/FileProcessor/Common/ModelFactory.cs
@@ -0,0 +1,42 @@
+namespace FileProcessor.Common
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using DataTransferObjects.Responses;
+ using FileImportLog = FIleProcessor.Models.FileImportLog;
+
+ ///
+ ///
+ ///
+ ///
+ public class ModelFactory : IModelFactory
+ {
+ #region Methods
+
+ ///
+ /// Converts from.
+ ///
+ /// The import logs.
+ ///
+ public FileImportLogList ConvertFrom(List importLogs)
+ {
+ FileImportLogList result = new FileImportLogList();
+ result.FileImportLogs = new List();
+ foreach (FileImportLog fileImportLog in importLogs)
+ {
+ result.FileImportLogs.Add(new DataTransferObjects.Responses.FileImportLog
+ {
+ FileCount = fileImportLog.Files.Count(),
+ FileImportLogId = fileImportLog.FileImportLogId,
+ ImportLogDate = fileImportLog.FileImportLogDateTime.Date,
+ ImportLogDateTime = fileImportLog.FileImportLogDateTime,
+ ImportLogTime = fileImportLog.FileImportLogDateTime.TimeOfDay
+ });
+ }
+
+ return result;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FileProcessor/Controllers/FileController.cs b/FileProcessor/Controllers/FileController.cs
index d1f773a..78ab29b 100644
--- a/FileProcessor/Controllers/FileController.cs
+++ b/FileProcessor/Controllers/FileController.cs
@@ -10,6 +10,7 @@
using BusinessLogic.Managers;
using DataTransferObjects;
using MediatR;
+ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shared.General;
@@ -21,7 +22,7 @@
[ExcludeFromCodeCoverage]
[Route(FileController.ControllerRoute)]
[ApiController]
- //[Authorize]
+ [Authorize]
public class FileController : ControllerBase
{
#region Fields
diff --git a/FileProcessor/Controllers/FileImportLogController.cs b/FileProcessor/Controllers/FileImportLogController.cs
new file mode 100644
index 0000000..f5b497d
--- /dev/null
+++ b/FileProcessor/Controllers/FileImportLogController.cs
@@ -0,0 +1,94 @@
+namespace FileProcessor.Controllers
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using BusinessLogic.Managers;
+ using Common;
+ using FIleProcessor.Models;
+ using Microsoft.AspNetCore.Authorization;
+ using Microsoft.AspNetCore.Mvc;
+
+ ///
+ ///
+ ///
+ ///
+ [ExcludeFromCodeCoverage]
+ [Route(FileImportLogController.ControllerRoute)]
+ [ApiController]
+ [Authorize]
+ public class FileImportLogController : ControllerBase
+ {
+ #region Fields
+
+ ///
+ /// The manager
+ ///
+ private readonly IFileProcessorManager Manager;
+
+ ///
+ /// The model factory
+ ///
+ private readonly IModelFactory ModelFactory;
+
+ #endregion
+
+ #region Constructors
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The manager.
+ /// The model factory.
+ public FileImportLogController(IFileProcessorManager manager,
+ IModelFactory modelFactory)
+ {
+ this.Manager = manager;
+ this.ModelFactory = modelFactory;
+ }
+
+ #endregion
+
+ #region Methods
+
+ ///
+ /// Gets the import logs.
+ ///
+ /// The estate identifier.
+ /// The start date time.
+ /// The end date time.
+ /// The merchant identifier.
+ /// The cancellation token.
+ ///
+ [HttpGet]
+ [Route("{estateId}")]
+ public async Task GetImportLogs([FromRoute] Guid estateId,
+ [FromQuery] DateTime startDateTime,
+ [FromQuery] DateTime endDateTime,
+ [FromQuery] Guid? merchantId,
+ CancellationToken cancellationToken)
+ {
+ List fileImportLogs = await this.Manager.GetFileImportLogs(estateId, startDateTime, endDateTime, merchantId, cancellationToken);
+
+ return this.Ok(this.ModelFactory.ConvertFrom(fileImportLogs));
+ }
+
+ #endregion
+
+ #region Others
+
+ ///
+ /// The controller name
+ ///
+ public const String ControllerName = "fileImportLogs";
+
+ ///
+ /// The controller route
+ ///
+ private const String ControllerRoute = "api/" + FileImportLogController.ControllerName;
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/FileProcessor/Startup.cs b/FileProcessor/Startup.cs
index 301aafb..5d85fda 100644
--- a/FileProcessor/Startup.cs
+++ b/FileProcessor/Startup.cs
@@ -20,7 +20,9 @@ namespace FileProcessor
using BusinessLogic.Managers;
using BusinessLogic.RequestHandlers;
using BusinessLogic.Requests;
+ using Common;
using EstateManagement.Client;
+ using EstateReporting.Database;
using EventStore.Client;
using File.DomainEvents;
using FileImportLog.DomainEvents;
@@ -36,6 +38,7 @@ namespace FileProcessor
using NLog.Extensions.Logging;
using SecurityService.Client;
using Shared.DomainDrivenDesign.EventSourcing;
+ using Shared.EntityFramework;
using Shared.EntityFramework.ConnectionStringConfiguration;
using Shared.EventStore.Aggregate;
using Shared.EventStore.EventHandling;
@@ -134,8 +137,12 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton>(fileProfiles.ToList());
- services.AddTransient();
+ services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton, DbContextFactory>();
+ services.AddSingleton>(cont => (connectionString) => { return new EstateReportingContext(connectionString); });
Boolean useConnectionStringConfig = Boolean.Parse(ConfigurationReader.GetValue("AppSettings", "UseConnectionStringConfig"));
@@ -159,7 +166,7 @@ public void ConfigureServices(IServiceCollection services)
}
services.AddSingleton();
- services.AddTransient();
+ services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
diff --git a/FileProcessor/appsettings.json b/FileProcessor/appsettings.json
index b6ba6e2..bf67fc2 100644
--- a/FileProcessor/appsettings.json
+++ b/FileProcessor/appsettings.json
@@ -21,6 +21,10 @@
"ApiName": "fileProcessor",
"Authority": "https://192.168.1.133:5001"
},
+ "ConnectionStrings": {
+ "EstateReportingReadModel": "server=192.168.1.133;user id=sa;password=Sc0tland;database=EstateReportingReadModel",
+ "HealthCheck": "server=192.168.1.133;user id=sa;password=Sc0tland;database=master"
+ },
"AppSettings": {
"FileProfilePollingWindowInSeconds": 20,
"SubscriptionFilter": "FileProcessor",