Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-nx-15-8
Browse files Browse the repository at this point in the history
  • Loading branch information
frontend-specialisten committed Mar 30, 2023
2 parents 29f9c30 + 0657af5 commit eaef0ec
Show file tree
Hide file tree
Showing 47 changed files with 1,189 additions and 1,090 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/dist
/coverage
**/generated/**/*
schema.graphql

# Ignore API applications (BFF's)
**/api-*/**/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ limitations under the License.

<ItemGroup>
<PackageReference Include="WireMock.Net" Version="1.5.13" />
<PackageReference Include="Energinet.DataHub.Core.TestCommon" Version="4.0.0" />
<PackageReference Include="Energinet.DataHub.Core.FunctionApp.TestCommon" Version="4.0.0" />
<PackageReference Include="Energinet.DataHub.Core.TestCommon" Version="4.0.2" />
<PackageReference Include="Energinet.DataHub.Core.FunctionApp.TestCommon" Version="4.0.2" />
<PackageReference Include="Energinet.DataHub.MeteringPoints.Client" Version="3.0.1" />
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.12" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task GetFilteredActors_NotFas_ReturnsSingleActor(OrganizationDto or
.ReturnsAsync(organizations);

MarketParticipantClientMock
.Setup(client => client.GetActorsAsync(organization.OrganizationId))
.Setup(client => client.GetActorsAsync())
.ReturnsAsync(actors);

