Skip to content

Commit

Permalink
Merge branch 'main' into feature/dp-590-press-continue-button-many-ti…
Browse files Browse the repository at this point in the history
…mes-issue
  • Loading branch information
JBaigGoaco committed Oct 7, 2024
2 parents 53325cd + b4f36f3 commit 4671f3b
Show file tree
Hide file tree
Showing 38 changed files with 1,269 additions and 693 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task OnGet_SetSupplierInformation()
_model.SupplierInformation.Should().Be(supplierInfo);
_model.SupplierInformation?.OperationTypes.Should().NotBeNull();
_model.SupplierInformation?.OperationTypes.Should().BeOfType<List<OperationType>>();
_model.SupplierInformation?.OperationTypes.Should().Contain(OperationType.SmallorMediumSized);
_model.SupplierInformation?.OperationTypes.Should().Contain(OperationType.SmallOrMediumSized);
_model.SupplierInformation?.OperationTypes.Should().Contain(OperationType.NonGovernmental);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static SupplierInformation CreateSupplierInformationClientModel(
return new SupplierInformation(
organisationName: "FakeOrg",
supplierType: SupplierType.Organisation,
operationTypes: new List<OperationType>() { OperationType.SmallorMediumSized, OperationType.NonGovernmental },
operationTypes: new List<OperationType>() { OperationType.SmallOrMediumSized, OperationType.NonGovernmental },
completedRegAddress: true,
completedPostalAddress: completedPostalAddress,
completedVat: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task OnPost_ValidModelState_ReturnsRedirectToSupplierBasicInformati
{
var id = Guid.NewGuid();
_model.Id = id;
_model.SelectedOperationTypes = new List<OperationType> { OperationType.SmallorMediumSized };
_model.SelectedOperationTypes = new List<OperationType> { OperationType.SmallOrMediumSized };

_organisationClientMock.Setup(client => client.GetOrganisationAsync(id))
.ReturnsAsync(SupplierDetailsFactory.GivenOrganisationClientModel(id));
Expand Down Expand Up @@ -89,7 +89,7 @@ public void ValidateModel_WithNoneAndOtherOperationTypes_ShouldReturnValidationE
SelectedOperationTypes = new List<OperationType>
{
OperationType.None,
OperationType.SmallorMediumSized
OperationType.SmallOrMediumSized
}
};

Expand Down
4 changes: 2 additions & 2 deletions Frontend/CO.CDP.OrganisationApp/Constants/OperationTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static string Description(this OperationType operationType)
{
return operationType switch
{
OperationType.SmallorMediumSized => "As a small or medium-sized enterprise",
OperationType.SmallOrMediumSized => "As a small or medium-sized enterprise",
OperationType.NonGovernmental => "As a non-governmental organisation that is value-driven and which principally reinvests its surpluses to further social, environmental or cultural objectives",
OperationType.SupportedEmploymentProvider => "As a supported employment provider",
OperationType.PublicService => "As a public service mutual",
Expand All @@ -22,7 +22,7 @@ public static string ShortDescription(this OperationType operationType)
{
return operationType switch
{
OperationType.SmallorMediumSized => "Small or medium-sized enterprise",
OperationType.SmallOrMediumSized => "Small or medium-sized enterprise",
OperationType.NonGovernmental => "Non-governmental organisation ",
OperationType.SupportedEmploymentProvider => "Supported employment provider",
OperationType.PublicService => "Public service mutual",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
var uploadFileHasError = ((TagBuilder)Html.ValidationMessageFor(m => m.UploadedFile)).HasInnerHtml;
var selectOptionHasError = ((TagBuilder)Html.ValidationMessageFor(m => m.HasValue)).HasInnerHtml;

void RenderHeading()
{
if (!string.IsNullOrWhiteSpace(Model.Heading))
{
<h1 class="govuk-heading-l">@Model.Heading</h1>
}
}

void RenderDescription()
{
if (!string.IsNullOrWhiteSpace(Model.Description))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
<div class="govuk-checkboxes" data-module="govuk-checkboxes">
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="chkSmallOrMediumAized"
name="SelectedOperationTypes" type="checkbox" value="@OperationType.SmallorMediumSized" @IsSelected(OperationType.SmallorMediumSized) />
name="SelectedOperationTypes" type="checkbox" value="@OperationType.SmallOrMediumSized" @IsSelected(OperationType.SmallOrMediumSized) />
<label class="govuk-label govuk-checkboxes__label" for="chkSmallOrMediumAized">
@OperationType.SmallorMediumSized.Description()
@OperationType.SmallOrMediumSized.Description()
</label>
</div>
<details class="govuk-details" data-module="govuk-details">
Expand Down
7 changes: 7 additions & 0 deletions Services/CO.CDP.DataSharing.WebApi.Tests/EntityFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ internal static List<ConnectedEntity> GetMockAdditionalEntities()
return mockEntities;
}

internal static IList<OperationType> GetOperationTypes()
{
var mockOperationType = new List<OperationType> { OperationType.SmallOrMediumSized };

return mockOperationType;
}

public static Organisation GivenOrganisation(
Guid? guid = null,
Tenant? tenant = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ public async Task ItReturnsMappedSupplierInformationWhenSharedConsentIsFound()

var mockAssociatedPersons = EntityFactory.GetMockAssociatedPersons();
var mockAdditionalEntities = EntityFactory.GetMockAdditionalEntities();
var mockOperationTypes = EntityFactory.GetOperationTypes();

_organisationRepository.Setup(repo => repo.GetConnectedIndividualTrusts(organisationId))
.ReturnsAsync(mockAssociatedPersons);

_organisationRepository.Setup(repo => repo.GetConnectedOrganisations(organisationId))
.ReturnsAsync(mockAdditionalEntities);

_organisationRepository.Setup(repo => repo.GetOperationTypes(organisationId))
.ReturnsAsync(mockOperationTypes);

return (shareCode, organisationId, organisationGuid, formId);
}

Expand Down Expand Up @@ -172,6 +176,10 @@ private void AssertRoles(IEnumerable<PartyRole>? roles)
private void AssertDetails(Details? details)
{
details.Should().NotBeNull();
details?.Scale.Should().Be("small");
details?.Vcse.Should().Be(false);
details?.ShelteredWorkshop.Should().Be(false);
details?.PublicServiceMissionOrganization.Should().Be(false);
}

private void AssertSupplierInformationData(SupplierInformationData? supplierInformationData)
Expand Down
4 changes: 4 additions & 0 deletions Services/CO.CDP.DataSharing.WebApi/Model/Details.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ namespace CO.CDP.DataSharing.WebApi.Model;
public class Details
{
public LegalForm? LegalForm { get; set; }
public string? Scale { get; set; }
public bool Vcse { get; set; }
public bool ShelteredWorkshop { get; set; }
public bool PublicServiceMissionOrganization { get; set; }
}

public record LegalForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ public class GetSharedDataUseCase(
private async Task<Details> GetDetails(SharedConsent sharedConsent)
{
var legalForm = await organisationRepository.GetLegalForm(sharedConsent.OrganisationId);
var operationTypes = await organisationRepository.GetOperationTypes(sharedConsent.OrganisationId);

return new Details
{
LegalForm = legalForm != null ? mapper.Map<LegalForm>(legalForm) : null
LegalForm = legalForm != null ? mapper.Map<LegalForm>(legalForm) : null,
Scale = operationTypes.Contains(OperationType.SmallOrMediumSized) ? "small" : "large",
Vcse = operationTypes.Contains(OperationType.NonGovernmental),
ShelteredWorkshop = operationTypes.Contains(OperationType.SupportedEmploymentProvider),
PublicServiceMissionOrganization = operationTypes.Contains(OperationType.PublicService)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,43 @@ public async Task GetConnectedOrganisations_WhenNoConnectedEntitiesExist_Returns
result.Should().BeEmpty();
}

[Fact]
public async Task GetOperationTypes_WhenNoOperationTypeExists_ReturnsNull()
{
using var repository = OrganisationRepository();

var organisation = GivenOrganisation();
organisation.SupplierInfo = GivenSupplierInformation();
organisation.SupplierInfo.OperationTypes = [];

using var context = postgreSql.OrganisationInformationContext();
await context.Organisations.AddAsync(organisation);
await context.SaveChangesAsync();

var result = await repository.GetOperationTypes(organisation.Id);

result.Should().BeEmpty();
}

[Fact]
public async Task GetOperationTypes_WhenOperationTypeExists_ReturnsEmptyList()
{
using var repository = OrganisationRepository();

var organisation = GivenOrganisation();
organisation.SupplierInfo = GivenSupplierInformation();
organisation.SupplierInfo.OperationTypes = [OperationType.SmallOrMediumSized];

using var context = postgreSql.OrganisationInformationContext();
await context.Organisations.AddAsync(organisation);
await context.SaveChangesAsync();

var result = await repository.GetOperationTypes(organisation.Id);

result.Should().NotBeNull();
result.Should().Contain(OperationType.SmallOrMediumSized);
}

private IOrganisationRepository OrganisationRepository()
{
return new DatabaseOrganisationRepository(postgreSql.OrganisationInformationContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ public async Task<IList<ConnectedEntity>> GetConnectedOrganisations(int organisa
return organisation?.SupplierInfo?.LegalForm;
}

public async Task<IList<OperationType>> GetOperationTypes(int organisationId)
{
var organisation = await context.Organisations
.Where(x => x.Id == organisationId)
.Include(x => x.SupplierInfo)
.FirstOrDefaultAsync();

return organisation?.SupplierInfo?.OperationTypes ?? [];
}

public void Save(Organisation organisation)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ public class DuplicateOrganisationException(string message, Exception? cause = n
public Task<IList<ConnectedEntity>> GetConnectedOrganisations(int organisationId);

public Task<Organisation.LegalForm?> GetLegalForm(int organisationId);

public Task<IList<OperationType>> GetOperationTypes(int organisationId);
}
2 changes: 1 addition & 1 deletion Services/CO.CDP.OrganisationInformation/OperationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CO.CDP.OrganisationInformation;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum OperationType
{
SmallorMediumSized = 1,
SmallOrMediumSized,
NonGovernmental,
SupportedEmploymentProvider,
PublicService,
Expand Down
6 changes: 6 additions & 0 deletions docs/diagrams/libraries/govUkNotify.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

govUkNotifyClient = component "Gov.uk Notify" {
technology "C# project"
description "Gov.uk Notify client"
tags "Shared Component"
}
6 changes: 6 additions & 0 deletions docs/diagrams/libraries/mq.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

mq = component "MQ" {
technology "C# project"
description "Message Queue client"
tags "Shared Component"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

organisationInformationPersisence = component "Organisation Information Persistence" {
technology "C# project"
description "Exposes the database model, queries, and persistence operations with EntityFramework Core"
tags "Shared Component"
}
File renamed without changes.
83 changes: 63 additions & 20 deletions docs/diagrams/workspace.dsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ workspace "Central Digital Platform" {
buyer = person "Buyer"
eSender = softwareSystem "eSender" "Commercial Software that Buyers use to manage tender processes"
oneLogin = softwareSystem "Gov.uk One Login" "Let users sign in and prove their identities to use your service"
govNotify = softwareSystem "Gov.uk Notify" "Sends emails, text messages and letters"
govUkNotify = softwareSystem "Gov.uk Notify" "Sends emails, text messages and letters"
companiesHouse = softwareSystem "Companies House" "Provides registered company details"
fts = softwareSystem "Find a Tender"
cfs = softwareSystem "Supplier Information and Contracts Finder"
Expand All @@ -21,10 +21,20 @@ workspace "Central Digital Platform" {
entityVerificationDatabase = container "Entity Verification Database" "" PostgreSQL Database {
}
entityVerification = container "Entity Verification" "" "Asp.Net Core" WebApi {
group "Libraries" {
!include "libraries/mq.dsl"
}
entityVerificationEndpoint = component "Entity Verification Endpoint" "Queries known identifers." "Asp.Net Core Web API"
entityVerificationUseCase = component "Use Case"
entityVerificationUseCase -> messageQueue "publishes to / listens to" "HTTPS"
-> entityVerificationDatabase "reads/writes" "SQL"
useCase = component "Use Case"
mqSubscriber = component "Message Subscriber"
persistence = component "Persistence" "EntityFramework Core model and repositories" "C# Namespace"
entityVerificationEndpoint -> useCase "Executes"
useCase -> persistence "Calls"
mqSubscriber -> persistence "Calls"
useCase -> mq "Calls"
mq -> messageQueue "publishes to / listens to" "HTTPS"
mq -> mqSubscriber "Calls"
persistence -> entityVerificationDatabase "reads/writes" "SQL"
}
}

Expand All @@ -35,48 +45,81 @@ workspace "Central Digital Platform" {
}

authority = container "Authority" "" "Asp.Net Core" WebApi {
group "Libraries" {
!include "libraries/organisationInformationPersistence.dsl"
}
openIdConfigurationEndpoint = component "OpenID Well-Known Configuration Endpoint" "Exposes OpenID configuration" "Asp.Net Core Web API"
openIdJwksConfigurationEndpoint = component "OpenID Well-Known JWKS Configuration Endpoint" "Exposes Json Web Key Set" "Asp.Net Core Web API"
tokenEndpoint = component "Token endpoint" "Exchanges a valid One Login token to a longer-lived token with additional claims." "Asp.Net Core Web API"
-> organisationInformationDatabase "reads/writes" "SQL"
tokenService = component "Token Service" "Creates and validates authentication tokens"
tokenEndpoint -> tokenService "Calls"
tokenService -> organisationInformationPersisence "Calls"
organisationInformationPersisence -> organisationInformationDatabase "reads/writes" "SQL"
}
tenantApi = container "Tenant API" "" "Asp.Net Core" WebApi {
group "Libraries" {
!include "libraries/organisationInformationPersistence.dsl"
}
tenantEndpoint = component "Tenant Endpoint" "" "Asp.Net Core Web API"
registerTenantUseCase = component "Register Tenant Use Case"
getTenantUseCase = component "Get Tenant Use Case"
tenantPersistence = component "Persistence" "" "Project"
tenantEndpoint -> registerTenantUseCase "Executes"
tenantEndpoint -> getTenantUseCase "Executes"
registerTenantUseCase -> tenantPersistence "Calls"
getTenantUseCase -> tenantPersistence "Calls"
tenantPersistence -> organisationInformationDatabase "reads/writes" "SQL"
useCase = component "Use Case"
tenantEndpoint -> useCase "Executes"
useCase -> organisationInformationPersisence "Calls"
organisationInformationPersisence -> organisationInformationDatabase "reads/writes" "SQL"
}
personApi = container "Person API" "" "Asp.Net Core" WebApi {
group "Libraries" {
!include "libraries/organisationInformationPersistence.dsl"
}
personEndpoint = component "Person Endpoint" "" "Asp.Net Core Web API"
-> organisationInformationDatabase "reads/writes" "SQL"
useCase = component "Use Case"
personEndpoint -> useCase "Executes"
useCase -> organisationInformationPersisence "Calls"
organisationInformationPersisence -> organisationInformationDatabase "reads/writes" "SQL"
}
organisationApi = container "Organisation API" "" "Asp.Net Core" WebApi {
group "Libraries" {
!include "libraries/organisationInformationPersistence.dsl"
!include "libraries/mq.dsl"
!include "libraries/govUkNotify.dsl"
}
organisationEndpoint = component "Organisation Endpoint" "" "Asp.Net Core Web API"
useCase = component "Use Case"
useCase -> messageQueue "publishes to / listens to" "HTTPS"
useCase -> govNotify "sends notifications with" "HTTPS"
-> organisationInformationDatabase "reads/writes" "SQL"
mqSubscriber = component "Message Subscriber"
organisationEndpoint -> useCase "Executes"
useCase -> organisationInformationPersisence "Calls"
useCase -> mq "Calls"
useCase -> govUkNotifyClient "Calls"
mqSubscriber -> organisationInformationPersisence "Calls"
organisationInformationPersisence -> organisationInformationDatabase "reads/writes" "SQL"
mq -> messageQueue "publishes to / listens to" "HTTPS"
mq -> mqSubscriber "Calls"
govUkNotifyClient -> govUkNotify "sends notifications with" "HTTPS"
}
formsApi = container "Forms API" "" "Asp.Net Core" WebApi {
group "Libraries" {
!include "libraries/organisationInformationPersistence.dsl"
}
formsEndpoint = component "Forms Endpoint" "" "Asp.Net Core Web API"
useCase = component "Use Case"
formsEndpoint -> useCase "Executes"
useCase -> fileStorage "writes to" "HTTPS"
-> organisationInformationDatabase "reads/writes" "SQL"
useCase -> organisationInformationPersisence "Calls"
organisationInformationPersisence -> organisationInformationDatabase "reads/writes" "SQL"
}
dataSharingApi = container "Data Sharing API" "" "Asp.Net Core" WebApi {
group "Libraries" {
!include "libraries/organisationInformationPersistence.dsl"
}
dataSharingEndpoint = component "Data Sharing Endpoint" "" "Asp.Net Core Web API"
useCase = component "Use Case"
dataSharingEndpoint -> useCase "Executes"
useCase -> fileStorage "writes to / reads from" "HTTPS"
-> organisationInformationDatabase "reads/writes" "SQL"
useCase -> organisationInformationPersisence "Calls"
organisationInformationPersisence -> organisationInformationDatabase "reads/writes" "SQL"
}
organisationApp = container "Organisation App" "Account & data capture frontend" "Asp.Net Core MVC" WebApp {
group "Libraries" {
!include "libraries.dsl"
!include "libraries/webApiClients.dsl"
}

mvcController = component "MVC Controller" "Enables web users to perform tasks." "Asp.Net Core MVC Controller"
Expand Down
Loading

0 comments on commit 4671f3b

Please sign in to comment.