Skip to content

Commit

Permalink
Merge branch 'feature/default-sponsored-grant-amounts' of https://git…
Browse files Browse the repository at this point in the history
…hub.com/DFE-Digital/academies-academisation-api into feature/default-sponsored-grant-amounts
  • Loading branch information
dneed-nimble committed Sep 18, 2023
2 parents 34c7028 + 38ba1b9 commit cf2bfea
Show file tree
Hide file tree
Showing 29 changed files with 1,805 additions and 43 deletions.
8 changes: 8 additions & 0 deletions CypressTests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const { defineConfig } = require('cypress')
const dotenv = require('dotenv')
const { generateZapReport } = require('./cypress/plugins/generateZapReport')

dotenv.config();

module.exports = defineConfig({
env: {
url: process.env.url,
apiKey: process.env.apiKey,
URN: process.env.URN
},
video: false,
e2e: {
setupNodeEvents(on, config) {
Expand Down
825 changes: 825 additions & 0 deletions CypressTests/cypress/e2e/Transfers-MAT.cy.js

Large diffs are not rendered by default.

786 changes: 786 additions & 0 deletions CypressTests/cypress/e2e/Transfers-SAT.cy.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

const AuthorisedUserCanAssignUserDataPayload =
{
"urn": Cypress.env('URN'),
"userId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"userEmail": "[email protected]",
"userFullName": "userFullName value"
}
module.exports = { AuthorisedUserCanAssignUserDataPayload }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

const transferringAcademyUkprnAAndOutgoingTrustUkprn = 10066875
const transferringAcademyUkprnB = 10066884
const incomingTrustUkprn = 10066876
const AuthorisedUserCanCreateNewMATTransferPayload =
{
"transferringAcademyUkprns": [
transferringAcademyUkprnAAndOutgoingTrustUkprn,
transferringAcademyUkprnB
],
"outgoingTrustUkprn": transferringAcademyUkprnAAndOutgoingTrustUkprn,
"incomingTrustUkprn": incomingTrustUkprn
}
module.exports = {AuthorisedUserCanCreateNewMATTransferPayload}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

const transferringAcademyUkprnAAndOutgoingTrustUkprn = 10066875
const incomingTrustUkprn = 10066876
const AuthorisedUserCanCreateNewSATTransferPayload =
{
"transferringAcademyUkprns": [
transferringAcademyUkprnAAndOutgoingTrustUkprn,
],
"outgoingTrustUkprn": transferringAcademyUkprnAAndOutgoingTrustUkprn,
"incomingTrustUkprn": incomingTrustUkprn
}
module.exports = {AuthorisedUserCanCreateNewSATTransferPayload}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

const AuthorisedUserCanSetAdditionalSchoolDataPayload =
{
"urn": Cypress.env('URN'),
"transferringAcademyUkprn": 10066875,
"latestOfstedReportAdditionalInformation": "latestOfstedReportAdditionalInformation value",
"pupilNumbersAdditionalInformation": "pupilNumbersAdditionalInformation value",
"keyStage2PerformanceAdditionalInformation": "keyStage2PerformanceAdditionalInformation value",
"keyStage4PerformanceAdditionalInformation": "KeyStage4PerformanceAdditionalInformation value",
"keyStage5PerformanceAdditionalInformation": "keyStage5PerformanceAdditionalInformation value"
}
module.exports = { AuthorisedUserCanSetAdditionalSchoolDataPayload }
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const AuthorisedUserCanSetBenefitsPayload =
{
"urn": Cypress.env('URN'),
"intendedTransferBenefits": {
"selectedBenefits": [
"selectedBenefits value"
],
"otherBenefitValue": "otherBenefitValue value"
},
"otherFactorsToConsider": {
"highProfile": {
"shouldBeConsidered": true,
"furtherSpecification": "highProfile furtherSpecification value"
},
"complexLandAndBuilding": {
"shouldBeConsidered": true,
"furtherSpecification": "complexLandAndBuildingFurtherSpecification Value"
},
"financeAndDebt": {
"shouldBeConsidered": true,
"furtherSpecification": "financeAndDebtFurtherSpecification value"
},
"otherRisks": {
"shouldBeConsidered": true,
"furtherSpecification": "otherRisksfurtherSpecification value"
}
},
"equalitiesImpactAssessmentConsidered": true,
"anyRisks": true,
"isCompleted": true
}
module.exports = { AuthorisedUserCanSetBenefitsPayload }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

const AuthorisedUserCanSetFeaturesPayload =
{
"urn": Cypress.env('URN'),
"id": 1,
"typeOfTransfer": "typeOfTransfer Value",
"whoInitiatedTheTransfer": "whoInitiatedTheTransfer Value",
"isCompleted": true
}
module.exports = { AuthorisedUserCanSetFeaturesPayload }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const AuthorisedUserCanSetLegalRequirementsPayload =
{
"urn": Cypress.env('URN'),
"outgoingTrustConsent": "outgoing Trust Consent Value",
"incomingTrustAgreement": "incoming Trust Consent Value",
"diocesanConsent": "diocesanConsent Value",
"isCompleted": true
}
module.exports = { AuthorisedUserCanSetLegalRequirementsPayload }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

const AuthorisedUserCanSetRationalePayload =
{
"urn": Cypress.env('URN'),
"projectRationale": "projectRationale",
"trustSponsorRationale": "trustSponsorRationale",
"isCompleted": true

}
module.exports = {AuthorisedUserCanSetRationalePayload}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const AuthorisedUserCanSetTransferDatesPayload =
{
"urn": Cypress.env('urn'),
"htbDate": "2023-08-23T09:50:45.404Z",
"targetDateForTransfer": "2023-08-23T09:50:45.404Z"
}
module.exports = { AuthorisedUserCanSetTransferDatesPayload }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const AuthorisedUserCanSetTrustInfoAndProjectDatesPayload =
{
"urn": Cypress.env('urn'),
"recommendation": "recommendationString value",
"author": "authorString value"
}
module.exports = { AuthorisedUserCanSetTrustInfoAndProjectDatesPayload }
13 changes: 13 additions & 0 deletions CypressTests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions CypressTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"zaproxy": "^2.0.0-rc.2"
},
"devDependencies": {
"dotenv": "^16.3.1",
"eslint": "^8.38.0",
"eslint-plugin-cypress": "^2.13.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ void ConfigureTrust(EntityTypeBuilder<Trust> trustConfiguration)

trustConfiguration.Property(i => i.RegionId)
.HasColumnName("FK_Region");

trustConfiguration
.HasOne<Region>(x => x.Region)
.WithMany(x => x.Trusts)
.HasForeignKey(s => s.RegionId);
.HasOne(x => x.Region)
.WithOne()
.HasForeignKey<Trust>(x => x.RegionId);

}

void ConfigureRegion(EntityTypeBuilder<Region> regionConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void SetTransferProjectTrustInformationAndProjectDates_WithValidParameter
var author = fixture.Create<string>();

//Act
result.SetTrustInformationAndProjectDates(recommendation, author);
result.SetGeneralInformation(recommendation, author);

//Assert
result.Recommendation.Should().Be(recommendation);
Expand Down
5 changes: 2 additions & 3 deletions Dfe.Academies.Academisation.Domain/Academies/Region.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace Dfe.Academies.Academisation.Domain.Academies;

public class Region
{
public long Id { get; set; }
public string Name { get; set; }

Check warning on line 8 in Dfe.Academies.Academisation.Domain/Academies/Region.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
[JsonIgnore]
public ICollection<Trust> Trusts { get; set; }

}
6 changes: 3 additions & 3 deletions Dfe.Academies.Academisation.Domain/Academies/Trust.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Dfe.Academies.Academisation.Domain.Academies;
namespace Dfe.Academies.Academisation.Domain.Academies;

public class Trust
{
Expand All @@ -10,6 +10,6 @@ public class Trust
public string? CompaniesHouseNumber { get; set; }
public string? UKPRN { get; set; }

public virtual Region Region { get; set; }
public long RegionId { get; set; }
public virtual Region? Region { get; set; }
public long? RegionId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void SetRationale(string projectRationale, string trustSponsorRationale,
TrustSponsorRationale = trustSponsorRationale;
RationaleSectionIsCompleted = isCompleted;
}
public void SetTrustInformationAndProjectDates(string recommendation, string author)
public void SetGeneralInformation(string recommendation, string author)
{
Recommendation = recommendation;
Author = author;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ void SetBenefitsAndRisks(bool? anyRisks, bool? equalitiesImpactAssessmentConside
bool? otherRisksShouldBeConsidered, string? otherRisksFurtherSpecification,
bool? isCompleted);

void SetTrustInformationAndProjectDates(string recommendation, string author);
void SetGeneralInformation(string recommendation, string author);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ namespace Dfe.Academies.Academisation.Service.UnitTest.Commands.TransferProject;
public class SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests
{
private readonly Mock<ITransferProjectRepository> _transferProjectRepositoryMock;
private readonly Mock<ILogger<SetTransferProjectTrustInformationAndProjectDatesCommandHandler>> _loggerMock;
private readonly SetTransferProjectTrustInformationAndProjectDatesCommandHandler _handler;
private readonly Mock<ILogger<SetTransferProjectGeneralInformationCommandHandler>> _loggerMock;
private readonly SetTransferProjectGeneralInformationCommandHandler _handler;

public SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests()
{
_transferProjectRepositoryMock = new Mock<ITransferProjectRepository>();
_loggerMock = new Mock<ILogger<SetTransferProjectTrustInformationAndProjectDatesCommandHandler>>();
_handler = new SetTransferProjectTrustInformationAndProjectDatesCommandHandler(_transferProjectRepositoryMock.Object, _loggerMock.Object);
_loggerMock = new Mock<ILogger<SetTransferProjectGeneralInformationCommandHandler>>();
_handler = new SetTransferProjectGeneralInformationCommandHandler(_transferProjectRepositoryMock.Object, _loggerMock.Object);
}

[Fact]
public async Task Handle_TransferProjectNotFound_ReturnsNotFoundCommandResult()
{
// Arrange
var command = new SetTransferProjectTrustInformationAndProjectDatesCommand
var command = new SetTransferProjectGeneralInformationCommand
{
Urn = 1,
Recommendation = "Recommendation",
Expand Down Expand Up @@ -55,7 +55,7 @@ public async Task Handle_TransferProjectNotFound_ReturnsNotFoundCommandResult()
public async Task Handle_TransferProjectFound_ReturnsCommandSuccessResult()
{
// Arrange
var command = new SetTransferProjectTrustInformationAndProjectDatesCommand
var command = new SetTransferProjectGeneralInformationCommand
{
Urn = 1,
Recommendation = "Recommendation",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xunit;
using Dfe.Academies.Academisation.Service.Commands.TransferProject;
using Xunit;

namespace Dfe.Academies.Academisation.Service.UnitTest.Commands.TransferProject;

Expand All @@ -13,7 +14,7 @@ public void CommandProperties_AreSetCorrectly()
var author = "Author";

// Act
var command = new SetTransferProjectTrustInformationAndProjectDatesCommand
var command = new SetTransferProjectGeneralInformationCommand
{
Urn = urn,
Recommendation = recommendation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SetTransferProjectBenefitsCommand : SetTransferProjectCommand
public class IntendedTransferBenefitDto
{
public List<string> SelectedBenefits { get; set; }
public string OtherBenefitValue { get; set; }
public string? OtherBenefitValue { get; set; }
}

public class OtherFactorsToConsiderDto
Expand All @@ -29,7 +29,7 @@ public class OtherFactorsToConsiderDto

public class BenefitConsideredFactorDto
{
public bool ShouldBeConsidered { get; set; }
public string FurtherSpecification { get; set; }
public bool? ShouldBeConsidered { get; set; }
public string? FurtherSpecification { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Dfe.Academies.Academisation.Core;
using MediatR;
using TramsDataApi.RequestModels.AcademyTransferProject;

namespace Dfe.Academies.Academisation.Service.Commands.TransferProject
{
public class SetTransferProjectGeneralInformationCommand : SetTransferProjectCommand
{
public string Recommendation { get; set; }
public string Author { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

namespace Dfe.Academies.Academisation.Service.Commands.TransferProject
{
public class SetTransferProjectTrustInformationAndProjectDatesCommandHandler : IRequestHandler<SetTransferProjectTrustInformationAndProjectDatesCommand, CommandResult>
public class SetTransferProjectGeneralInformationCommandHandler : IRequestHandler<SetTransferProjectGeneralInformationCommand, CommandResult>
{
private readonly ITransferProjectRepository _transferProjectRepository;
private readonly ILogger<SetTransferProjectTrustInformationAndProjectDatesCommandHandler> _logger;
private readonly ILogger<SetTransferProjectGeneralInformationCommandHandler> _logger;

public SetTransferProjectTrustInformationAndProjectDatesCommandHandler(ITransferProjectRepository transferProjectRepository,
ILogger<SetTransferProjectTrustInformationAndProjectDatesCommandHandler> logger)
public SetTransferProjectGeneralInformationCommandHandler(ITransferProjectRepository transferProjectRepository,
ILogger<SetTransferProjectGeneralInformationCommandHandler> logger)
{
_transferProjectRepository = transferProjectRepository;
_logger = logger;
}

public async Task<CommandResult> Handle(SetTransferProjectTrustInformationAndProjectDatesCommand request,
public async Task<CommandResult> Handle(SetTransferProjectGeneralInformationCommand request,
CancellationToken cancellationToken)
{
var transferProject = await _transferProjectRepository.GetByUrn(request.Urn).ConfigureAwait(false);
Expand All @@ -28,7 +28,7 @@ public async Task<CommandResult> Handle(SetTransferProjectTrustInformationAndPro
return new NotFoundCommandResult();
}

transferProject.SetTrustInformationAndProjectDates(request.Recommendation, request.Author);
transferProject.SetGeneralInformation(request.Recommendation, request.Author);

_transferProjectRepository.Update(transferProject as Domain.TransferProjectAggregate.TransferProject);
await _transferProjectRepository.UnitOfWork.SaveChangesAsync(cancellationToken);
Expand Down

This file was deleted.

Loading

0 comments on commit cf2bfea

Please sign in to comment.