MarketParticipantClientMock
Expand Down Expand Up @@ -118,7 +118,7 @@ public async Task GetFilteredActors_IsFas_ReturnsAllActors(OrganizationDto organ
.ReturnsAsync(organizations);

MarketParticipantClientMock
.Setup(client => client.GetActorsAsync(organization.OrganizationId))
.Setup(client => client.GetActorsAsync())
.ReturnsAsync(actors);

MarketParticipantClientMock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Energinet.DataHub.Core.TestCommon.AutoFixture.Attributes;
using Energinet.DataHub.MarketParticipant.Client.Models;
using Energinet.DataHub.WebApi.Controllers.Wholesale.Dto;
using Energinet.DataHub.WebApi.Clients.Wholesale.v3;
using Energinet.DataHub.WebApi.Tests.Fixtures;
using Energinet.DataHub.Wholesale.Contracts;
using FluentAssertions;
using Moq;
using Xunit;
using Xunit.Abstractions;
using BatchRequestDto = Energinet.DataHub.WebApi.Clients.Wholesale.v3.BatchRequestDto;
using ProcessStepResultDtoV3 = Energinet.DataHub.WebApi.Clients.Wholesale.v3.ProcessStepResultDto;
using TimeSeriesTypeV3 = Energinet.DataHub.WebApi.Clients.Wholesale.v3.TimeSeriesType;
using BatchDtoV3 = Energinet.DataHub.WebApi.Clients.Wholesale.v3.BatchDto;

namespace Energinet.DataHub.WebApi.Tests.Integration.Controllers
{
Expand All @@ -43,136 +39,15 @@ public WholesaleControllerTests(
{
}

private const string BatchCreateUrl = "/v1/wholesalebatch";
private const string BatchSearchUrl = "/v1/wholesalebatch/search";
private const string BatchProcessStepResultUrl = "/v1/wholesalebatch/processstepresult";
private const string BaseUrl = "/v1/wholesalebatch";
private const string GridAreaCode = "805";

[Theory]
[InlineAutoMoqData]
public async Task CreateAsync_ReturnsOk(BatchRequestDto requestDto)
{
MockMarketParticipantClient();
var actual = await BffClient.PostAsJsonAsync(BatchCreateUrl, requestDto);
actual.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Theory]
[InlineAutoMoqData]
public async Task GetAsync_ReturnsBatch_WithGridAreaNames(Guid batchId)
{
MockMarketParticipantClient();
var batchDtoV2 = new BatchDtoV2(
Guid.NewGuid(),
DateTimeOffset.Now,
DateTimeOffset.Now,
DateTimeOffset.Now,
DateTimeOffset.Now,
BatchState.Completed,
true,
new[] { GridAreaCode },
ProcessType.BalanceFixing);

WholesaleClientMock
.Setup(m => m.GetBatchAsync(batchId))
.ReturnsAsync(batchDtoV2);
var responseMessage = await BffClient.GetAsync($"/v1/WholesaleBatch/Batch?batchId={batchId}");

var actual = await responseMessage.Content.ReadAsAsync<BatchDto>();
foreach (var gridAreaDto in actual.GridAreas)
{
Assert.NotNull(gridAreaDto.Name);
}
}

[Theory]
[InlineAutoMoqData]
public async Task PostAsync_WhenBatchesFound_ReturnsOk(BatchSearchDtoV2 searchDto)
{
var batches = new List<BatchDtoV2>
{
new(
Guid.NewGuid(),
DateTimeOffset.Now,
DateTimeOffset.Now,
DateTimeOffset.Now,
DateTimeOffset.Now,
BatchState.Completed,
true,
new[] { GridAreaCode },
ProcessType.BalanceFixing),
};
WholesaleClientMock
.Setup(m => m.GetBatchesAsync(searchDto))
.ReturnsAsync(batches);

MockMarketParticipantClient();

var actual = await BffClient.PostAsJsonAsync(BatchSearchUrl, searchDto);

actual.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Theory]
[InlineAutoMoqData]
public async Task PostAsync_WhenNoBatchesFound_ReturnsOk(BatchSearchDtoV2 searchDto)
{
MockMarketParticipantClient();
WholesaleClientMock
.Setup(m => m.GetBatchesAsync(searchDto))
.ReturnsAsync(new List<BatchDtoV2>());

var actual = await BffClient.PostAsJsonAsync(BatchSearchUrl, searchDto);

actual.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Theory]
[InlineAutoMoqData]
public async Task PostAsync_WhenBatchesFound_GridAreasHaveNames(BatchSearchDtoV2 searchDto)
{
var batches = new List<BatchDtoV2>
{
new(
Guid.NewGuid(),
DateTimeOffset.Now,
DateTimeOffset.Now,
DateTimeOffset.Now,
DateTimeOffset.Now,
BatchState.Completed,
true,
new[] { GridAreaCode },
ProcessType.BalanceFixing),
};
WholesaleClientMock
.Setup(m => m.GetBatchesAsync(searchDto))
.ReturnsAsync(batches);

MockMarketParticipantClient();

var responseMessage = await BffClient.PostAsJsonAsync(BatchSearchUrl, searchDto);
var actual = await responseMessage.Content.ReadAsAsync<IEnumerable<BatchDto>>();
foreach (var batchDto in actual)
{
foreach (var gridAreaDto in batchDto.GridAreas)
{
Assert.NotNull(gridAreaDto.Name);
}
}
}

[Theory]
[InlineAutoMoqData]
public async Task PostAsync_WhenProcessStepResultIsFound_ReturnsOk(
ProcessStepResultRequestDtoV3 processStepResultRequestDto,
ProcessStepResultDtoV3 processStepResultDto)
{
WholesaleClientV3Mock
.Setup(m => m.GetProcessStepResultAsync(processStepResultRequestDto.BatchId, processStepResultRequestDto.GridAreaCode, (TimeSeriesTypeV3)processStepResultRequestDto.TimeSeriesType, processStepResultRequestDto.EnergySupplierGln, processStepResultRequestDto.BalanceResponsiblePartyGln, null, CancellationToken.None))
.ReturnsAsync(processStepResultDto);

var actual = await BffClient.PostAsJsonAsync(BatchProcessStepResultUrl, processStepResultRequestDto);

var actual = await BffClient.PostAsJsonAsync(BaseUrl, requestDto);
actual.StatusCode.Should().Be(HttpStatusCode.OK);
}

Expand Down
Loading

0 comments on commit eaef0ec

Please sign in to comment.