Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APPMAN-1323 - Employer Successful Applicants and Applicant Details endpoints #1537

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
80c7ce0
Tidying
Dec 11, 2024
533b7d7
Startup tidy
Dec 11, 2024
26b00ae
Adding handler for successful employer candidates
Dec 11, 2024
45e06df
Bit of tidying
Dec 11, 2024
781a8c9
Query amendments
Dec 11, 2024
1241652
Query handler amendments
Dec 11, 2024
e2494dd
Adding controller tests
Dec 12, 2024
17d5cab
Test improvements
Dec 12, 2024
d607ae8
Test improvement
Dec 12, 2024
8020ebf
Bit of a refactor/tidy
Dec 12, 2024
9c6f9d2
Refactoring/fixes
Dec 12, 2024
7775d07
Adding handler for getting application review
Dec 12, 2024
82819c5
Adding endpoint to get applicant details
Dec 12, 2024
7b49c72
Sorting usings.
Dec 12, 2024
5b7d80a
whitespace
Dec 12, 2024
d0a0061
Merge branch 'master' into APPMAN-1323-NewApplcantEndpoints
cofaulco Dec 17, 2024
2dbb4d1
Adding regex timeout to prevent DoS attacks
Dec 18, 2024
30bc07a
Merge branch 'APPMAN-1323-NewApplcantEndpoints' of https://github.com…
Dec 18, 2024
0ead94f
Fixing sonarcloud issues
Dec 18, 2024
f51e39b
boolean fixes
Dec 18, 2024
ba3664a
Refactoring to use applicationReviewId to retrive an applicationReview
Dec 18, 2024
a735f21
Merge remote-tracking branch 'origin/master' into APPMAN-1323-NewAppl…
Najamuddin-Muhammad Jan 6, 2025
b79ad78
Merge remote-tracking branch 'origin/master' into APPMAN-1323-NewAppl…
Jan 7, 2025
21ba74b
Merge branch 'APPMAN-1323-NewApplcantEndpoints' of https://github.com…
Jan 7, 2025
c02b95d
Added Interviewing to ApplicationReviewStatus
Jan 7, 2025
0b4d7f1
Adding InReview to ApplicationReviewStatus
Jan 8, 2025
7062bae
Refcator to use IRecruitVacancyClient to pull applications instead of…
Jan 8, 2025
27f8725
Merge remote-tracking branch 'origin/master' into APPMAN-1323-NewAppl…
Jan 9, 2025
a008eeb
Merge remote-tracking branch 'origin/master' into APPMAN-1323-NewAppl…
Najamuddin-Muhammad Jan 10, 2025
998051c
Merge branch 'APPMAN-1323-NewApplcantEndpoints' of https://github.com…
Najamuddin-Muhammad Jan 10, 2025
61a25eb
Fixing bug where vacancy reference is null
Jan 13, 2025
346c4d9
Merge branch 'APPMAN-1323-NewApplcantEndpoints' of https://github.com…
Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture.NUnit3;
using FluentAssertions;
using SFA.DAS.Recruit.Api.Controllers;
using Xunit;
using Moq;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;
using SFA.DAS.Recruit.Api.Controllers;
using SFA.DAS.Recruit.Api.Models;
using SFA.DAS.Recruit.Api.Queries;
using System.Threading;
using SFA.DAS.Testing.AutoFixture;
using Xunit;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers
public class ApplicantsControllerTests
{
public class ApplicantsControllerTests
{
private readonly Mock<IMediator> _mockMediator;
private readonly ApplicantsController _sut;
private GetApplicantsQuery _queryPassed;
private readonly Mock<IMediator> _mockMediator;
private readonly ApplicantsController _sut;
private GetApplicantsQuery _queryPassed;

public ApplicantsControllerTests()
{
_mockMediator = new Mock<IMediator>();
_mockMediator.Setup(x => x.Send(It.IsAny<GetApplicantsQuery>(), CancellationToken.None))
.ReturnsAsync(new GetApplicantsResponse())
.Callback<IRequest<GetApplicantsResponse>, CancellationToken>((q, _) => _queryPassed = (GetApplicantsQuery)q);
_sut = new ApplicantsController(_mockMediator.Object);
}
public ApplicantsControllerTests()
{
_mockMediator = new Mock<IMediator>();
_mockMediator.Setup(x => x.Send(It.IsAny<GetApplicantsQuery>(), CancellationToken.None))
.ReturnsAsync(new GetApplicantsResponse())
.Callback<IRequest<GetApplicantsResponse>, CancellationToken>((q, _) => _queryPassed = (GetApplicantsQuery)q);
_sut = new ApplicantsController(_mockMediator.Object);
}

[Fact]
public async Task GetCall_EnsuresApplicantApplicationOutcomeFilterPassedToMediatorIsTrimmed()
{
var result = await _sut.Get(10000001, " successful ");
_queryPassed.ApplicantApplicationOutcomeFilter.Contains(" ").Should().BeFalse();
}
[Fact]
public async Task GetCall_EnsuresApplicantApplicationOutcomeFilterPassedToMediatorIsTrimmed()
{
var result = await _sut.Get(10000001, " successful ");
_queryPassed.ApplicantApplicationOutcomeFilter.Contains(" ").Should().BeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture.NUnit3;
using Esfa.Recruit.Vacancies.Client.Domain.Entities;
Expand All @@ -12,6 +14,7 @@
using NUnit.Framework;
using SFA.DAS.Recruit.Api.Controllers;
using SFA.DAS.Recruit.Api.Models;
using SFA.DAS.Recruit.Api.Queries;
using SFA.DAS.Testing.AutoFixture;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers;
Expand Down Expand Up @@ -78,4 +81,31 @@ public async Task Then_The_Withdraw_Request_Is_Handled_And_MediatrEvent_Publishe
c.VacancyReference == vacancyRef
&& c.CandidateId == candidateId)), Times.Once);
}

