Skip to content

Commit

Permalink
Merge branch 'main' into xvibe/show-only-relevant-grid-areas
Browse files Browse the repository at this point in the history
  • Loading branch information
vbelinschi committed Dec 12, 2024
2 parents 14eceb5 + c0738f4 commit 52bfc83
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
// limitations under the License.

using MediatR;
using NodaTime;

namespace Energinet.DataHub.MarketParticipant.Application.Commands.GridAreas;

public sealed record GetRelevantGridAreasCommand(Interval Period) : IRequest<GetGridAreasResponse>;
public sealed record GetRelevantGridAreasCommand(GetRelevantGridAreasRequestDto GetRelevantGridAreasRequest) : IRequest<GetGridAreasResponse>;
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private static readonly IReadOnlyDictionary<AuditIdentity, KnownAuditIdentityPro
{ KnownAuditIdentityProvider.Migration.IdentityId, KnownAuditIdentityProvider.Migration },
{ KnownAuditIdentityProvider.TestFramework.IdentityId, KnownAuditIdentityProvider.TestFramework },
{ KnownAuditIdentityProvider.OrganizationBackgroundService.IdentityId, KnownAuditIdentityProvider.OrganizationBackgroundService },
{ KnownAuditIdentityProvider.ProcessManagerBackgroundJobs.IdentityId, KnownAuditIdentityProvider.ProcessManagerBackgroundJobs },
};

private readonly IUserRepository _userRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using Energinet.DataHub.MarketParticipant.Domain.Model;
using Energinet.DataHub.MarketParticipant.Domain.Repositories;
using MediatR;
using NodaTime;

namespace Energinet.DataHub.MarketParticipant.Application.Handlers.GridAreas;

Expand All @@ -44,8 +43,8 @@ public async Task<GetGridAreasResponse> Handle(GetRelevantGridAreasCommand reque
{
ArgumentNullException.ThrowIfNull(request, nameof(request));

var startDate = request.Period.Start.ToDateTimeOffset();
var endDate = request.Period.End.ToDateTimeOffset();
var startDate = request.GetRelevantGridAreasRequest.Period.Start.ToDateTimeOffset();
var endDate = request.GetRelevantGridAreasRequest.Period.End.ToDateTimeOffset();

var gridAreas = await _gridAreaRepository.GetAsync().ConfigureAwait(false);
var filteredByDateGridAreas = gridAreas.Where(ga => DoDatesOverlap(ga, startDate, endDate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private KnownAuditIdentityProvider(string friendlyName, string identityId)
public static KnownAuditIdentityProvider Migration { get; } = new("Migrated Data", "00000000-FFFF-FFFF-FFFF-000000000000");
public static KnownAuditIdentityProvider TestFramework { get; } = new("Test Framework", "AAAAAAAA-BBBB-CCCC-DDDD-000000000000");
public static KnownAuditIdentityProvider OrganizationBackgroundService { get; } = new("Organization Background Service", "00000000-1111-0000-0001-000000000000");
public static KnownAuditIdentityProvider ProcessManagerBackgroundJobs { get; } = new("Process Manager Background Jobs", "C861C5E2-8DDA-43E5-A5D0-B94834EE3FF6");

public AuditIdentity IdentityId { get; }
public string FriendlyName { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
using System.Threading.Tasks;
using Energinet.DataHub.MarketParticipant.Application.Commands;
using Energinet.DataHub.MarketParticipant.Application.Commands.GridAreas;
using Energinet.DataHub.MarketParticipant.Application.Commands.Users;
using Energinet.DataHub.MarketParticipant.Domain.Model;
using Energinet.DataHub.MarketParticipant.EntryPoint.WebApi.Revision;
using Energinet.DataHub.RevisionLog.Integration.WebApi;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using NodaTime;

namespace Energinet.DataHub.MarketParticipant.EntryPoint.WebApi.Controllers;

Expand Down Expand Up @@ -53,7 +51,7 @@ public async Task<ActionResult<IEnumerable<GridAreaDto>>> GetRelevantGridAreasAs
{
ArgumentNullException.ThrowIfNull(getRelevantGridAreasRequest);

var command = new GetRelevantGridAreasCommand(getRelevantGridAreasRequest.Period);
var command = new GetRelevantGridAreasCommand(getRelevantGridAreasRequest);
var response = await _mediator.Send(command).ConfigureAwait(false);
return Ok(response.GridAreas);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task Handle_ActorWithGridAreas_ReturnsGridAreas()
var target = new GetRelevantGridAreasHandler(actorRepositoryMock.Object, gridAreaRepositoryMock.Object, userContextMock.Object);

// act
var actual = await target.Handle(new GetRelevantGridAreasCommand(period), CancellationToken.None);
var actual = await target.Handle(new GetRelevantGridAreasCommand(new GetRelevantGridAreasRequestDto(period)), CancellationToken.None);

// assert
Assert.NotEmpty(actual.GridAreas);
Expand Down Expand Up @@ -105,7 +105,7 @@ public async Task Handle_ActorHasNoGridAreas_ReturnsEmpty()
var target = new GetRelevantGridAreasHandler(actorRepositoryMock.Object, gridAreaRepositoryMock.Object, userContextMock.Object);

// act
var actual = await target.Handle(new GetRelevantGridAreasCommand(period), CancellationToken.None);
var actual = await target.Handle(new GetRelevantGridAreasCommand(new GetRelevantGridAreasRequestDto(period)), CancellationToken.None);

// assert
Assert.Empty(actual.GridAreas);
Expand Down Expand Up @@ -149,7 +149,7 @@ public async Task Handle_ValidDates_ReturnsGridAreas(string validFrom, string? v
var target = new GetRelevantGridAreasHandler(actorRepositoryMock.Object, gridAreaRepositoryMock.Object, userContextMock.Object);

// act
var actual = await target.Handle(new GetRelevantGridAreasCommand(period), CancellationToken.None);
var actual = await target.Handle(new GetRelevantGridAreasCommand(new GetRelevantGridAreasRequestDto(period)), CancellationToken.None);

// assert
Assert.NotEmpty(actual.GridAreas);
Expand Down Expand Up @@ -191,7 +191,7 @@ public async Task Handle_InvalidDates_ReturnsEmpty(string validFrom, string? val
var target = new GetRelevantGridAreasHandler(actorRepositoryMock.Object, gridAreaRepositoryMock.Object, userContextMock.Object);

// act
var actual = await target.Handle(new GetRelevantGridAreasCommand(period), CancellationToken.None);
var actual = await target.Handle(new GetRelevantGridAreasCommand(new GetRelevantGridAreasRequestDto(period)), CancellationToken.None);

// assert
Assert.Empty(actual.GridAreas);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void ControllerEndpoint_Exists_MustHaveAuthorizationAttribute()
$"{nameof(ActorQueryController)}.{nameof(ActorQueryController.GetSelectionActorsAsync)}",
$"{nameof(GridAreaController)}.{nameof(GridAreaController.GetGridAreasAsync)}",
$"{nameof(GridAreaController)}.{nameof(GridAreaController.GetGridAreaAsync)}",
$"{nameof(GridAreaController)}.{nameof(GridAreaController.GetRelevantGridAreasAsync)}",
$"{nameof(GridAreaController)}.{nameof(GridAreaController.GetAuditAsync)}",
$"{nameof(GridAreaOverviewController)}.{nameof(GridAreaOverviewController.GetGridAreaOverviewAsync)}",
$"{nameof(OrganizationController)}.{nameof(OrganizationController.ListAllAsync)}",
Expand Down

0 comments on commit 52bfc83

Please sign in to comment.