Template
chore: deploy initial code base
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Models
|
||||
{
|
||||
public class ConfigurationInfo
|
||||
{
|
||||
public Guid ConfigurationGuid { get; set; }
|
||||
public string Name { get; set; }
|
||||
public byte DisplayOrder { get; set; }
|
||||
public Guid ServiceLineDimensionGuid { get; set; }
|
||||
[JsonPropertyName("entityIdsCSV")]
|
||||
public string EntityIdsCsv { get; set; }
|
||||
public bool IsUsingIndirectCost { get; set; }
|
||||
public string DepartmentRollupGlobalId { get; set; }
|
||||
public bool IsUsingCustomEntityDimension => !string.IsNullOrEmpty(DepartmentRollupGlobalId);
|
||||
[JsonPropertyName("customEntityIdsCSV")]
|
||||
public string CustomEntityIdsCsv { get; set; }
|
||||
[JsonPropertyName("fiscalYearID")]
|
||||
public short FiscalYearId { get; set; }
|
||||
public DateTime OrgDefinedEndDate { get; set; }
|
||||
public DateTime OrgDefinedTrackingCurrentMonth { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
using Riok.Mapperly.Abstractions;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Models
|
||||
{
|
||||
[Mapper(UseDeepCloning = true, EnumMappingStrategy = EnumMappingStrategy.ByName, EnumMappingIgnoreCase = true)]
|
||||
public static partial class MapperlyConfigurationInfo
|
||||
{
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.ConfiguredEntityIds))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.FiscalMonthResolver))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.LastFiscalYearEndDate))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.LastFiscalYearStartDate))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.OrgDefinedTrackingEndDate))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.OrgDefinedTrackingStartDate))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.QualityVariationEndDate))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.QualityVariationIsUsingAPRDRG))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.QVIOpportunityBreakdown))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.QVIOpportunityBreakdownEnum))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.QVIOpportunityBreakdownName))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.QVIOpportunityBreakdownNamePlural))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.VariationEndDate))]
|
||||
[MapperIgnoreSource(nameof(Biz.Configuration.Configuration.VariationTrackingCurrentMonth))]
|
||||
[MapProperty(nameof(Biz.Configuration.Configuration.EntityIdsCSV), nameof(ConfigurationInfo.EntityIdsCsv))]
|
||||
[MapProperty(nameof(Biz.Configuration.Configuration.CustomEntityIdsCSV), nameof(ConfigurationInfo.CustomEntityIdsCsv))]
|
||||
[MapProperty(nameof(Biz.Configuration.Configuration.FiscalYearID), nameof(ConfigurationInfo.FiscalYearId))]
|
||||
public static partial ConfigurationInfo Mapped(this Biz.Configuration.Configuration src);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Setup;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Tests;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
[SetUpFixture]
|
||||
public class ClientIntegrationTestFixture
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public virtual async Task SetDbContextAndServices()
|
||||
{
|
||||
#if DEBUG
|
||||
//When running locally sets the profile to the CI profile so you have access to resources
|
||||
Environment.SetEnvironmentVariable("AWS_Profile", "sdt-continuous-improvement-service-role");
|
||||
#endif
|
||||
var clientService = new ClientServiceBase();
|
||||
await clientService.ClientValidation();
|
||||
var services = ServiceCollectionFactory.Create();
|
||||
await services.SetupServiceProperties(clientService.StrataId);
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public async Task TearDown()
|
||||
{
|
||||
try
|
||||
{
|
||||
var centralDbContext = ServiceProperties.CentralDbContext as CentralDbContext;
|
||||
if (centralDbContext == null) { return; }
|
||||
_ = await centralDbContext.Database.EnsureDeletedAsync(CancellationToken.None);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Strata.ApiLib.Core.Cors.Extensions;
|
||||
using Strata.ApiLib.Core.StrataAuthentication.Bootstrappers;
|
||||
using Strata.Configuration.Client.DependencyInjection.ConsoleApps;
|
||||
using Strata.ContinuousImprovement.Biz.Configurations;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Setup
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class ServiceCollectionFactory
|
||||
{
|
||||
// dev master
|
||||
private static readonly Guid DevMasterDatabase = new("54409f55-5ddf-4748-8222-9ccfb04fb4f5");
|
||||
private static readonly Guid SeleniumAutomationDatabase = new("6bcd9090-3446-4cc1-b1aa-38afae76a1c6");
|
||||
private static readonly Guid SeleniumAutomationRefreshed4Master = new("feb7a099-8b2a-436c-9aba-0f853c8c60c9");
|
||||
private static readonly string IntegrationTesting = $"ci_client_{DateTime.Now:yyyyMMdd}_{Guid.NewGuid():N}";
|
||||
|
||||
public static IServiceCollection Create()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
var jazzDbGuid = Debugger.IsAttached ? SeleniumAutomationRefreshed4Master : SeleniumAutomationDatabase;
|
||||
// for now, though
|
||||
jazzDbGuid = DevMasterDatabase;
|
||||
try
|
||||
{
|
||||
var configuration = StrataConfigurationFactory.GetConfiguration();
|
||||
services.AddSingleton(configuration);
|
||||
services.AddStrataAuthentication(configuration);
|
||||
services.AddStrataCors(configuration);
|
||||
services.AddContinuousImprovementServices(configuration, IntegrationTesting);
|
||||
services.AddAsyncDbContextFactory<JazzDbContext>(options =>
|
||||
{
|
||||
options
|
||||
.WithConnectionString((provider, token) => provider.GetConnectionStringFromSmc(jazzDbGuid, token))
|
||||
.WithDbContextOptions((connectionString, provider, builder) =>
|
||||
builder.UseSqlServer(connectionString, options => { options.CommandTimeout(300); }));
|
||||
});
|
||||
services.AddLogging();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using Strata.Analytics.Client;
|
||||
using Strata.Analytics.Models.Workbooks;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts.Snowflake;
|
||||
using Strata.ContinuousImprovement.Biz.Generics;
|
||||
using Strata.ContinuousImprovement.Biz.OpportunityTypeWorkbooks;
|
||||
using Strata.ContinuousImprovement.Biz.OpportunityWorkbooks;
|
||||
using Strata.ContinuousImprovement.JazzEntityFrameworkStub;
|
||||
using Strata.SqlTools.Configuration.Common.AsyncFactory;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Setup
|
||||
{
|
||||
public static class ServiceProperties
|
||||
{
|
||||
// dev master
|
||||
internal static readonly Guid DatabaseGuid = new("54409f55-5ddf-4748-8222-9ccfb04fb4f5");
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
||||
public static IContinuousImprovementService ContinuousImprovementService { get; set; }
|
||||
public static ICentralDbContext CentralDbContext { get; set; }
|
||||
public static JazzEntityFrameworkFactory JazzConnBuilderFactory { get; set; }
|
||||
public static IJazzDbContext JazzDbContext { get; set; }
|
||||
public static ISnowflakeDatabaseContext SnowflakeDatabaseContext { get; set; }
|
||||
public static IServiceCollection Services { get; set; }
|
||||
public static IServiceProvider ServiceProvider { get; set; }
|
||||
public static IAnalyticsService AnalyticsService { get; set; }
|
||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
||||
|
||||
private static int WorkbookId = 9;
|
||||
|
||||
public static async Task SetupServiceProperties(this IServiceCollection services, int strataId = 0)
|
||||
{
|
||||
Services = services;
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
ServiceProvider = serviceProvider;
|
||||
|
||||
try
|
||||
{
|
||||
var sfConnBuilderFactory = serviceProvider.GetRequiredService<ISnowflakeDatabaseContextFactory>();
|
||||
SnowflakeDatabaseContext = sfConnBuilderFactory.Create($"{DatabaseGuid:N}");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ILB
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var jazzConnBuilderFactory = serviceProvider.GetRequiredService<IAsyncDbContextFactory<JazzDbContext>>();
|
||||
JazzDbContext = await jazzConnBuilderFactory.CreateDbContextAsync(CancellationToken.None);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ILB
|
||||
}
|
||||
|
||||
await BuildPostgresDb(strataId);
|
||||
|
||||
BuildAnalyticsService(strataId);
|
||||
}
|
||||
|
||||
private static async Task BuildPostgresDb(int strataId)
|
||||
{
|
||||
try
|
||||
{
|
||||
CentralDbContext = ServiceProvider.GetService<CentralDbContext>() as CentralDbContext
|
||||
?? throw new NullReferenceException(nameof(CentralDbContext));
|
||||
var centralDbContext = CentralDbContext as CentralDbContext;
|
||||
if (centralDbContext == null) { throw new NullReferenceException(nameof(centralDbContext)); }
|
||||
|
||||
await centralDbContext.Database.MigrateAsync(CancellationToken.None);
|
||||
JazzConnBuilderFactory = new JazzEntityFrameworkFactory();
|
||||
await JazzConnBuilderFactory.EnsureCreatedAsync(centralDbContext, JazzDbContext, CancellationToken.None);
|
||||
var workbook = new OpportunityWorkbook
|
||||
{
|
||||
StrataId = strataId,
|
||||
WorkbookId = WorkbookId,
|
||||
OpportunityGuid = Guid.NewGuid(),
|
||||
Name = "Test",
|
||||
};
|
||||
Assert.That(centralDbContext, Is.Not.Null);
|
||||
await centralDbContext.OpportunityWorkbooks.AddAsync(workbook, CancellationToken.None);
|
||||
|
||||
var oppTypeWorkbook = new OpportunityTypeWorkbook
|
||||
{
|
||||
StrataId = strataId,
|
||||
WorkbookId = WorkbookId,
|
||||
OpportunityType = (int)OpportunityTypes.ChargeCode,
|
||||
Name = "Test",
|
||||
};
|
||||
Assert.That(centralDbContext, Is.Not.Null);
|
||||
await centralDbContext.OpportunityTypeWorkbooks.AddAsync(oppTypeWorkbook, CancellationToken.None);
|
||||
|
||||
await centralDbContext.SaveChangesAsync(CancellationToken.None);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void BuildAnalyticsService(int strataId)
|
||||
{
|
||||
var analyticsService = Mock.Of<IAnalyticsService>();
|
||||
var workbook = new Workbook
|
||||
{
|
||||
Name = "Test",
|
||||
WorkbookId = WorkbookId,
|
||||
IsHidden = false,
|
||||
StrataId = strataId,
|
||||
};
|
||||
var workbooks = new List<Workbook> { workbook };
|
||||
workbooks.AddRange(Enumerable.Range(1, 1000).Where(i => i != WorkbookId).Select(i => new Workbook
|
||||
{
|
||||
Name = $"Test {i}",
|
||||
WorkbookId = i,
|
||||
IsHidden = (i % 2 == 0),
|
||||
StrataId = (i % 3 == 0) ? 9 : strataId,
|
||||
}));
|
||||
//GetWorkbooksAsync
|
||||
Mock.Get(analyticsService)
|
||||
.Setup(s => s.GetWorkbookAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
||||
.Returns<int, CancellationToken>((id, token)
|
||||
=> Task.FromResult(id == WorkbookId ? workbook : null));
|
||||
Mock.Get(analyticsService)
|
||||
.Setup(s => s.GetWorkbooksAsync(It.IsAny<bool>(), It.IsAny<CancellationToken>()))
|
||||
.Returns<bool, CancellationToken>((isHidden, token)
|
||||
=> Task.FromResult(workbooks.Where(w => w.IsHidden == isHidden)));
|
||||
AnalyticsService = analyticsService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Setup
|
||||
{
|
||||
public class VaultResponse
|
||||
{
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.400.36" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||
<PackageReference Include="NUnit" Version="4.3.2" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.7.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
|
||||
<PackageReference Include="Strata.ApiLib.Core" Version="8.4.1" />
|
||||
<PackageReference Include="Strata.Configuration.Client" Version="9.15.1" />
|
||||
<PackageReference Include="Strata.SnowflakeLib" Version="4.3.0" />
|
||||
<PackageReference Include="Strata.SqlTools.EntityFramework" Version="6.0.3" />
|
||||
<PackageReference Include="Verify.NUnit" Version="29.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Strata.ContinuousImprovement.Biz\Strata.ContinuousImprovement.Biz.csproj" />
|
||||
<ProjectReference Include="..\..\src\Strata.DecisionSupport.Models\Strata.DecisionSupport.Models.csproj" />
|
||||
<ProjectReference Include="..\Strata.DecisionSupport.Biz.Test.Integration\Strata.DecisionSupport.Biz.Test.Integration.csproj" />
|
||||
<ProjectReference Include="..\Strata.ContinuousImprovement.JazzEntityFrameworkStub\Strata.ContinuousImprovement.JazzEntityFrameworkStub.csproj" />
|
||||
<ProjectReference Include="..\..\src\Strata.ContinuousImprovement.Client\Strata.ContinuousImprovement.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="NUnit.Framework" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using Strata.ContinuousImprovement.Biz.OpportunityTypeWorkbooks;
|
||||
using Strata.ContinuousImprovement.Biz.OpportunityWorkbooks;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Models;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Setup;
|
||||
using Strata.CoreLib.Claims;
|
||||
using Strata.CoreLib.Claims.Extensions;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Tests
|
||||
{
|
||||
public class ClientServiceBase
|
||||
{
|
||||
protected StrataTokenInfo StrataTokenInfo { get; set; }
|
||||
protected string AccessToken { get; set; }
|
||||
protected IEnumerable<Claim> Claims { get; set; }
|
||||
protected long ExpiresIn { get; set; }
|
||||
protected ClaimsIdentity ClaimsIdentity { get; set; }
|
||||
protected ClaimsPrincipal ClaimsPrincipal { get; set; }
|
||||
internal IClaimsPrincipalAccessor ClaimsPrincipalAccessor { get; set; }
|
||||
internal int StrataId { get; set; }
|
||||
internal Guid DatabaseGuid { get; set; }
|
||||
|
||||
protected readonly string BaseAddress = "https://continuousimprovement-api.dev.stratanetwork.net/";
|
||||
public IContinuousImprovementService ContinuousImprovementService { get; set; }
|
||||
public JazzDbContext JazzDbContext { get; set; }
|
||||
public CentralDbContext CentralDbContext { get; set; }
|
||||
public IOpportunityWorkbookService OpportunityWorkbookService { get; set; }
|
||||
#pragma warning disable NUnit1032 // An IDisposable field/property should be Disposed in a TearDown method
|
||||
public IServiceProvider ServiceProvider { get; set; }
|
||||
#pragma warning restore NUnit1032 // An IDisposable field/property should be Disposed in a TearDown method
|
||||
|
||||
public OpportunityWorkbook OpportunityWorkbook { get; set; }
|
||||
public OpportunityTypeWorkbook OpportunityTypeWorkbook { get; set; }
|
||||
|
||||
[OneTimeSetUp]
|
||||
public async Task TestSetup()
|
||||
{
|
||||
ServiceProvider = ServiceProperties.ServiceProvider;
|
||||
await ClientValidation();
|
||||
var httpClient = new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri(BaseAddress)
|
||||
};
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
|
||||
ContinuousImprovementService = new ContinuousImprovementService(httpClient);
|
||||
ServiceProperties.ContinuousImprovementService = ContinuousImprovementService;
|
||||
CentralDbContext = (CentralDbContext)ServiceProperties.CentralDbContext;
|
||||
JazzDbContext = (JazzDbContext)ServiceProperties.JazzDbContext;
|
||||
await ReplaceOpportunitWorkbookService();
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public async Task TestTearDown()
|
||||
{
|
||||
((ServiceProvider)ServiceProvider).Dispose();
|
||||
}
|
||||
|
||||
private async Task ReplaceOpportunitWorkbookService()
|
||||
{
|
||||
var claimsAccessor = Mock.Of<IClaimsPrincipalAccessor>();
|
||||
Mock.Get(claimsAccessor)
|
||||
.Setup(s => s.GetCurrentClaimsPrincipal())
|
||||
.Returns(ClaimsPrincipal);
|
||||
var analyticsService = ServiceProperties.AnalyticsService;
|
||||
OpportunityWorkbookService = new OpportunityWorkbookService(CentralDbContext, analyticsService, claimsAccessor, Mock.Of<ILogger<OpportunityWorkbookService>>());
|
||||
var services = ServiceProperties.Services;
|
||||
var descriptor = services.FirstOrDefault(d => d.ServiceType == typeof(IOpportunityWorkbookService));
|
||||
if (descriptor != null)
|
||||
{
|
||||
services.Remove(descriptor);
|
||||
services.AddScoped<IOpportunityWorkbookService, OpportunityWorkbookService>();
|
||||
ServiceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
OpportunityWorkbook = await CentralDbContext.OpportunityWorkbooks.FirstOrDefaultAsync(CancellationToken.None);
|
||||
OpportunityTypeWorkbook = await CentralDbContext.OpportunityTypeWorkbooks.FirstOrDefaultAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
#region Client Claims Validation
|
||||
|
||||
public async Task<string> ClientValidation()
|
||||
{
|
||||
var UserInfo = new
|
||||
{
|
||||
vaultUserName = "ccicostleader", // vault ccicostleader is same as jazz ccicostleader
|
||||
userName = "ccicostleader",
|
||||
fullName = "Administrator, CCI"
|
||||
};
|
||||
var vaultPassword = await GetUserPassword(UserInfo.vaultUserName);
|
||||
var bearerToken = await GetBearerToken(UserInfo.userName, vaultPassword);
|
||||
ClaimsIdentity = new ClaimsIdentity(Claims);
|
||||
ClaimsPrincipal = new ClaimsPrincipal(ClaimsIdentity);
|
||||
StrataId = ClaimsPrincipal.GetStrataId();
|
||||
DatabaseGuid = ClaimsPrincipal.GetDatabaseGuid();
|
||||
BuildClaimsPrincipalAccessor();
|
||||
return bearerToken;
|
||||
}
|
||||
|
||||
internal async Task<string> GetUserPassword(string vaultUserName)
|
||||
{
|
||||
var client = new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri("https://vault.sdt.local/")
|
||||
};
|
||||
client.DefaultRequestHeaders.Add("apiKey", "a69d2e478c3f5b395b687ecdf34a3239");
|
||||
client.DefaultRequestHeaders.Add("ignoreHTTPSErrors", "true");
|
||||
var vaultResponse = await client.GetAsync($"api/searchpasswords/122?title={vaultUserName}");
|
||||
vaultResponse.EnsureSuccessStatusCode();
|
||||
string responseString = await vaultResponse.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrEmpty(responseString)) { return string.Empty; }
|
||||
var jsonResponse = JsonSerializer.Deserialize<IEnumerable<VaultResponse>>(responseString);
|
||||
if (jsonResponse == null) { return string.Empty; }
|
||||
var vaultUserInfo = jsonResponse.First();
|
||||
client.Dispose();
|
||||
return vaultUserInfo.Password;
|
||||
}
|
||||
|
||||
internal async Task<string> GetBearerToken(string userName, string password)
|
||||
{
|
||||
var form = BuildTokenRequest(userName, password);
|
||||
var client = new HttpClient();
|
||||
var response = await client.PostAsync("https://identity.dev.stratanetwork.net/connect/token", form);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrEmpty(responseString)) { return string.Empty; }
|
||||
var strataTokenInfo = JsonSerializer.Deserialize<StrataTokenInfo>(responseString);
|
||||
if (strataTokenInfo == null) { return string.Empty; }
|
||||
StrataTokenInfo = strataTokenInfo;
|
||||
AccessToken = strataTokenInfo.AccessToken;
|
||||
ExpiresIn = strataTokenInfo.ExpiresIn;
|
||||
var handler = new JwtSecurityTokenHandler();
|
||||
var jwtToken = handler.ReadJwtToken(AccessToken);
|
||||
Claims = jwtToken.Claims;
|
||||
client.Dispose();
|
||||
return AccessToken;
|
||||
}
|
||||
|
||||
internal FormUrlEncodedContent BuildTokenRequest(string userName, string password)
|
||||
{
|
||||
var form = new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("database_guid", ServiceProperties.DatabaseGuid.ToString()),
|
||||
new KeyValuePair<string, string>("grant_type", "password"),
|
||||
new KeyValuePair<string, string>("username", userName),
|
||||
new KeyValuePair<string, string>("password", password),
|
||||
new KeyValuePair<string, string>("scope", "strata.api.external offline_access"),
|
||||
new KeyValuePair<string, string>("client_id", "IntegrationTest"),
|
||||
new KeyValuePair<string, string>("client_secret", "UhAEQsGByTCrwPdHPLmaet_DmLEfcJVbZqGBxArdeRup_TPLrYKNpUNRHejjdnhd")
|
||||
]);
|
||||
return form;
|
||||
}
|
||||
|
||||
internal void BuildClaimsPrincipalAccessor()
|
||||
{
|
||||
var claimsAccessor = Mock.Of<IClaimsPrincipalAccessor>();
|
||||
Mock.Get(claimsAccessor)
|
||||
.Setup(s => s.GetCurrentClaimsPrincipal())
|
||||
.Returns(ClaimsPrincipal);
|
||||
ClaimsPrincipalAccessor = claimsAccessor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
protected async Task<IEnumerable<ConfigurationInfo>> GetConfigurationsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var configurations = await JazzDbContext.Configurations.ToListAsync(cancellationToken);
|
||||
return configurations.Select(c => c.Mapped());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Tests
|
||||
{
|
||||
public class StrataTokenInfo
|
||||
{
|
||||
[JsonPropertyName("access_token")]
|
||||
public required string AccessToken { get; set; }
|
||||
[JsonPropertyName("token_type")]
|
||||
public required string TokenType { get; set; }
|
||||
[JsonPropertyName("expires_in")]
|
||||
public required long ExpiresIn { get; set; }
|
||||
[JsonPropertyName("refresh_token")]
|
||||
public required string RefreshToken { get; set; }
|
||||
}
|
||||
}
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using Strata.ContinuousImprovement.Biz.Generics;
|
||||
using Strata.ContinuousImprovement.Biz.OpportunityWorkbooks;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Models;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Setup;
|
||||
using Strata.DecisionSupport.Biz.Utilities;
|
||||
using Strata.DecisionSupport.Models.Jazz;
|
||||
using Strata.DecisionSupport.Models.Queries;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Tests
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
[TestFixture(Category = "Integration")]
|
||||
public class TestContinuousImprovementClient : ClientServiceBase
|
||||
{
|
||||
private const string MSDRGCaseTypeFamilyIdQuery = @"select ctf.casetypefamilyid Value
|
||||
FROM dss.CaseTypeFamily ctf
|
||||
WHERE ctf.Name = 'Acute Kidney Failure'
|
||||
AND EXISTS (SELECT TOP (1) 1 FROM dss.CaseTypeFamilyMappingICD10 msdrg WHERE msdrg.CaseTypeFamilyID = ctf.CaseTypeFamilyID)";
|
||||
private const string APRDRGCaseTypeFamilyIdQuery = @"SELECT ctf.CaseTypeFamilyID Value
|
||||
FROM dss.CaseTypeFamily ctf
|
||||
WHERE ctf.Name = 'Acute Kidney Injury'
|
||||
AND EXISTS(SELECT TOP (1) 1 FROM dss.CaseTypeFamilyMappingAPRDRG aprdrg WHERE aprdrg.CaseTypeFamilyID = ctf.CaseTypeFamilyID)";
|
||||
private const string CptCodeCaseTypeFamilyIdQuery = @"SELECT ctf.CaseTypeFamilyID Value
|
||||
FROM dss.CaseTypeFamily ctf
|
||||
WHERE ctf.Name = 'Acupuncture Procedures'
|
||||
AND EXISTS(SELECT TOP (1) 1 FROM dss.CaseTypeFamilyMappingCPT cpt WHERE cpt.CaseTypeFamilyID = ctf.CaseTypeFamilyID)";
|
||||
private const string PatientPopClinicalIndicatorIdQuery = @"SELECT ci.ClinicalIndicatorID Value
|
||||
FROM dss.CaseTypeFamily ctf
|
||||
INNER JOIN dss.DimCaseType ct ON ct.CaseTypeFamilyID = ctf.CaseTypeFamilyID
|
||||
INNER JOIN dss.DimClinicalIndicator ci ON ci.ClinicalIndicatorID = ct.ClinicalIndicatorID
|
||||
WHERE ct.CaseTypeCategory = 2
|
||||
AND ci.Name = 'BPCI Major Joint Replacement - Knee'";
|
||||
|
||||
[Test, Order(1)]
|
||||
public async Task TestGetConfigurations()
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
var configurations = await GetConfigurationsAsync(CancellationToken.None);
|
||||
|
||||
// assert
|
||||
Assert.That(configurations, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test, Order(1)]
|
||||
[Ignore("Test database needs to be rolled over to the new year")]
|
||||
public async Task TestGetDfltConfiguration()
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
var configurations = await GetConfigurationsAsync(CancellationToken.None);
|
||||
var dftlConfiguration = configurations.OrderBy(c => c.DisplayOrder).FirstOrDefault();
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(configurations, Is.Not.Empty);
|
||||
Assert.That(dftlConfiguration, Is.Not.Null);
|
||||
var expectedFiscalYearId = DateTime.Now.Year;
|
||||
Assert.That(dftlConfiguration.FiscalYearId, Is.InRange(expectedFiscalYearId - 1, expectedFiscalYearId), "Fiscal year configuration needs to be updated for the current year.");
|
||||
Assert.That(dftlConfiguration.OrgDefinedEndDate, Is.EqualTo(new DateTime(dftlConfiguration.FiscalYearId, 1, 1).AddDays(-1)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test, Order(1)]
|
||||
public async Task TestGetEntityConfiguration()
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
var configurations = await GetConfigurationsAsync(CancellationToken.None);
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).FirstOrDefault(c => c.EntityIdsCsv != "" && !c.IsUsingCustomEntityDimension);
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(configurations, Is.Not.Empty);
|
||||
Assert.That(configuration, Is.Not.Null);
|
||||
Assert.That(configuration.IsUsingCustomEntityDimension, Is.False);
|
||||
Assert.That(configuration.EntityIdsCsv, Is.Not.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestDecisionSupportMsdrgEncounterInfo()
|
||||
{
|
||||
// arrange
|
||||
var configurations = await GetConfigurationsAsync(CancellationToken.None);
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).First(c => c.EntityIdsCsv != "" && !c.IsUsingCustomEntityDimension);
|
||||
var entityIdValues = configuration.EntityIdsCsv?.Split(',') ?? [];
|
||||
if (entityIdValues.IsEmpty())
|
||||
{
|
||||
entityIdValues = configuration.CustomEntityIdsCsv?.Split(',') ?? ["2"];
|
||||
}
|
||||
var entityIds = entityIdValues.Select(entityId => int.TryParse(entityId, out var r) ? r : 0).Distinct();
|
||||
var caseTypeFamilyId = await GetCaseTypeFamilyId(MSDRGCaseTypeFamilyIdQuery, CancellationToken.None);
|
||||
var encounterInfo = EncounterInfo(CaseTypeCategory.MSDRG, caseTypeFamilyId, configuration, entityIds);
|
||||
|
||||
// act
|
||||
var result = Enumerable.Empty<MSDRGEncounterInfo>();
|
||||
Assert.DoesNotThrowAsync(async () =>
|
||||
result = await ContinuousImprovementService.DecisionSupportMsdrgEncounterInfo(encounterInfo, CancellationToken.None));
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(result, Is.AssignableTo<IEnumerable<MSDRGEncounterInfo>>());
|
||||
Assert.That(result, Is.Not.Null.And.Not.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestDecisionSupportAprdrgEncounterInfo()
|
||||
{
|
||||
// arrange
|
||||
var configurations = await GetConfigurationsAsync(CancellationToken.None);
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).First(c => c.EntityIdsCsv != "" && !c.IsUsingCustomEntityDimension);
|
||||
var entityIdValues = configuration.EntityIdsCsv?.Split(',') ?? [];
|
||||
if (entityIdValues.IsEmpty())
|
||||
{
|
||||
entityIdValues = configuration.CustomEntityIdsCsv?.Split(',') ?? ["2"];
|
||||
}
|
||||
var entityIds = entityIdValues.Select(entityId => int.TryParse(entityId, out var r) ? r : 0).Distinct();
|
||||
var caseTypeFamilyId = await GetCaseTypeFamilyId(APRDRGCaseTypeFamilyIdQuery, CancellationToken.None);
|
||||
var encounterInfo = EncounterInfo(CaseTypeCategory.APRDRG, caseTypeFamilyId, configuration, entityIds);
|
||||
|
||||
// act
|
||||
var result = Enumerable.Empty<APRDRGEncounterInfo>();
|
||||
Assert.DoesNotThrowAsync(async () =>
|
||||
result = await ContinuousImprovementService.DecisionSupportAprdrgEncounterInfo(encounterInfo, CancellationToken.None));
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(result, Is.AssignableTo<IEnumerable<APRDRGEncounterInfo>>());
|
||||
Assert.That(result, Is.Not.Null.And.Not.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestDecisionSupportCptCodeDrgEncounterInfo()
|
||||
{
|
||||
// arrange
|
||||
var configurations = await GetConfigurationsAsync(CancellationToken.None);
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).First(c => c.EntityIdsCsv != "" && !c.IsUsingCustomEntityDimension);
|
||||
var entityIdValues = configuration.EntityIdsCsv?.Split(',') ?? [];
|
||||
if (entityIdValues.IsEmpty())
|
||||
{
|
||||
entityIdValues = configuration.CustomEntityIdsCsv?.Split(',') ?? ["2"];
|
||||
}
|
||||
var entityIds = entityIdValues.Select(entityId => int.TryParse(entityId, out var r) ? r : 0).Distinct();
|
||||
var caseTypeFamilyId = await GetCaseTypeFamilyId(CptCodeCaseTypeFamilyIdQuery, CancellationToken.None);
|
||||
var encounterInfo = EncounterInfo(CaseTypeCategory.CPTCode, caseTypeFamilyId, configuration, entityIds);
|
||||
|
||||
// act
|
||||
var result = Enumerable.Empty<CPTCodeEncounterInfo>();
|
||||
Assert.DoesNotThrowAsync(async () =>
|
||||
result = await ContinuousImprovementService.DecisionSupportCptCodeEncounterInfo(encounterInfo, CancellationToken.None));
|
||||
|
||||
// assert
|
||||
Assert.That(result, Is.AssignableTo<IEnumerable<CPTCodeEncounterInfo>>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestDecisionSupportPatientPopulationEncounterInfo()
|
||||
{
|
||||
// arrange
|
||||
var configurations = await GetConfigurationsAsync(CancellationToken.None);
|
||||
var configuration = configurations.OrderBy(c => c.DisplayOrder).First(c => c.EntityIdsCsv != "" && !c.IsUsingCustomEntityDimension);
|
||||
var entityIdValues = configuration.EntityIdsCsv?.Split(',') ?? [];
|
||||
if (entityIdValues.IsEmpty())
|
||||
{
|
||||
entityIdValues = configuration.CustomEntityIdsCsv?.Split(',') ?? ["2"];
|
||||
}
|
||||
var entityIds = entityIdValues.Select(entityId => int.TryParse(entityId, out var r) ? r : 0).Distinct();
|
||||
var clinicalIndicatorId = await GetCaseTypeFamilyId(PatientPopClinicalIndicatorIdQuery, CancellationToken.None);
|
||||
var encounterInfo = EncounterInfo(CaseTypeCategory.PatientPopulation, clinicalIndicatorId, configuration, entityIds);
|
||||
|
||||
// act
|
||||
var result = Enumerable.Empty<PatientPopulationEncounterInfo>();
|
||||
Assert.DoesNotThrowAsync(async () =>
|
||||
result = await ContinuousImprovementService.DecisionSupportPatientPopulationEncounterInfo(encounterInfo, CancellationToken.None));
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(result, Is.AssignableTo<IEnumerable<PatientPopulationEncounterInfo>>());
|
||||
Assert.That(result, Is.Not.Null.And.Not.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetAllWorkbooks()
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
var workbooks = await ContinuousImprovementService.GetAllWorkbooks(CancellationToken.None);
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
|
||||
Assert.That(workbooks, Is.AssignableTo<IEnumerable<WorkbookClientInfo>>());
|
||||
Assert.That(workbooks.Count, Is.GreaterThanOrEqualTo(1));
|
||||
var workbook = workbooks.FirstOrDefault();
|
||||
if (workbook == null) { return; }
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(OpportunityWorkbook.WorkbookId, Is.GreaterThan(0));
|
||||
Assert.That(OpportunityWorkbook.StrataId, Is.EqualTo(workbook.StrataId));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetOpportunityWorkbooks()
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
var workbooks = await ContinuousImprovementService.GetOpportunityWorkbooks(Guid.NewGuid(), CancellationToken.None);
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(workbooks, Is.AssignableTo<IEnumerable<OpportunityWorkbookClientInfo>>());
|
||||
Assert.That(workbooks.Count, Is.GreaterThanOrEqualTo(0));
|
||||
var workbook = workbooks.FirstOrDefault();
|
||||
if (workbook == null) { return; }
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(OpportunityWorkbook.WorkbookId, Is.GreaterThan(0));
|
||||
Assert.That(OpportunityWorkbook.StrataId, Is.EqualTo(workbook.StrataId));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetOpportunityTypeWorkbooks()
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
var workbooks = await ContinuousImprovementService.GetOpportunityTypeWorkbooks((int)OpportunityTypes.Encounter, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(workbooks, Is.AssignableTo<IEnumerable<OpportunityTypeWorkbookClientInfo>>());
|
||||
Assert.That(workbooks.Count, Is.GreaterThanOrEqualTo(0));
|
||||
var workbook = workbooks.FirstOrDefault();
|
||||
if (workbook == null) { return; }
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(OpportunityWorkbook.WorkbookId, Is.GreaterThan(0));
|
||||
Assert.That(OpportunityWorkbook.StrataId, Is.EqualTo(workbook.StrataId));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Test, Ignore("WIP")]
|
||||
public async Task TestCreateAndDeleteOpportunityWorkbooks()
|
||||
{
|
||||
// arrange
|
||||
var jazzDbContext = (JazzDbContext)ServiceProperties.JazzDbContext;
|
||||
var uvOpps = jazzDbContext.VariationOpportunities.Take(10).ToList();
|
||||
var opportunityWorkbooks = uvOpps.Select(uv => new OpportunityWorkbookClientInfo
|
||||
{
|
||||
Name = uv.OpportunityKey,
|
||||
OpportunityGuid = uv.OpportunityGuid,
|
||||
StrataId = StrataId,
|
||||
});
|
||||
|
||||
// act
|
||||
var workbooks = await ContinuousImprovementService.CreateOpportunityWorkbooks(opportunityWorkbooks, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(workbooks, Is.AssignableTo<IEnumerable<OpportunityWorkbookClientInfo>>());
|
||||
Assert.That(workbooks.Count, Is.GreaterThanOrEqualTo(0));
|
||||
var workbook = workbooks.FirstOrDefault();
|
||||
if (workbook == null) { return; }
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(OpportunityWorkbook.WorkbookId, Is.GreaterThan(0));
|
||||
Assert.That(OpportunityWorkbook.StrataId, Is.EqualTo(workbook.StrataId));
|
||||
});
|
||||
});
|
||||
|
||||
foreach (var workbook in workbooks)
|
||||
{
|
||||
// act
|
||||
var response = await ContinuousImprovementService.DeleteOpportunityWorkbook(workbook.OpportunityGuid, workbook.WorkbookId, CancellationToken.None);
|
||||
|
||||
//assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private async Task<int> GetCaseTypeFamilyId(string query, CancellationToken cancellationToken)
|
||||
=> await ((JazzDbContext)ServiceProperties.JazzDbContext).Database
|
||||
.SqlQueryRaw<int>(query)
|
||||
.SingleOrDefaultAsync(CancellationToken.None);
|
||||
|
||||
private EncounterQueryInfo EncounterInfo(CaseTypeCategory caseTypeCategory, int caseTypeFamilyId,
|
||||
ConfigurationInfo configuration,
|
||||
IEnumerable<int> entityIds)
|
||||
=> new EncounterQueryInfo
|
||||
{
|
||||
CaseTypeCategory = caseTypeCategory,
|
||||
CaseTypeFamilyId = caseTypeFamilyId,
|
||||
StartDate = configuration.OrgDefinedEndDate.AddDays(1).AddYears(-1),
|
||||
EndDate = configuration.OrgDefinedEndDate,
|
||||
DepartmentRollupGlobalId = "",
|
||||
ServiceLineGuid = configuration.ServiceLineDimensionGuid,
|
||||
EntityIDs = entityIds,
|
||||
ObservationUnitsDivisor = 0.5
|
||||
};
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts.Snowflake;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Setup;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Tests
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
[TestFixture(Category = "Integration")]
|
||||
public class TestFixtureSetup : ClientServiceBase
|
||||
{
|
||||
[Test]
|
||||
public async Task TestBearerToken()
|
||||
{
|
||||
var bearerToken = AccessToken;
|
||||
Assert.That(bearerToken, Is.Not.Null.And.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestCentralDbContext()
|
||||
{
|
||||
var centralDbContext = ServiceProperties.CentralDbContext as CentralDbContext;
|
||||
Assert.That(centralDbContext, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestJazzDbContext()
|
||||
{
|
||||
var jazzDbContext = ServiceProperties.JazzDbContext as JazzDbContext;
|
||||
Assert.That(jazzDbContext, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestSnowflakeDbContext()
|
||||
{
|
||||
var snowflakeDbContext = ServiceProperties.SnowflakeDatabaseContext as SnowflakeDatabaseContext;
|
||||
Assert.That(snowflakeDbContext, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestClientService()
|
||||
{
|
||||
var clientService = ContinuousImprovementService;
|
||||
Assert.That(clientService, Is.Not.Null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Strata.ContinuousImprovement.Biz.OpportunityWorkbooks;
|
||||
using Strata.ContinuousImprovement.Client.Test.Integration.Setup;
|
||||
using Strata.CoreLib.Claims;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Client.Test.Integration.Tests
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
[TestFixture(Category = "Integration")]
|
||||
public class TestValidateServiceConnection : ClientServiceBase
|
||||
{
|
||||
[Test]
|
||||
public async Task TestGetOpportunityWorkbooksAsync()
|
||||
{
|
||||
// arrange
|
||||
var claimsAccessor = Mock.Of<IClaimsPrincipalAccessor>();
|
||||
Mock.Get(claimsAccessor)
|
||||
.Setup(s => s.GetCurrentClaimsPrincipal())
|
||||
.Returns(ClaimsPrincipal);
|
||||
var analyticsService = ServiceProperties.AnalyticsService;
|
||||
var opportunityWorkbookService = new OpportunityWorkbookService(CentralDbContext, analyticsService, claimsAccessor, Mock.Of<ILogger<OpportunityWorkbookService>>());
|
||||
|
||||
// act
|
||||
var workbooks = await opportunityWorkbookService.GetOpportunityWorkbooksAsync(OpportunityWorkbook.OpportunityGuid, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
Assert.That(workbooks.Count, Is.GreaterThanOrEqualTo(1));
|
||||
var workbook = workbooks.First();
|
||||
|
||||
Assert.That(OpportunityWorkbook.WorkbookId, Is.EqualTo(workbook.WorkbookId));
|
||||
Assert.That(OpportunityWorkbook.StrataId, Is.EqualTo(workbook.StrataId));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user