[Test, MoqAutoData]
public async Task When_Getting_Application_Review_Then_Query_Is_Created_And_Data_Is_Returned(
Guid applicationId,
Guid candidateId,
GetApplicationReviewResponse response,
ApplicationReviewResponse applicationReview,
[Frozen] Mock<IMediator> mockMediator,
[Greedy] ApplicationsController sut
)
{
response.ResultCode = ResponseCode.Success;
response.Data = applicationReview;

mockMediator.Setup(x => x.Send(
It.Is<GetApplicationReviewQuery>(q => q.ApplicationReviewId == applicationId && q.CandidateId == candidateId),
It.IsAny<CancellationToken>()))
.ReturnsAsync(response);

var result = await sut.GetApplicationReview(candidateId, applicationId) as OkObjectResult;

result.Should().NotBeNull();
result.StatusCode.Should().Be((int)HttpStatusCode.OK);

var actual = result.Value as ApplicationReviewResponse;
actual.Should().BeEquivalentTo(applicationReview);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using AutoFixture.NUnit3;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture.NUnit3;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.Vacancy;
using FluentAssertions;
using FluentAssertions.Execution;
Expand All @@ -7,12 +10,9 @@
using Moq;
using NUnit.Framework;
using SFA.DAS.Recruit.Api.Controllers;
using SFA.DAS.Recruit.Api.Models;
using SFA.DAS.Recruit.Api.Queries;
using SFA.DAS.Testing.AutoFixture;
using System.Threading;
using System.Threading.Tasks;
using SFA.DAS.Recruit.Api.Models;
using System.Collections.Generic;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers;
public class ClosedVacanciesControllerTests
Expand Down
105 changes: 69 additions & 36 deletions src/API/Recruit.Api.UnitTests/Controllers/EmployersControllerTests.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,78 @@
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture.NUnit3;
using FluentAssertions;
using SFA.DAS.Recruit.Api.Controllers;
using Xunit;
using Moq;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;
using SFA.DAS.Recruit.Api.Controllers;
using SFA.DAS.Recruit.Api.Models;
using SFA.DAS.Recruit.Api.Queries;
using System.Threading;
using SFA.DAS.Testing.AutoFixture;
using Xunit;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers
public class EmployersControllerTests
{
public class EmployersControllerTests
private readonly Mock<IMediator> _mockMediator;
private readonly EmployersController _sut;
private GetEmployerSummaryQuery _queryPassed = null;

public EmployersControllerTests()
{
_mockMediator = new Mock<IMediator>();
_mockMediator
.Setup(x => x.Send(
It.IsAny<GetEmployerSummaryQuery>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(new GetEmployerSummaryResponse())
.Callback<IRequest<GetEmployerSummaryResponse>, CancellationToken>((request, cancellationToken) =>
{
_queryPassed = (GetEmployerSummaryQuery)request;
});

_sut = new EmployersController(_mockMediator.Object);
}

[Xunit.Theory]
[InlineData(" myjr4x")]
[InlineData("MYJR4X")]
[InlineData(" myjR4X ")]
public async Task GetCall_EnsuresEmployerAccountIdPassedInQueryPassedToMediatorIsTrimmedAndUppercased(string input)
{
private readonly Mock<IMediator> _mockMediator;
private readonly EmployersController _sut;
private GetEmployerSummaryQuery _queryPassed = null;

public EmployersControllerTests()
{
_mockMediator = new Mock<IMediator>();
_mockMediator
.Setup(x => x.Send(
It.IsAny<GetEmployerSummaryQuery>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(new GetEmployerSummaryResponse())
.Callback<IRequest<GetEmployerSummaryResponse>, CancellationToken>((request, cancellationToken) =>
{
_queryPassed = (GetEmployerSummaryQuery) request;
});
_sut = new EmployersController(_mockMediator.Object);
}

[Theory]
[InlineData(" myjr4x")]
[InlineData("MYJR4X")]
[InlineData(" myjR4X ")]
public async Task GetCall_EnsuresEmployerAccountIdPassedInQueryPassedToMediatorIsTrimmedAndUppercased(string input)
{
await _sut.Get(input);
string.CompareOrdinal(_queryPassed.EmployerAccountId, "MYJR4X").Should().Be(0);
}
await _sut.Get(input);

string.CompareOrdinal(_queryPassed.EmployerAccountId, "MYJR4X").Should().Be(0);
}

[Test, MoqAutoData]
public async Task When_Getting_Successful_Applicants_Then_Query_Is_Created_And_Data_Returned(
string employerAccountId,
GetEmployerSuccessfulApplicantsQueryResponse response,
List<SuccessfulApplicant> successfulApplicants,
[Frozen] Mock<IMediator> mockMediator,
[Greedy] EmployersController sut
)
{
employerAccountId = employerAccountId.Trim().ToUpper();
response.ResultCode = ResponseCode.Success;
response.Data = successfulApplicants;

mockMediator.Setup(x => x.Send(
It.Is<GetEmployerSuccessfulApplicantsQuery>(q => q.EmployerAccountId == employerAccountId),
It.IsAny<CancellationToken>()))
.ReturnsAsync(response);

var result = await sut.GetSuccessfulApplicants(employerAccountId) as OkObjectResult;

result.Should().NotBeNull();
result.StatusCode.Should().Be((int)HttpStatusCode.OK);

var actual = result.Value as List<SuccessfulApplicant>;
actual.Should().BeEquivalentTo(successfulApplicants);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture.NUnit3;
using Esfa.Recruit.Vacancies.Client.Infrastructure.QueryStore.Projections.Vacancy;
using FluentAssertions;
Expand All @@ -10,9 +13,6 @@
using SFA.DAS.Recruit.Api.Controllers;
using SFA.DAS.Recruit.Api.Queries;
using SFA.DAS.Testing.AutoFixture;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers;
public class LiveVacanciesControllerTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using SFA.DAS.Recruit.Api.Controllers;
using Xunit;
using Moq;
using MediatR;
using Moq;
using SFA.DAS.Recruit.Api.Controllers;
using SFA.DAS.Recruit.Api.Queries;
using System.Threading;
using Xunit;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture.NUnit3;
using FluentAssertions;
using SFA.DAS.Recruit.Api.Controllers;
using Xunit;
using Moq;
using MediatR;
using SFA.DAS.Recruit.Api.Queries;
using System.Threading;
using AutoFixture.NUnit3;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;
using SFA.DAS.Recruit.Api.Commands;
using SFA.DAS.Recruit.Api.Controllers;
using SFA.DAS.Recruit.Api.Models;
using SFA.DAS.Recruit.Api.Queries;
using SFA.DAS.Testing.AutoFixture;
using Xunit;
using Assert = NUnit.Framework.Assert;

namespace SFA.DAS.Recruit.Api.UnitTests.Controllers
Expand Down
Loading
Loading