-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1811 from SkillsFundingAgency/FLP-1018_Apprentice…
…shipsStubs Flp 1018 apprenticeships stubs
- Loading branch information
Showing
5 changed files
with
406 additions
and
9 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
308 changes: 308 additions & 0 deletions
308
src/Apprenticeships/SFA.DAS.Apprenticeships.Stubs/Program.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,308 @@ | ||
using System.Net; | ||
using System.Text.Json; | ||
using AutoFixture; | ||
using SFA.DAS.Apprenticeships.InnerApi; | ||
using SFA.DAS.Apprenticeships.Responses; | ||
using SFA.DAS.SharedOuterApi.InnerApi.Responses; | ||
using SFA.DAS.SharedOuterApi.InnerApi.Responses.Apprenticeships; | ||
using SFA.DAS.SharedOuterApi.InnerApi.Responses.CollectionCalendar; | ||
using WireMock.RequestBuilders; | ||
using WireMock.ResponseBuilders; | ||
using WireMock.Server; | ||
using WireMock.Settings; | ||
|
||
namespace SFA.DAS.Apprenticeships.Stubs | ||
{ | ||
public class Program | ||
{ | ||
private static WireMockServer _fakeCoursesApi; | ||
private static WireMockServer _fakeApprenticeshipsApi; | ||
private static WireMockServer _fakeCommitmentsApi; | ||
private static WireMockServer _fakeAccountsApi; | ||
private static WireMockServer _fakeEmployerProfilesApi; | ||
private static WireMockServer _fakeCollectionCalendarApi; | ||
|
||
static void Main(string[] args) | ||
{ | ||
try | ||
{ | ||
_fakeCoursesApi = WireMockServer.Start(new WireMockServerSettings | ||
{ | ||
Urls = new[] { "http://*:6011" }, | ||
StartAdminInterface = true, | ||
}); | ||
SetUpCoursesResponses(); | ||
|
||
_fakeApprenticeshipsApi = WireMockServer.Start(new WireMockServerSettings | ||
{ | ||
Urls = new[] { "http://*:6012" }, | ||
StartAdminInterface = true, | ||
}); | ||
SetUpApprenticeshipResponses(); | ||
|
||
_fakeCommitmentsApi = WireMockServer.Start(new WireMockServerSettings | ||
{ | ||
Urls = new[] { "http://*:6013" }, | ||
StartAdminInterface = true, | ||
}); | ||
SetUpCommitmentsResponses(); | ||
|
||
_fakeAccountsApi = WireMockServer.Start(new WireMockServerSettings | ||
{ | ||
Urls = new[] { "http://*:6014" }, | ||
StartAdminInterface = true, | ||
}); | ||
SetUpAccountsResponses(); | ||
|
||
_fakeEmployerProfilesApi = WireMockServer.Start(new WireMockServerSettings | ||
{ | ||
Urls = new[] { "http://*:6015" }, | ||
StartAdminInterface = true, | ||
}); | ||
SetUpEmployerProfilesResponses(); | ||
|
||
_fakeCollectionCalendarApi = WireMockServer.Start(new WireMockServerSettings | ||
{ | ||
Urls = new[] { "http://*:6016" }, | ||
StartAdminInterface = true, | ||
}); | ||
SetupCollectionCalendarResponses(); | ||
|
||
Console.WriteLine(("Please RETURN to stop server")); | ||
Console.ReadLine(); | ||
} | ||
finally | ||
{ | ||
_fakeCoursesApi.Stop(); | ||
_fakeCoursesApi.Dispose(); | ||
_fakeApprenticeshipsApi.Stop(); | ||
_fakeApprenticeshipsApi.Dispose(); | ||
_fakeCommitmentsApi.Stop(); | ||
_fakeCommitmentsApi.Dispose(); | ||
_fakeAccountsApi.Stop(); | ||
_fakeAccountsApi.Dispose(); | ||
_fakeEmployerProfilesApi.Stop(); | ||
_fakeEmployerProfilesApi.Dispose(); | ||
_fakeCollectionCalendarApi.Stop(); | ||
_fakeCollectionCalendarApi.Dispose(); | ||
} | ||
} | ||
|
||
private static void SetUpCoursesResponses() | ||
{ | ||
_fakeCoursesApi.Given( | ||
Request.Create().WithPath($"/api/courses/standards/*") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetStandardsListItem>()))); | ||
} | ||
|
||
private static void SetupCollectionCalendarResponses() | ||
{ | ||
_fakeCollectionCalendarApi.Given( | ||
Request.Create().WithPath($"/academicyears") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetAcademicYearsResponse>()))); | ||
} | ||
|
||
private static void SetUpCommitmentsResponses() | ||
{ | ||
_fakeCommitmentsApi.Given( | ||
Request.Create().WithPath($"/api/AccountLegalEntity/*") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetAccountLegalEntityResponse>()))); | ||
|
||
_fakeCommitmentsApi.Given( | ||
Request.Create().WithPath($"/api/providers/*") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetProviderResponse>()))); | ||
|
||
_fakeCommitmentsApi.Given( | ||
Request.Create().WithPath($"/api/trainingprogramme/*/versions") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetTrainingProgrammeVersionsResponse>()))); | ||
} | ||
|
||
private static void SetUpApprenticeshipResponses() | ||
{ | ||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/key") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<Guid>()))); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/price") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetApprenticeshipPriceResponse>()))); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/startDate") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetApprenticeshipStartDateResponse>()))); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/priceHistory").UsingPost() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<PostCreateApprenticeshipPriceChangeApiResponse>()))); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/startDateChange").UsingPost() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/priceHistory/pending").UsingGet() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetPendingPriceChangeApiResponse>()))); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/startDateChange/pending").UsingGet() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Create<GetPendingStartDateChangeApiResponse>()))); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/priceHistory/pending").UsingDelete() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/priceHistory/pending/reject").UsingPatch() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/priceHistory/pending").UsingPatch() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/startDateChange/pending").UsingDelete() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/startDateChange/reject").UsingPatch() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/startDateChange/pending").UsingPatch() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/freeze").UsingPost() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
|
||
_fakeApprenticeshipsApi.Given( | ||
Request.Create().WithPath($"/*/unfreeze").UsingPost() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody("{}")); | ||
} | ||
|
||
private static void SetUpAccountsResponses() | ||
{ | ||
_fakeAccountsApi.Given( | ||
Request.Create().WithPath($"/api/user/*/accounts") | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().CreateMany<GetUserAccountsResponse>()))); | ||
} | ||
|
||
private static void SetUpEmployerProfilesResponses() | ||
{ | ||
_fakeEmployerProfilesApi.Given( | ||
Request.Create().WithPath($"/api/users/*") | ||
.UsingGet() | ||
) | ||
.RespondWith( | ||
Response.Create() | ||
.WithStatusCode((int)HttpStatusCode.OK) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithBody(JsonSerializer.Serialize(new Fixture().Build<EmployerProfileUsersApiResponse>().With(x => x.Id, Guid.NewGuid().ToString).Create()))); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Apprenticeships/SFA.DAS.Apprenticeships.Stubs/SFA.DAS.Apprenticeships.Stubs.csproj
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AutoFixture" /> | ||
<PackageReference Include="WireMock.Net" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Shared\SFA.DAS.SharedOuterApi\SFA.DAS.SharedOuterApi.csproj" /> | ||
<ProjectReference Include="..\SFA.DAS.Apprenticeships\SFA.DAS.Apprenticeships.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.