Beispiel #1
0
        public void ShouldThrowAnExceptionIfAnyMapFdzDatasetsJobFailedToQueue()
        {
            ProviderSnapshot        providerSnapshot    = NewProviderSnapshotForFundingStream();
            FundingDataZoneProvider expectedProviderOne = NewFundingDataZoneProvider();
            FundingDataZoneProvider expectedProviderTwo = NewFundingDataZoneProvider();

            GivenTheProviderSnapshotForTheFundingStream(providerSnapshot);
            AndTheFundingDataZoneProvidersForTheSnapshot(providerSnapshot.ProviderSnapshotId, expectedProviderOne, expectedProviderTwo);

            string providerVersionId = GetProviderVersionIdFromSnapshot(providerSnapshot);

            AndSettingTheProviderVersionForTheSpecificationSucceeds(providerVersionId);
            AndTheProviderVersionUploadSucceeds(providerVersionId, null, expectedProviderOne.ProviderId, expectedProviderTwo.ProviderId);

            string expectedExceptionMessage = NewRandomString();

            AndTheJobCreationThrowsAnException(expectedExceptionMessage);

            Func <Task> invocation = async() => await WhenTheProviderSnapshotDataIsLoaded(NewValidMessage());

            invocation
            .Should()
            .ThrowExactly <Exception>()
            .Which
            .Message
            .Should()
            .Be(expectedExceptionMessage);
        }
Beispiel #2
0
        public void ShouldThrowAnExceptionIfProviderSnapShotIdNotSet()
        {
            ProviderSnapshot        providerSnapshot    = NewProviderSnapshotForFundingStream();
            FundingDataZoneProvider expectedProviderOne = NewFundingDataZoneProvider();
            FundingDataZoneProvider expectedProviderTwo = NewFundingDataZoneProvider();

            GivenTheProviderSnapshotForTheFundingStream(providerSnapshot);
            AndTheFundingDataZoneProvidersForTheSnapshot(providerSnapshot.ProviderSnapshotId, expectedProviderOne, expectedProviderTwo);

            string providerVersionId = GetProviderVersionIdFromSnapshot(providerSnapshot);

            AndSettingTheProviderVersionForTheSpecificationSucceeds(providerVersionId);
            AndTheProviderVersionUploadSucceeds(providerVersionId, null, expectedProviderOne.ProviderId, expectedProviderTwo.ProviderId);

            string expectedExceptionMessage = "Invalid provider snapshot id";

            AndTheJobCreationThrowsAnException(expectedExceptionMessage);

            Func <Task> invocation = async() => await WhenTheProviderSnapshotDataIsLoaded(NewValidMessage(_ => _.WithoutUserProperty(ProviderSnapshotId)));

            invocation
            .Should()
            .ThrowExactly <NonRetriableException>()
            .Which
            .Message
            .Should()
            .Be(expectedExceptionMessage);
        }
Beispiel #3
0
        public async Task ShouldDownloadAndSaveProviderVersionFDZProvidersWhenProviderVersionNotExistsForGivenSpecificationAndProviderSnapshot()
        {
            ProviderSnapshot        providerSnapshot    = NewProviderSnapshotForFundingStream();
            FundingDataZoneProvider expectedProviderOne = NewFundingDataZoneProvider();
            FundingDataZoneProvider expectedProviderTwo = NewFundingDataZoneProvider();

            GivenTheProviderSnapshotForTheFundingStream(providerSnapshot);
            AndTheFundingDataZoneProvidersForTheSnapshot(providerSnapshot.ProviderSnapshotId, expectedProviderOne, expectedProviderTwo);

            string providerVersionId = GetProviderVersionIdFromSnapshot(providerSnapshot);

            AndSettingTheProviderVersionForTheSpecificationSucceeds(providerVersionId);
            AndTheProviderVersionUploadSucceeds(providerVersionId, null, expectedProviderOne.ProviderId, expectedProviderTwo.ProviderId);

            await WhenTheProviderSnapshotDataIsLoaded(NewValidMessage());

            ThenTheProviderVersionWasSetOnTheSpecification();
            AndTheProviderVersionsWereUploaded();
            AndAMapFdzDatasetsJobWasQueued();
        }
Beispiel #4
0
        public void ShouldProviderVersionFDZProvidersThrowsExceptionWhenSetProviderVersionReturnsError()
        {
            ProviderSnapshot        providerSnapshot    = NewProviderSnapshotForFundingStream();
            FundingDataZoneProvider expectedProviderOne = NewFundingDataZoneProvider();
            FundingDataZoneProvider expectedProviderTwo = NewFundingDataZoneProvider();

            GivenTheProviderSnapshotForTheFundingStream(providerSnapshot);
            AndTheFundingDataZoneProvidersForTheSnapshot(providerSnapshot.ProviderSnapshotId, expectedProviderOne, expectedProviderTwo);

            string providerVersionId = GetProviderVersionIdFromSnapshot(providerSnapshot);

            AndSettingTheProviderVersionForTheSpecificationFails(providerVersionId);
            AndTheProviderVersionUploadSucceeds(providerVersionId, null, expectedProviderOne.ProviderId, expectedProviderTwo.ProviderId);

            Func <Task> invocation = async() => await WhenTheProviderSnapshotDataIsLoaded(NewValidMessage());

            invocation
            .Should()
            .ThrowExactly <Exception>()
            .Which
            .Message
            .Should()
            .Be($"Unable to update the specification - {_specificationId}, with provider version id  - {providerVersionId}. HttpStatusCode - {HttpStatusCode.BadRequest}");
        }
Beispiel #5
0
        public void ShouldProviderVersionFDZProvidersThrowsExceptionWhenUploadProviderVersionReturnsValidationError()
        {
            ProviderSnapshot        providerSnapshot    = NewProviderSnapshotForFundingStream();
            FundingDataZoneProvider expectedProviderOne = NewFundingDataZoneProvider();
            FundingDataZoneProvider expectedProviderTwo = NewFundingDataZoneProvider();

            GivenTheProviderSnapshotForTheFundingStream(providerSnapshot);
            AndTheFundingDataZoneProvidersForTheSnapshot(providerSnapshot.ProviderSnapshotId, expectedProviderOne, expectedProviderTwo);

            string providerVersionId = GetProviderVersionIdFromSnapshot(providerSnapshot);

            AndSettingTheProviderVersionForTheSpecificationSucceeds(providerVersionId);
            AndTheProviderVersionUploadFails(providerVersionId, new ConflictResult(), expectedProviderOne.ProviderId, expectedProviderTwo.ProviderId);

            Func <Task> invocation = async() => await WhenTheProviderSnapshotDataIsLoaded(NewValidMessage());

            invocation
            .Should()
            .ThrowExactly <Exception>()
            .Which
            .Message
            .Should()
            .Be($"Failed to upload provider version {providerVersionId}. ProviderVersion alreay exists for - {providerVersionId}");
        }