public void HasDataLockCourseChangeTriaged_Returns_Correct_Value(DataLockErrorCode errorCode, bool expectedResult)
        {
            //Arrange
            _dataLocks = new List <DataLock>
            {
                new DataLock
                {
                    Id             = 1,
                    TriageStatus   = TriageStatus.Change,
                    DataLockStatus = Status.Fail,
                    IsResolved     = false,
                    ErrorCode      = errorCode
                },
                new DataLock
                {
                    Id             = 2,
                    TriageStatus   = TriageStatus.Unknown,
                    DataLockStatus = Status.Pass,
                    IsResolved     = false
                }
            };

            //Act
            var actualResult = _dataLocks.HasDataLockCourseChangeTriaged();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public async Task Builds_an_event_with_errors(
            DataLockErrorCode errorCode,
            string description,
            [Frozen] Mock <IApprenticeshipRepository> repository,
            PriceEpisodeStatusChangeBuilder sut,
            EarningFailedDataLockMatching dataLock,
            List <EarningPeriod> periods,
            List <DataLockFailure> dataLockFailures,
            ApprenticeshipModel apprenticeships)
        {
            CommonTestSetup(repository, dataLock, periods, new List <ApprenticeshipModel> {
                apprenticeships
            }, dataLockFailures);
            var priceEpisode = dataLock.PriceEpisodes[0];

            periods[0].DataLockFailures[0].DataLockError = errorCode;

            var result = await sut.Build(
                new List <DataLockEvent> {
                dataLock
            },
                new List <(string identifier, PriceEpisodeStatus status)>
            {
                (priceEpisode.Identifier, PriceEpisodeStatus.New)
            },
                new List <PriceEpisodeStatusChange>(), dataLock.CollectionPeriod.AcademicYear);

            result.Should().NotBeEmpty();
            result[0].Errors.Should().ContainEquivalentOf(new
            {
                DataLockEventId   = result[0].DataLock.DataLockEventId,
                ErrorCode         = errorCode.ToString(),
                SystemDescription = description,
            });
        }
Пример #3
0
        private string GetDataLockDescription(DataLockErrorCode dlockCode)
        {
            switch (dlockCode)
            {
            case DataLockErrorCode.DLOCK_01: return("No matching record found in an employer digital account for the UKPRN");

            case DataLockErrorCode.DLOCK_03: return("No matching record found in the employer digital account for the standard code");

            case DataLockErrorCode.DLOCK_04: return("No matching record found in the employer digital account for the framework code");

            case DataLockErrorCode.DLOCK_05: return("No matching record found in the employer digital account for the programme type");

            case DataLockErrorCode.DLOCK_06: return("No matching record found in the employer digital account for the pathway code");

            case DataLockErrorCode.DLOCK_07: return("No matching record found in the employer digital account for the negotiated cost of training");

            case DataLockErrorCode.DLOCK_08: return("Multiple matching records found in the employer digital account");

            case DataLockErrorCode.DLOCK_09: return("The start date for this negotiated price is before the corresponding price start date in the employer digital account");

            case DataLockErrorCode.DLOCK_10: return("The employer has stopped payments for this apprentice");

            case DataLockErrorCode.DLOCK_11: return("The employer is not currently a levy payer");

            case DataLockErrorCode.DLOCK_12: return("DLOCK_12");

            default: return(dlockCode.ToString());
            }
        }
        public async Task EnableEdit_HasDataLockPriceTriaged_IsMapped(DataLockErrorCode dataLockErrorCode, bool expectedTriageOption)
        {
            //Arrange
            _apprenticeshipUpdatesResponse.ApprenticeshipUpdates = new List <ApprenticeshipUpdate>
            {
                new ApprenticeshipUpdate()
                {
                    OriginatingParty = Party.None
                }
            };
            _dataLocksResponse.DataLocks = new List <GetDataLocksResponse.DataLock>
            {
                new GetDataLocksResponse.DataLock
                {
                    Id             = 1,
                    TriageStatus   = TriageStatus.Change,
                    DataLockStatus = Status.Fail,
                    IsResolved     = false,
                    ErrorCode      = dataLockErrorCode
                },
            };

            //Act
            var result = await _mapper.Map(_request);

            //Assert
            Assert.AreEqual(expectedTriageOption, result.EnableEdit);
        }
Пример #5
0
        public async Task ThenPendingChangesWithoutCourseOrPriceAreNotExpiredOnSuccessfulDatalock(
            DataLockErrorCode errorCode)
        {
            var page1 = new List <DataLockStatus>
            {
                new DataLockStatus
                {
                    ApprenticeshipId = 1,
                    DataLockEventId  = 2,
                    ErrorCode        = errorCode
                }
            };

            _paymentEvents.Setup(x => x.GetDataLockEvents(1, null, null, 0L, 1)).ReturnsAsync(page1);

            _apprenticeshipUpdateRepository.Setup(x => x.GetPendingApprenticeshipUpdate(It.IsAny <long>()))
            .ReturnsAsync(new ApprenticeshipUpdate
            {
                Id          = 3,
                FirstName   = "ChangedFirstName",
                LastName    = "ChangedLastName",
                DateOfBirth = new DateTime(1999, 1, 1)
            });

            _apprenticeshipUpdateRepository.Setup(x => x.ExpireApprenticeshipUpdate(It.IsAny <long>()))
            .Returns(() => Task.FromResult(0L));

            //Act
            await _dataLockUpdater.RunUpdate();

            //Assert
            _apprenticeshipUpdateRepository.Verify(
                x => x.ExpireApprenticeshipUpdate(It.IsAny <long>()), Times.Never());
        }
        public void HasCourseDataLock_Returns_Correct_Value(DataLockErrorCode errorCode, bool expectedResult)
        {
            //Arrange
            _dataLock = new DataLock()
            {
                ErrorCode = errorCode
            };

            //Act
            var actualResult = _dataLock.WithCourseError();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #7
0
 public DetailsViewModelMapperFixture WithUnresolvedAndFailedDataLocks(DataLockErrorCode errorCode = DataLockErrorCode.Dlock07)
 {
     GetDataLocksResponse.DataLocks = new List <GetDataLocksResponse.DataLock> {
         new GetDataLocksResponse.DataLock
         {
             Id             = 1,
             TriageStatus   = TriageStatus.Unknown,
             DataLockStatus = Status.Fail,
             IsResolved     = false,
             ErrorCode      = errorCode
         }
     };
     return(this);
 }
Пример #8
0
            public DetailsViewModelMapperFixture WithAnotherDataLock(DataLockErrorCode errorCode)
            {
                var dataLocks = GetDataLocksResponse.DataLocks.ToList();

                dataLocks.Add(new GetDataLocksResponse.DataLock
                {
                    Id             = 1,
                    TriageStatus   = TriageStatus.Unknown,
                    DataLockStatus = Status.Fail,
                    IsResolved     = false,
                    ErrorCode      = errorCode
                });

                GetDataLocksResponse.DataLocks = dataLocks.AsReadOnly();
                return(this);
            }
        public DataLockErrorType MapErrorType(DataLockErrorCode errorCode)
        {
            if (errorCode.HasFlag(DataLockErrorCode.Dlock03) ||
                errorCode.HasFlag(DataLockErrorCode.Dlock04) ||
                errorCode.HasFlag(DataLockErrorCode.Dlock05) ||
                errorCode.HasFlag(DataLockErrorCode.Dlock06)
                )
            {
                return(DataLockErrorType.RestartRequired);
            }

            if (errorCode.HasFlag(DataLockErrorCode.Dlock07) ||
                errorCode.HasFlag(DataLockErrorCode.Dlock09))
            {
                return(DataLockErrorType.UpdateNeeded);
            }

            return(DataLockErrorType.None);
        }
        public async Task DataLock_TriageStatus_Mapped(DataLockErrorCode dataLockErrorCode, bool expectedTriageOption)
        {
            //Arrange
            _dataLocksResponse.DataLocks = new List <GetDataLocksResponse.DataLock>
            {
                new GetDataLocksResponse.DataLock
                {
                    Id             = 1,
                    TriageStatus   = TriageStatus.Change,
                    DataLockStatus = Status.Fail,
                    IsResolved     = false,
                    ErrorCode      = dataLockErrorCode
                },
            };


            //Act
            var result = await _mapper.Map(_request);

            //Assert
            Assert.AreEqual(expectedTriageOption, result.EnableEdit);
        }
Пример #11
0
        public async Task ThenDataLocksAreSkippedIfNotOnTheWhitelist(DataLockErrorCode errorCode, bool expectUpdate)
        {
            //Arrange
            var page1 = new List <DataLockStatus>
            {
                new DataLockStatus
                {
                    DataLockEventId = 2,
                    ErrorCode       = errorCode
                }
            };

            _paymentEvents.Setup(x => x.GetDataLockEvents(1, null, null, 0L, 1)).ReturnsAsync(page1);

            //Act
            await _dataLockUpdater.RunUpdate();

            //Assert
            var expectedCalls = expectUpdate ? 1 : 0;

            _dataLockRepository.Verify(x => x.UpdateDataLockStatus(It.IsAny <DataLockStatus>()), Times.Exactly(expectedCalls));
        }
        public async Task ThenPendingChangesAreExpiredOnSuccessfulDatalock(
            DataLockErrorCode errorCode, bool expectExpiry)
        {
            var page1 = new List <DataLockStatus>
            {
                new DataLockStatus
                {
                    ApprenticeshipId       = 1,
                    DataLockEventId        = 2,
                    ErrorCode              = errorCode,
                    PriceEpisodeIdentifier = "TEST-15/08/2018"
                }
            };

            _paymentEvents.Setup(x => x.GetDataLockEvents(1, null, null, 0L, 1)).ReturnsAsync(page1);

            _apprenticeshipUpdateRepository.Setup(x => x.GetPendingApprenticeshipUpdate(It.IsAny <long>()))
            .ReturnsAsync(new ApprenticeshipUpdate
            {
                Id           = 3,
                Cost         = 100,
                TrainingCode = "UpdatedTrainingCode"
            });

            _apprenticeshipUpdateRepository.Setup(x => x.ExpireApprenticeshipUpdate(It.IsAny <long>()))
            .Returns(() => Task.FromResult(0L));

            //Act
            await _dataLockUpdater.RunUpdate();

            //Assert
            _apprenticeshipUpdateRepository.Verify(
                x => x.GetPendingApprenticeshipUpdate(It.Is <long>(appId => appId == 1)),
                expectExpiry ? Times.Once() : Times.Never());

            _apprenticeshipUpdateRepository.Verify(
                x => x.ExpireApprenticeshipUpdate(It.Is <long>(updateId => updateId == 3)),
                expectExpiry ? Times.Once() : Times.Never());
        }
Пример #13
0
 private bool IsCourseChangeError(DataLockErrorCode errorCode)
 {
     return((errorCode & CourseChangeErrors) > 0);
 }
 public void HasCourseDataLock_Returns_Correct_Value(DataLockErrorCode errorCode, bool expectedResult)
 {
     _dataLock.ErrorCode = errorCode;
     Assert.AreEqual(expectedResult, _dataLock.HasCourseDataLock());
 }
Пример #15
0
        public DataLockRequestChangesRequestToViewModelMapperTestsFixture WithCourseDataLock(DataLockErrorCode courseDataLockErrorCode)
        {
            DataLocksWithCourseMismatch.Add(
                new DataLock {
                IsResolved = false, DataLockStatus = Status.Fail, ErrorCode = courseDataLockErrorCode
            });

            _dataLockSummariesResponse = AutoFixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, DataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, DataLocksWithOnlyPriceMismatch)
                                         .Create();

            _mockCommitmentsApiClient.Setup(r => r.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_dataLockSummariesResponse);

            return(this);
        }
        private List <DataLockEvent> CreateDataLockEvents(ApprenticeshipContractType1EarningEvent earningEvent, DataLockErrorCode dataLockErrorCode)
        {
            var dataLockEvents    = new List <DataLockEvent>();
            var nonPayableEarning = mapper.Map <EarningFailedDataLockMatching>(earningEvent);

            foreach (var onProgrammeEarning in nonPayableEarning.OnProgrammeEarnings)
            {
                var validPeriods   = new List <EarningPeriod>();
                var invalidPeriods = new List <EarningPeriod>();

                foreach (var period in onProgrammeEarning.Periods)
                {
                    period.DataLockFailures = new List <DataLockFailure>
                    {
                        new DataLockFailure
                        {
                            DataLockError = dataLockErrorCode
                        }
                    };
                }
            }

            foreach (var incentiveEarning in nonPayableEarning.IncentiveEarnings)
            {
                foreach (var period in incentiveEarning.Periods)
                {
                    period.DataLockFailures = new List <DataLockFailure>
                    {
                        new DataLockFailure
                        {
                            DataLockError = dataLockErrorCode
                        }
                    };
                }
            }

            if (nonPayableEarning.OnProgrammeEarnings.Any() || nonPayableEarning.IncentiveEarnings.Any())
            {
                dataLockEvents.Add(nonPayableEarning);
            }

            return(dataLockEvents);
        }
        private List <FunctionalSkillDataLockEvent> CreateDataLockEvents(IPaymentsEvent earningEvent, DataLockErrorCode dataLockErrorCode)
        {
            var dataLockEvents    = new List <FunctionalSkillDataLockEvent>();
            var nonPayableEarning = mapper.Map <FunctionalSkillEarningFailedDataLockMatching>(earningEvent);

            foreach (var onProgrammeEarning in nonPayableEarning.Earnings)
            {
                foreach (var period in onProgrammeEarning.Periods)
                {
                    period.DataLockFailures = new List <DataLockFailure>
                    {
                        new DataLockFailure
                        {
                            DataLockError = dataLockErrorCode
                        }
                    };
                }
            }

            if (nonPayableEarning.Earnings.Any())
            {
                dataLockEvents.Add(nonPayableEarning);
            }

            return(dataLockEvents);
        }
Пример #18
0
        public async Task With_Multiple_Datalocks_Then_AvailableTriageOption_Is_Mapped_Correctly(bool hasHadDataLockSuccess, DataLockErrorCode dataLockErrorCode, DataLockErrorCode dataLock2ErrorCode, DetailsViewModel.TriageOption expectedTriageOption)
        {
            _fixture
            .WithHasHadDataLockSuccess(hasHadDataLockSuccess)
            .WithUnresolvedAndFailedDataLocks(dataLockErrorCode)
            .WithAnotherDataLock(dataLock2ErrorCode);

            await _fixture.Map();

            Assert.AreEqual(expectedTriageOption, _fixture.Result.AvailableTriageOption);
        }
Пример #19
0
        public DataLockRequestChangesRequestToViewModelMapperTestsFixture WithCourseAndPriceDataLock(DateTime IlrEffectiveFromDate, decimal totalCost, string ilrTrainingCourseCode, TriageStatus triageStatus, DataLockErrorCode courseDataLockErrorCode)
        {
            DataLocksWithCourseMismatch.Add(
                new DataLock
            {
                IsResolved            = false,
                DataLockStatus        = Status.Fail,
                IlrEffectiveFromDate  = IlrEffectiveFromDate,
                IlrTotalCost          = totalCost,
                IlrTrainingCourseCode = ilrTrainingCourseCode,
                TriageStatus          = triageStatus,
                ErrorCode             = courseDataLockErrorCode | DataLockErrorCode.Dlock07
            });

            _dataLockSummariesResponse = AutoFixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, DataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, DataLocksWithOnlyPriceMismatch)
                                         .Create();

            _mockCommitmentsApiClient.Setup(r => r.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_dataLockSummariesResponse);

            return(this);
        }
Пример #20
0
        public async Task ThenDataLocksWithMultipleErrorCodesAreFilteredUsingWhitelist(DataLockErrorCode errorCode,
                                                                                       DataLockErrorCode expectSavedErrorCode)
        {
            //Arrange
            var page1 = new List <DataLockStatus>
            {
                new DataLockStatus
                {
                    DataLockEventId = 2,
                    ErrorCode       = errorCode
                }
            };

            _paymentEvents.Setup(x => x.GetDataLockEvents(1, null, null, 0L, 1)).ReturnsAsync(page1);

            //Act
            await _dataLockUpdater.RunUpdate();

            //Assert
            _dataLockRepository.Verify(x => x.UpdateDataLockStatus(It.Is <DataLockStatus>(d => d.ErrorCode == expectSavedErrorCode)), Times.Once);
        }