Skip to content

Commit

Permalink
Replaced 'Involuntary' with 'Sponsored'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdexnimble committed Jun 5, 2023
1 parent 8c60714 commit 2487ac3
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

namespace Dfe.Academies.Academisation.Data.UnitTest.ProjectAggregate
{
public class CreateInvoluntaryProjectCommandTests
public class CreateSponsoredProjectCommandTests
{
private readonly InvoluntaryProject _newProject;
private readonly SponsoredProject _newProject;
private readonly AcademisationContext _context;
private readonly IProjectCreateDataCommand _projectCreateDataCommand;
private readonly Fixture _fixture;

public CreateInvoluntaryProjectCommandTests()
public CreateSponsoredProjectCommandTests()
{
_fixture = new Fixture();
ProjectState projectState = _fixture.Create<ProjectState>();
Expand All @@ -29,18 +29,18 @@ public CreateInvoluntaryProjectCommandTests()
_context.Projects.Add(projectState);
_context.SaveChanges();

_newProject = _fixture.Create<InvoluntaryProject>();
_newProject = _fixture.Create<SponsoredProject>();
}

private CreateInvoluntaryProjectDataCommand System_under_test()
private CreateSponsoredProjectDataCommand System_under_test()
{
return new CreateInvoluntaryProjectDataCommand(_projectCreateDataCommand);
return new CreateSponsoredProjectDataCommand(_projectCreateDataCommand);
}

[Fact]
public async Task Should_add_the_new_involuntary_project()
public async Task Should_add_the_new_sponsored_project()
{
CreateInvoluntaryProjectDataCommand command = System_under_test();
CreateSponsoredProjectDataCommand command = System_under_test();

await command.Execute(_newProject);

Expand All @@ -50,18 +50,18 @@ public async Task Should_add_the_new_involuntary_project()
[Fact]
public async Task Should_return_error_if_school_is_null()
{
CreateInvoluntaryProjectDataCommand command = System_under_test();
CreateSponsoredProjectDataCommand command = System_under_test();

var result = await command.Execute(new InvoluntaryProject(null, _fixture.Create<InvoluntaryProjectTrust>()));
var result = await command.Execute(new SponsoredProject(null, _fixture.Create<SponsoredProjectTrust>()));

result.Should().BeOfType<CommandValidationErrorResult>();
}
[Fact]
public async Task Should_return_error_if_join_trust_is_null()
{
CreateInvoluntaryProjectDataCommand command = System_under_test();
CreateSponsoredProjectDataCommand command = System_under_test();

var result = await command.Execute(new InvoluntaryProject(_fixture.Create<InvoluntaryProjectSchool>(), null));
var result = await command.Execute(new SponsoredProject(_fixture.Create<SponsoredProjectSchool>(), null));

result.Should().BeOfType<CommandValidationErrorResult>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

namespace Dfe.Academies.Academisation.Data.ProjectAggregate
{
public class CreateInvoluntaryProjectDataCommand : ICreateInvoluntaryProjectDataCommand
public class CreateSponsoredProjectDataCommand : ICreateSponsoredProjectDataCommand
{
private readonly IProjectCreateDataCommand _projectCreateDataCommand;
public CreateInvoluntaryProjectDataCommand(IProjectCreateDataCommand projectCreateDataCommand)
public CreateSponsoredProjectDataCommand(IProjectCreateDataCommand projectCreateDataCommand)
{
_projectCreateDataCommand = projectCreateDataCommand;
}

public async Task<CommandResult> Execute(Core.ProjectAggregate.InvoluntaryProject project)
public async Task<CommandResult> Execute(Core.ProjectAggregate.SponsoredProject project)
{
var domainServiceResult = Project.CreateInvoluntaryProject(project);
var domainServiceResult = Project.CreateSponsoredProject(project);

switch (domainServiceResult)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Dfe.Academies.Academisation.Core.ProjectAggregate
{
public record SponsoredProject(SponsoredProjectSchool? School, SponsoredProjectTrust? Trust);
public record SponsoredProjectTrust(string Name, string ReferenceNumber);
public record SponsoredProjectSchool(string Name, int Urn, DateTime? OpeningDate, bool? PartOfPfiScheme);
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static CreateResult CreateFormAMat(IApplication application)
return new CreateSuccessResult<IEnumerable<IProject>>(projectList);
}

public static CreateResult CreateInvoluntaryProject(InvoluntaryProject project)
public static CreateResult CreateSponsoredProject(SponsoredProject project)
{
if (project.Trust == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Dfe.Academies.Academisation.IData.ProjectAggregate
{
public interface ICreateInvoluntaryProjectDataCommand
public interface ICreateSponsoredProjectDataCommand
{
Task<CommandResult> Execute(InvoluntaryProject project);
Task<CommandResult> Execute(SponsoredProject project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace Dfe.Academies.Academisation.IService.Commands.Legacy.Project
{
public interface ICreateInvoluntaryProjectCommand
public interface ICreateSponsoredProjectCommand
{
Task<CommandResult> Execute(InvoluntaryProjectServiceModel model);
Task<CommandResult> Execute(SponsoredProjectServiceModel model);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
namespace Dfe.Academies.Academisation.IService.ServiceModels.Legacy.ProjectAggregate
{
public class InvoluntaryProjectServiceModel
public class SponsoredProjectServiceModel
{
public InvoluntaryProjectSchoolServiceModel? School { get; init; }
public InvoluntaryProjectTrustServiceModel? Trust { get; init; }
public SponsoredProjectSchoolServiceModel? School { get; init; }
public SponsoredProjectTrustServiceModel? Trust { get; init; }
}

public class InvoluntaryProjectTrustServiceModel
public class SponsoredProjectTrustServiceModel
{
public string? Name { get; init; }
public string? ReferenceNumber { get; init; }
}

public class InvoluntaryProjectSchoolServiceModel
public class SponsoredProjectSchoolServiceModel
{
public string? Name { get; init; }
public int Urn { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

namespace Dfe.Academies.Academisation.Service.Commands.Legacy.Project
{
public class CreateInvoluntaryProjectCommand : ICreateInvoluntaryProjectCommand
public class CreateSponsoredProjectCommand : ICreateSponsoredProjectCommand
{
private readonly IMapper _mapper;
private readonly ICreateInvoluntaryProjectDataCommand _createInvoluntaryProjectDataCommand;
private readonly ICreateSponsoredProjectDataCommand _createSponsoredProjectDataCommand;

public CreateInvoluntaryProjectCommand(
public CreateSponsoredProjectCommand(
IMapper mapper,
ICreateInvoluntaryProjectDataCommand createInvoluntaryProjectDataCommand)
ICreateSponsoredProjectDataCommand createSponsoredProjectDataCommand)
{
_mapper = mapper;
_createInvoluntaryProjectDataCommand = createInvoluntaryProjectDataCommand;
_createSponsoredProjectDataCommand = createSponsoredProjectDataCommand;
}

public async Task<CommandResult> Execute(InvoluntaryProjectServiceModel model)
public async Task<CommandResult> Execute(SponsoredProjectServiceModel model)
{
var result = await _createInvoluntaryProjectDataCommand.Execute(_mapper.Map<InvoluntaryProject>(model));
var result = await _createSponsoredProjectDataCommand.Execute(_mapper.Map<SponsoredProject>(model));

if (result is CommandValidationErrorResult)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public async Task JoinAMatApplicationExists___ApplicationIsSubmitted_And_Project

var projectController = new LegacyProjectController(new LegacyProjectGetQuery(new ProjectGetDataQuery(_context)), Mock.Of<ILegacyProjectListGetQuery>(),
Mock.Of<IProjectGetStatusesQuery>(), Mock.Of<ILegacyProjectUpdateCommand>(), Mock.Of<ILegacyProjectAddNoteCommand>(), Mock.Of<ILegacyProjectDeleteNoteCommand>(),
Mock.Of<ICreateInvoluntaryProjectCommand>());
Mock.Of<ICreateSponsoredProjectCommand>());
var projectResult = await projectController.Get(1);

(_, LegacyProjectServiceModel project) = DfeAssert.OkObjectResult(projectResult);
Expand Down Expand Up @@ -194,7 +194,7 @@ public async Task FormAMatApplicationExists___ApplicationIsSubmitted_And_Project

var projectController = new LegacyProjectController(new LegacyProjectGetQuery(new ProjectGetDataQuery(_context)), new LegacyProjectListGetQuery(new ProjectListGetDataQuery(_context)),
Mock.Of<IProjectGetStatusesQuery>(), Mock.Of<ILegacyProjectUpdateCommand>(), Mock.Of<ILegacyProjectAddNoteCommand>(), Mock.Of<ILegacyProjectDeleteNoteCommand>(),
Mock.Of<ICreateInvoluntaryProjectCommand>());
Mock.Of<ICreateSponsoredProjectCommand>());
var projectResults = await projectController.GetProjects(new GetAcademyConversionSearchModel(1, 3, null, null, null, null, new[] { $"A2B_{createdPayload.ApplicationReference!}" }));

(_, LegacyApiResponse<LegacyProjectServiceModel> projects) = DfeAssert.OkObjectResult(projectResults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class LegacyProjectAddNoteTests
private readonly ILegacyProjectGetQuery _projectGetQuery;
private readonly ILegacyProjectListGetQuery _projectListGetQuery;
private readonly ILegacyProjectUpdateCommand _projectUpdateCommand;
private readonly ICreateInvoluntaryProjectCommand _createInvoluntaryProjectCommand;
private readonly ICreateSponsoredProjectCommand _createSponsoredProjectCommand;
private ILegacyProjectDeleteNoteCommand _projectDeleteNoteCommand;

public LegacyProjectAddNoteTests()
Expand All @@ -28,7 +28,7 @@ public LegacyProjectAddNoteTests()
_projectUpdateCommand = Mock.Of<ILegacyProjectUpdateCommand>();
_projectAddNoteCommand = new Mock<ILegacyProjectAddNoteCommand>();
_projectDeleteNoteCommand = Mock.Of<ILegacyProjectDeleteNoteCommand>();
_createInvoluntaryProjectCommand = Mock.Of<ICreateInvoluntaryProjectCommand>();
_createSponsoredProjectCommand = Mock.Of<ICreateSponsoredProjectCommand>();
}

private LegacyProjectController System_under_test()
Expand All @@ -40,7 +40,7 @@ private LegacyProjectController System_under_test()
_projectUpdateCommand,
_projectAddNoteCommand.Object,
_projectDeleteNoteCommand,
_createInvoluntaryProjectCommand);
_createSponsoredProjectCommand);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public LegacyProjectGetStatusesTests()
IProjectGetStatusesQuery query = new ProjectGetStatusesQuery(dataQuery);

_legacyProjectController = new LegacyProjectController(Mock.Of<ILegacyProjectGetQuery>(), Mock.Of<ILegacyProjectListGetQuery>(),
query, Mock.Of<ILegacyProjectUpdateCommand>(), Mock.Of<ILegacyProjectAddNoteCommand>(), Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateInvoluntaryProjectCommand>());
query, Mock.Of<ILegacyProjectUpdateCommand>(), Mock.Of<ILegacyProjectAddNoteCommand>(), Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateSponsoredProjectCommand>());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ProjectGetTests()

_legacyProjectController = new LegacyProjectController(legacyProjectGetQuery, Mock.Of<ILegacyProjectListGetQuery>(),
Mock.Of<IProjectGetStatusesQuery>(), Mock.Of<ILegacyProjectUpdateCommand>(), Mock.Of<ILegacyProjectAddNoteCommand>(),
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateInvoluntaryProjectCommand>());
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateSponsoredProjectCommand>());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public LegacyProjectListGetTests()

_subject = new LegacyProjectController(Mock.Of<ILegacyProjectGetQuery>(), legacyProjectGetQuery,
Mock.Of<IProjectGetStatusesQuery>(), Mock.Of<ILegacyProjectUpdateCommand>(), Mock.Of<ILegacyProjectAddNoteCommand>(),
Mock.Of<ILegacyProjectDeleteNoteCommand>(),Mock.Of<ICreateInvoluntaryProjectCommand>());
Mock.Of<ILegacyProjectDeleteNoteCommand>(),Mock.Of<ICreateSponsoredProjectCommand>());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task ProjectExists___FullProjectIsUpdated()
// Arrange
var legacyProjectController = new LegacyProjectController(_legacyProjectGetQuery, Mock.Of<ILegacyProjectListGetQuery>(),
Mock.Of<IProjectGetStatusesQuery>(), _legacyProjectUpdateCommand, Mock.Of<ILegacyProjectAddNoteCommand>(),
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateInvoluntaryProjectCommand>());
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateSponsoredProjectCommand>());
var existingProject = _fixture.Create<ProjectState>();
await _context.Projects.AddAsync(existingProject);
await _context.SaveChangesAsync();
Expand Down Expand Up @@ -75,7 +75,7 @@ public async Task ProjectExists_FullProjectIsReturnedOnGet()
// Arrange
var legacyProjectController = new LegacyProjectController(_legacyProjectGetQuery, Mock.Of<ILegacyProjectListGetQuery>(),
Mock.Of<IProjectGetStatusesQuery>(), _legacyProjectUpdateCommand, Mock.Of<ILegacyProjectAddNoteCommand>(),
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateInvoluntaryProjectCommand>());
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateSponsoredProjectCommand>());
var existingProject = _fixture.Create<ProjectState>();
await _context.Projects.AddAsync(existingProject);
await _context.SaveChangesAsync();
Expand Down Expand Up @@ -105,7 +105,7 @@ public async Task ProjectExists___PartialProjectIsUpdated()
// Arrange
var legacyProjectController = new LegacyProjectController(_legacyProjectGetQuery, Mock.Of<ILegacyProjectListGetQuery>(),
Mock.Of<IProjectGetStatusesQuery>(), _legacyProjectUpdateCommand, Mock.Of<ILegacyProjectAddNoteCommand>(),
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateInvoluntaryProjectCommand>());
Mock.Of<ILegacyProjectDeleteNoteCommand>(), Mock.Of<ICreateSponsoredProjectCommand>());
var existingProject = _fixture.Create<ProjectState>();

await _context.Projects.AddAsync(existingProject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public static void AddMappings(Profile profile)
// .ForMember(x => x.DynamicsApplicationId, opt => opt.Ignore());
//profile.CreateMap<JoinTrustState, JoinTrust>();
profile.CreateMap<IJoinTrust, ApplicationJoinTrustServiceModel>();
profile.CreateMap<InvoluntaryProjectServiceModel, InvoluntaryProject>();
profile.CreateMap<InvoluntaryProjectTrustServiceModel, InvoluntaryProjectTrust>();
profile.CreateMap<InvoluntaryProjectSchoolServiceModel, InvoluntaryProjectSchool>();
profile.CreateMap<SponsoredProjectServiceModel, SponsoredProject>();
profile.CreateMap<SponsoredProjectTrustServiceModel, SponsoredProjectTrust>();
profile.CreateMap<SponsoredProjectSchoolServiceModel, SponsoredProjectSchool>();

// the mapping for this object is awkward because of the use of records, may have to re-think someof this but this is the best for now
//profile.CreateMap<FormTrustState, FormTrustDetails>().ReverseMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ public class LegacyProjectController : ControllerBase
private readonly ILegacyProjectListGetQuery _legacyProjectListGetQuery;
private readonly ILegacyProjectUpdateCommand _legacyProjectUpdateCommand;
private readonly IProjectGetStatusesQuery _projectGetStatusesQuery;
private readonly ICreateInvoluntaryProjectCommand _createInvoluntaryProjectCommand;
private readonly ICreateSponsoredProjectCommand _createSponsoredProjectCommand;

public LegacyProjectController(ILegacyProjectGetQuery legacyProjectGetQuery,
ILegacyProjectListGetQuery legacyProjectListGetQuery,
IProjectGetStatusesQuery projectGetStatusesQuery,
ILegacyProjectUpdateCommand legacyProjectUpdateCommand,
ILegacyProjectAddNoteCommand legacyProjectAddNoteCommand,
ILegacyProjectDeleteNoteCommand legacyProjectDeleteNoteCommand,
ICreateInvoluntaryProjectCommand createInvoluntaryProjectCommand)
ICreateSponsoredProjectCommand createSponsoredProjectCommand)
{
_legacyProjectGetQuery = legacyProjectGetQuery;
_legacyProjectListGetQuery = legacyProjectListGetQuery;
_projectGetStatusesQuery = projectGetStatusesQuery;
_legacyProjectUpdateCommand = legacyProjectUpdateCommand;
_legacyProjectAddNoteCommand = legacyProjectAddNoteCommand;
_legacyProjectDeleteNoteCommand = legacyProjectDeleteNoteCommand;
_createInvoluntaryProjectCommand = createInvoluntaryProjectCommand;
_createSponsoredProjectCommand = createSponsoredProjectCommand;
}

/// <summary>
Expand Down Expand Up @@ -150,17 +150,17 @@ public async Task<ActionResult> AddNote(int id, AddNoteRequest note)
}

/// <summary>
/// Adds a involuntary conversion project
/// Adds a sponsored conversion project
/// </summary>
/// <param name="project">The model holding the data required to create an Involuntary conversion</param>
/// <param name="project">The model holding the data required to create a sponsored conversion</param>
/// <response code="201">The project has been added</response>
[HttpPost("project/involuntary-conversion-project")]
[HttpPost("project/sponsored-conversion-project")]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<ActionResult> AddInvoluntaryConversion(InvoluntaryProjectServiceModel project)
public async Task<ActionResult> AddSponsoredConversion(SponsoredProjectServiceModel project)
{
CommandResult result = await _createInvoluntaryProjectCommand.Execute(project);
CommandResult result = await _createSponsoredProjectCommand.Execute(project);

return result switch
{
Expand Down
4 changes: 2 additions & 2 deletions Dfe.Academies.Academisation.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
builder.Services.AddScoped<IProjectNoteDeleteCommand, ProjectNoteDeleteCommand>();
builder.Services.AddScoped<ILegacyProjectAddNoteCommand, LegacyProjectAddNoteCommand>();
builder.Services.AddScoped<ILegacyProjectDeleteNoteCommand, LegacyProjectDeleteNoteCommand>();
builder.Services.AddScoped<ICreateInvoluntaryProjectCommand, CreateInvoluntaryProjectCommand>();
builder.Services.AddScoped<ICreateInvoluntaryProjectDataCommand, CreateInvoluntaryProjectDataCommand>();
builder.Services.AddScoped<ICreateSponsoredProjectCommand, CreateSponsoredProjectCommand>();
builder.Services.AddScoped<ICreateSponsoredProjectDataCommand, CreateSponsoredProjectDataCommand>();

//Repositories
builder.Services.AddScoped<IApplicationRepository, ApplicationRepository>();
Expand Down
3 changes: 2 additions & 1 deletion Dfe.Academies.Academisation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
README.md = README.md
release-notes.md = release-notes.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{5D372A37-BC9B-4476-A5E2-BC4DB7375768}"
Expand All @@ -49,7 +50,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Academies.Academisation
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Academies.Academisation.SubcutaneousTest", "Dfe.Academies.Academisation.SubcutaneousTest\Dfe.Academies.Academisation.SubcutaneousTest.csproj", "{DFF6043C-B40F-4DC7-AFB0-8796CEC70D4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dfe.Academies.Academisation.Seed", "Dfe.Academies.Academisation.Seed\Dfe.Academies.Academisation.Seed.csproj", "{FDA48BDF-BEA9-4235-BC75-2108CD9F0ECD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dfe.Academies.Academisation.Seed", "Dfe.Academies.Academisation.Seed\Dfe.Academies.Academisation.Seed.csproj", "{FDA48BDF-BEA9-4235-BC75-2108CD9F0ECD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
4 changes: 4 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 8.0.0
* The term 'Involuntary Conversion' has been replaced with 'Sponsored Conversion'. This includes all Api endpoints. Note this release is required for the corresponding changes in the prepare-conversions application to work.

---

0 comments on commit 2487ac3

Please sign in to comment.