Adding
This commit is contained in:
+126
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.DispatcherModels.Models;
|
||||
using LCU.Library.Internal.DispatcherModels.Enums;
|
||||
using LCU.Api.Internal.DispatcherSharedLib;
|
||||
using LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Library.Internal.LcuHttpClient;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.DispatcherIntegrationTests;
|
||||
|
||||
public class DispatcherRequestBuilderTest
|
||||
{
|
||||
private readonly IServiceCollection services;
|
||||
private readonly IRequestBuilderService _requestBuilder;
|
||||
private const string TestPath1 = "\\\\zeus\\DataIntegrationsQA\\Test_FileOperationsApi_Folder_1";
|
||||
private const string TestPath2 = "\\\\zeus\\DataIntegrationsQA\\Test_FileOperationsApi_Folder_1";
|
||||
|
||||
public DispatcherRequestBuilderTest()
|
||||
{
|
||||
services = new ServiceCollection();
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Path.Combine(AppContext.BaseDirectory))
|
||||
.AddJsonFile("appsettings.integration.json");
|
||||
var config = builder.Build();
|
||||
services.AddDispatcherServices(config);
|
||||
services.AddLCUHttpServices();
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
_requestBuilder = serviceProvider.GetService<IRequestBuilderService>();
|
||||
}
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
// !!!!!! In order to run these test you will need the following set up locally. !!!!!!
|
||||
// 1.) Local Dispatcher Database.
|
||||
// 2.) Local docker with Rabbit installed and running.
|
||||
// 3.) Local instance of Dispatcher Api running along with other apis being tested (eg. FileOperationsApi).
|
||||
// Which will also need to be using local Rabbit queues.
|
||||
// 4.) Can use the the following two locations on QA for file operation testing.
|
||||
// - \\zeus\DataIntegrationsQA\Test_FileOperationsApi_Folder_1
|
||||
// - \\zeus\DataIntegrationsQA\Test_FileOperationsApi_Folder_2
|
||||
// !!!!!! ---------------------------------------------------------------------- !!!!!!
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Can only be run locally.")]
|
||||
public async Task Test_CreateDirectory()
|
||||
{
|
||||
//Create Job
|
||||
var job = new JobDetails()
|
||||
{
|
||||
Name = "Test",
|
||||
RequestingApplication = "Dispatcher Integration Test",
|
||||
CreatedBy = "Dispatcher Integration Test",
|
||||
CreatedAt = DateTime.Now,
|
||||
NextRunTime = DateTime.Now
|
||||
};
|
||||
|
||||
_requestBuilder.CreateJob(job);
|
||||
|
||||
//Create WorkItem
|
||||
var createDirectoryRequest = new CreateDirectoryRequest()
|
||||
{
|
||||
DirectoryName = "FirstDispatcherIntegrationTest",
|
||||
DirectoryPath = TestPath1
|
||||
};
|
||||
|
||||
var workItemDetailsCreateDirectory = new WorkItemDetails()
|
||||
{
|
||||
Name = "Test",
|
||||
Order = 0
|
||||
};
|
||||
|
||||
_requestBuilder.AddWorkItem(createDirectoryRequest, workItemDetailsCreateDirectory, ActionType.CreateDirectory);
|
||||
|
||||
//Send
|
||||
var result = await _requestBuilder.SendDispatcherRequest();
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Can only be run locally.")]
|
||||
public async Task Test_RenameDirectory()
|
||||
{
|
||||
//Create Job
|
||||
var job = new JobDetails()
|
||||
{
|
||||
Name = "Test - Test_RenameDirectory",
|
||||
RequestingApplication = "Dispatcher Integration Test - Test_RenameDirectory Builder",
|
||||
CreatedBy = "Dispatcher Integration Test",
|
||||
CreatedAt = DateTime.Now,
|
||||
NextRunTime = DateTime.Now
|
||||
};
|
||||
|
||||
_requestBuilder.CreateJob(job);
|
||||
|
||||
//Create WorkItem
|
||||
var renameDirectoryRequest = new RenameDirectoryRequest()
|
||||
{
|
||||
SourceDirectoryName = "FirstDispatcherIntegrationTest",
|
||||
SourceDirectoryPath = TestPath1,
|
||||
NewDirectoryName = "RenameDispatcherIntegrationTest2"
|
||||
};
|
||||
|
||||
var workItemDetailsCreateDirectory = new WorkItemDetails()
|
||||
{
|
||||
Name = "Test - Test_RenameDirectory",
|
||||
Order = 0
|
||||
};
|
||||
|
||||
_requestBuilder.AddWorkItem(renameDirectoryRequest, workItemDetailsCreateDirectory, ActionType.RenameDirectory);
|
||||
|
||||
//Send
|
||||
var result = await _requestBuilder.SendDispatcherRequest();
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.integration.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.integration.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" Version="4.13.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LCU.Api.Internal.DispatcherLib\LCU.Api.Internal.DispatcherLib.csproj" />
|
||||
<ProjectReference Include="..\LCU.Api.Internal.DispatcherSharedLib\LCU.Api.Internal.DispatcherSharedLib.csproj" />
|
||||
<ProjectReference Include="..\LCU.Api.Internal.Dispatcher\LCU.Api.Internal.Dispatcher.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"LevelSwitches": { "$controlSwitch": "Information" },
|
||||
"MinimumLevel": {
|
||||
"ControlledBy": "$controlSwitch",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Seq",
|
||||
"Args": {
|
||||
"serverUrl": "https://qa-seq.lcu-internal.com",
|
||||
"apiKey": "VfIDjFsJC1zLalKeesnu",
|
||||
"controlLevelSwitch": "$controlSwitch"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||
"Properties": {
|
||||
"Application": "Dispatcher",
|
||||
"Environment": "Debug"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Primary": {
|
||||
"AttemptsLimit": 2,
|
||||
"SchedulersCronSchedule": "* * * * *",
|
||||
"Apis": {
|
||||
"FileOperationApi": {
|
||||
"MoveFile": "https://localhost:44385/api/FileOperations/MoveFile",
|
||||
"CopyFile": "https://localhost:44385/api/FileOperations/CopyFile",
|
||||
"RenameFile": "https://localhost:44385/api/FileOperations/RenameFile",
|
||||
"DeleteFile": "https://localhost:44385/api/FileOperations/DeleteFile",
|
||||
"ZipDirectory": "https://localhost:44385/api/FileOperations/ZipDirectory",
|
||||
"CreateDirectory": "https://localhost:44385/api/FileOperations/CreateDirectory",
|
||||
"RenameDirectory": "https://localhost:44385/api/FileOperations/RenameDirectory"
|
||||
},
|
||||
"FtpApi": {
|
||||
"SftpFile": "https://localhost:44383/api/Sftp"
|
||||
},
|
||||
"NotificationApi": {
|
||||
"Email": "http://localhost:54954/api/Email"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Connections": {
|
||||
"SQL": {
|
||||
"DispatcherDb": "data source=localhost;initial catalog=Dispatcher;Integrated Security=SSPI;MultipleActiveResultSets=True;App=EntityFramework"
|
||||
}
|
||||
},
|
||||
"DispatcherConfig": {
|
||||
"Url": "https://localhost:44380/api/QueueIngestion"
|
||||
},
|
||||
"DispatcherIngestionConsumer": {
|
||||
"QueueName": "LCU.Queue.Dispatcher.Ingestion",
|
||||
"ExchangeName": "LCU.Dispatcher.Direct",
|
||||
"Subject": "LCU.Queue.Dispatcher.Ingestion"
|
||||
},
|
||||
"ErroredDispatcherIngestionConsumer": {
|
||||
"QueueName": "LCU.Queue.Dispatcher.Ingestion.Errored",
|
||||
"ExchangeName": "LCU.Dispatcher.Direct",
|
||||
"Subject": "LCU.Queue.Dispatcher.Ingestion.Errored"
|
||||
},
|
||||
"DispatcherExecutionConsumer": {
|
||||
"QueueName": "LCU.Queue.Dispatcher.Execution",
|
||||
"ExchangeName": "LCU.Dispatcher.Direct",
|
||||
"Subject": "LCU.Queue.Dispatcher.Execution"
|
||||
},
|
||||
"DispatcherCompletionConsumer": {
|
||||
"QueueName": "LCU.Queue.Dispatcher.Completion",
|
||||
"ExchangeName": "LCU.Dispatcher.Direct",
|
||||
"Subject": "LCU.Queue.Dispatcher.Completion"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user