-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from SkillsFundingAgency/PA-360-RPL-details-o…
…n-view-page PA-360 View has been updated to show RPL details
- Loading branch information
Showing
16 changed files
with
227 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...pers/DraftApprenticeship/ViewDraftApprenticeshipViewModelFromDetailsRequestMapperTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AutoFixture; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.CommitmentsV2.Shared.Interfaces; | ||
using SFA.DAS.CommitmentsV2.Api.Client; | ||
using SFA.DAS.CommitmentsV2.Api.Types.Responses; | ||
using SFA.DAS.CommitmentsV2.Types; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Mappers.DraftApprenticeship; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.DraftApprenticeship; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Mappers.DraftApprenticeship | ||
{ | ||
[TestFixture] | ||
public class ViewDraftApprenticeshipViewModelFromDetailsRequestMapperTests | ||
{ | ||
private ViewDraftApprenticeshipViewModelFromDetailsRequestMapper _mapper; | ||
private Mock<ICommitmentsApiClient> _apiClient; | ||
private Mock<IModelMapper> _modelMapper; | ||
private GetCohortResponse _cohort; | ||
private DetailsRequest _request; | ||
|
||
[SetUp] | ||
public void Arrange() | ||
{ | ||
var autoFixture = new Fixture(); | ||
_cohort = autoFixture.Create<GetCohortResponse>(); | ||
|
||
_request = autoFixture.Create<DetailsRequest>(); | ||
|
||
_apiClient = new Mock<ICommitmentsApiClient>(); | ||
|
||
_apiClient.Setup(x => x.GetCohort(It.IsAny<long>(), It.IsAny<CancellationToken>())).ReturnsAsync(_cohort); | ||
|
||
_modelMapper = new Mock<IModelMapper>(); | ||
|
||
_modelMapper.Setup(x => x.Map<IDraftApprenticeshipViewModel>(It.IsAny<ViewDraftApprenticeshipRequest>())) | ||
.ReturnsAsync(new ViewDraftApprenticeshipViewModel()); | ||
|
||
_mapper = new ViewDraftApprenticeshipViewModelFromDetailsRequestMapper(_apiClient.Object, _modelMapper.Object); | ||
} | ||
|
||
[TestCase(Party.Employer, typeof(ViewDraftApprenticeshipRequest))] | ||
[TestCase(Party.Provider, typeof(ViewDraftApprenticeshipRequest))] | ||
[TestCase(Party.TransferSender, typeof(ViewDraftApprenticeshipRequest))] | ||
public async Task When_Mapping_The_Mapping_Request_Is_Passed_On_To_The_Appropriate_Mapper(Party withParty, Type expectedMappingRequestType) | ||
{ | ||
_cohort.WithParty = withParty; | ||
await _mapper.Map(_request); | ||
|
||
_modelMapper.Verify( | ||
x => x.Map<IDraftApprenticeshipViewModel>(It.Is<IDraftApprenticeshipRequest>( | ||
r => r.GetType() == expectedMappingRequestType | ||
&& r.Request == _request | ||
&& r.Cohort == _cohort)), | ||
Times.Once); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...b/Mappers/DraftApprenticeship/ViewDraftApprenticeshipViewModelFromDetailsRequestMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Threading.Tasks; | ||
using SFA.DAS.CommitmentsV2.Api.Client; | ||
using SFA.DAS.CommitmentsV2.Shared.Interfaces; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.DraftApprenticeship; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.Mappers.DraftApprenticeship | ||
{ | ||
public class ViewDraftApprenticeshipViewModelFromDetailsRequestMapper : IMapper<DetailsRequest, ViewDraftApprenticeshipViewModel> | ||
{ | ||
private readonly ICommitmentsApiClient _commitmentsApiClient; | ||
private readonly IModelMapper _modelMapper; | ||
|
||
public ViewDraftApprenticeshipViewModelFromDetailsRequestMapper(ICommitmentsApiClient commitmentsApiClient, IModelMapper modelMapper) | ||
{ | ||
_commitmentsApiClient = commitmentsApiClient; | ||
_modelMapper = modelMapper; | ||
} | ||
|
||
public async Task<ViewDraftApprenticeshipViewModel> Map(DetailsRequest source) | ||
{ | ||
var cohort = await _commitmentsApiClient.GetCohort(source.CohortId); | ||
return (ViewDraftApprenticeshipViewModel)await _modelMapper.Map<IDraftApprenticeshipViewModel>(new ViewDraftApprenticeshipRequest | ||
{ | ||
Cohort = cohort, | ||
Request = source | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters