Skip to content

Commit

Permalink
Add enforcement test data (#178)
Browse files Browse the repository at this point in the history
* Refactor Pollutant class

* Randomize selected user in test data

* Add enforcement case data

* Add enforcement action data

* Add enforcement action reviews and stipulated penalties

* Reorganize static common data files

* Reorganize enforcement action subtypes

* Configure Entity Framework DbContext

* Fix unit tests
  • Loading branch information
dougwaldron authored Nov 15, 2024
1 parent c23c911 commit 7c5697b
Show file tree
Hide file tree
Showing 47 changed files with 921 additions and 220 deletions.
6 changes: 3 additions & 3 deletions src/Domain/ComplianceEntities/WorkEntries/ComplianceEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AirWeb.Domain.DataExchange;
using AirWeb.Domain.EnforcementEntities.Cases;
using AirWeb.Domain.Identity;
using System.Text.Json.Serialization;

Expand All @@ -12,13 +13,12 @@ private protected ComplianceEvent() { }

private protected ComplianceEvent(int? id, ApplicationUser? user) : base(id, user) { }

// TODO: Uncomment this when enforcement entities are added to the EF repository.
// public ICollection<EnforcementCase> EnforcementCases { get; } = [];
public ICollection<EnforcementCase> EnforcementCases { get; } = [];

// Data exchange properties
public bool IsDataFlowEnabled => IsClosed && !IsDeleted && WorkEntryType != WorkEntryType.RmpInspection;

[JsonIgnore]
[StringLength(11)]
[StringLength(1)]
public DataExchangeStatus DataExchangeStatus { get; init; }
}
2 changes: 1 addition & 1 deletion src/Domain/Data/Counties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace AirWeb.Domain.Data;

public static partial class Data
public static partial class CommonData
{
public static List<string> Counties { get; } =
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace AirWeb.Domain.EnforcementEntities.Properties;
// ReSharper disable StringLiteralTypo

namespace AirWeb.Domain.Data;

// Source of data from IAIP airbranch DB:
//
Expand All @@ -11,9 +13,9 @@
// where ICIS_POLLUTANT_CODE is not null
// ```

public static partial class Data
public static partial class CommonData
{
public static List<Pollutant> Pollutants { get; } =
public static List<Pollutant> AllPollutants { get; } =
[
new("300000331", "Chromium"),
new("300000025", "Cadmium"),
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Data/States.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace AirWeb.Domain.Data;

public static partial class Data
public static partial class CommonData
{
public static IEnumerable<string> States { get; } =
[
Expand Down
12 changes: 7 additions & 5 deletions src/Domain/DataExchange/Enums.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.Text.Json.Serialization;
using System.ComponentModel;
using System.Text.Json.Serialization;

namespace AirWeb.Domain.DataExchange;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum DataExchangeStatus
{
[UsedImplicitly] Processed,
[UsedImplicitly] Inserted,
[UsedImplicitly] Updated,
[UsedImplicitly] Deleted,
[Description("NotIncluded"), UsedImplicitly] N,
[Description("Processed"), UsedImplicitly] P,
[Description("Inserted"), UsedImplicitly] I,
[Description("Updated"), UsedImplicitly] U,
[Description("Deleted"), UsedImplicitly] D,
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using AirWeb.Domain.Identity;
using AirWeb.Domain.EnforcementEntities.Actions;
using AirWeb.Domain.Identity;
using System.ComponentModel;

namespace AirWeb.Domain.EnforcementEntities.Actions;
namespace AirWeb.Domain.EnforcementEntities.ActionProperties;

public class EnforcementActionReview : AuditableEntity
{
// Constructors
[UsedImplicitly] // Used by ORM.
private protected EnforcementActionReview() { }
private EnforcementActionReview() { }

private protected EnforcementActionReview(Guid id, EnforcementAction enforcementAction, ApplicationUser? user)
internal EnforcementActionReview(Guid id, EnforcementAction enforcementAction, ApplicationUser? user)
{
Id = id;
EnforcementAction = enforcementAction;
Expand All @@ -22,6 +23,8 @@ private protected EnforcementActionReview(Guid id, EnforcementAction enforcement
public ApplicationUser? ReviewedBy { get; internal init; }
public bool IsCompleted => DateCompleted.HasValue;
public DateOnly? DateCompleted { get; internal set; }

[StringLength(11)]
public ReviewResult? Status { get; internal set; }

[StringLength(7000)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using AirWeb.Domain.Identity;
using AirWeb.Domain.EnforcementEntities.Actions;
using AirWeb.Domain.Identity;
using Microsoft.EntityFrameworkCore;

namespace AirWeb.Domain.EnforcementEntities.Actions;
namespace AirWeb.Domain.EnforcementEntities.ActionProperties;

public class StipulatedPenalty : AuditableSoftDeleteEntity<Guid>
{
Expand All @@ -16,10 +18,11 @@ internal StipulatedPenalty(Guid id, ConsentOrder consentOrder, ApplicationUser?

public ConsentOrder ConsentOrder { get; set; } = null!;

public decimal StipulatedPenaltyAmount { get; set; }
[Precision(12, 2)]
public decimal Amount { get; set; }

[StringLength(7000)]
public string? StipulatedPenaltyComment { get; set; }
public DateOnly DateReceived { get; set; }

public short SortOrder { get; set; }
[StringLength(7000)]
public string? Notes { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ internal AdministrativeOrder(Guid id, EnforcementCase enforcementCase, Applicati
public DateOnly? Executed { get; set; }
public DateOnly? Appealed { get; set; }
public DateOnly? Resolved { get; set; }
public AoResolvedLetter? ResolvedLetter { get; set; }
}

This file was deleted.

19 changes: 19 additions & 0 deletions src/Domain/EnforcementEntities/Actions/AoResolvedLetter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using AirWeb.Domain.Identity;

namespace AirWeb.Domain.EnforcementEntities.Actions;

public class AoResolvedLetter : EnforcementAction
{
// Constructors
[UsedImplicitly] // Used by ORM.
private AoResolvedLetter() { }

internal AoResolvedLetter(Guid id, AdministrativeOrder administrativeOrder, ApplicationUser? user)
: base(id, administrativeOrder.EnforcementCase, user)
{
EnforcementActionType = EnforcementActionType.AoResolvedLetter;
AdministrativeOrder = administrativeOrder;
}

public AdministrativeOrder AdministrativeOrder { get; init; } = null!;
}
19 changes: 19 additions & 0 deletions src/Domain/EnforcementEntities/Actions/CoResolvedLetter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using AirWeb.Domain.Identity;

namespace AirWeb.Domain.EnforcementEntities.Actions;

public class CoResolvedLetter : EnforcementAction
{
// Constructors
[UsedImplicitly] // Used by ORM.
private CoResolvedLetter() { }

internal CoResolvedLetter(Guid id, ConsentOrder consentOrder, ApplicationUser? user)
: base(id, consentOrder.EnforcementCase, user)
{
EnforcementActionType = EnforcementActionType.CoResolvedLetter;
ConsentOrder = consentOrder;
}

public ConsentOrder ConsentOrder { get; init; } = null!;
}
7 changes: 6 additions & 1 deletion src/Domain/EnforcementEntities/Actions/ConsentOrder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using AirWeb.Domain.EnforcementEntities.Cases;
using AirWeb.Domain.EnforcementEntities.ActionProperties;
using AirWeb.Domain.EnforcementEntities.Cases;
using AirWeb.Domain.Identity;
using Microsoft.EntityFrameworkCore;

namespace AirWeb.Domain.EnforcementEntities.Actions;

Expand Down Expand Up @@ -28,8 +30,11 @@ internal ConsentOrder(Guid id, EnforcementCase enforcementCase, ApplicationUser?
public DateOnly? Executed { get; set; }
public DateOnly? ReceivedFromDirectorsOffice { get; set; }
public DateOnly? Resolved { get; set; }
public CoResolvedLetter? ResolvedLetter { get; set; }

public short? OrderNumber { get; set; }

[Precision(12, 2)]
public decimal? PenaltyAmount { get; set; }

[StringLength(7000)]
Expand Down
19 changes: 0 additions & 19 deletions src/Domain/EnforcementEntities/Actions/ConsentOrderResolved.cs

This file was deleted.

16 changes: 9 additions & 7 deletions src/Domain/EnforcementEntities/Actions/EnforcementAction.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AirWeb.Domain.BaseEntities;
using AirWeb.Domain.DataExchange;
using AirWeb.Domain.EnforcementEntities.ActionProperties;
using AirWeb.Domain.EnforcementEntities.Cases;
using AirWeb.Domain.Identity;
using System.ComponentModel;
Expand All @@ -23,7 +24,7 @@ private protected EnforcementAction(Guid id, EnforcementCase enforcementCase, Ap

// Basic data
public EnforcementCase EnforcementCase { get; init; } = null!;
protected EnforcementActionType EnforcementActionType { get; init; }
public EnforcementActionType EnforcementActionType { get; protected init; }

[StringLength(7000)]
public string Notes { get; set; } = string.Empty;
Expand All @@ -36,7 +37,8 @@ private protected EnforcementAction(Guid id, EnforcementCase enforcementCase, Ap
public DateTimeOffset? CurrentOwnerAssignedDate { get; internal set; }
public ICollection<EnforcementActionReview> Reviews { get; } = [];
public bool IsApproved { get; internal set; }
public ICollection<ApplicationUser> ApprovedBy { get; } = [];
public DateOnly? DateApproved { get; internal set; }
public ApplicationUser? ApprovedBy { get; set; }

// Status
public DateOnly? IssueDate { get; internal set; }
Expand All @@ -56,7 +58,7 @@ or EnforcementActionType.ProposedConsentOrder
public short? ActionNumber { get; set; }

[JsonIgnore]
[StringLength(11)]
[StringLength(1)]
public DataExchangeStatus DataExchangeStatus { get; init; }
}

Expand All @@ -66,11 +68,11 @@ public enum EnforcementActionType
[Description("Letter of Noncompliance")] LetterOfNoncompliance,
[Description("Notice of Violation")] NoticeOfViolation,
[Description("No Further Action Letter")] NoFurtherAction,
[Description("Combined NOV/NFA Letter")] NovNfa,
[Description("Combined NOV/NFA Letter")] NovNfaLetter,
[Description("Proposed Consent Order")] ProposedConsentOrder,
[Description("Consent Order")] ConsentOrder,
[Description("Consent Order Resolved")] ConsentOrderResolved,
[Description("Consent Order Resolved")] CoResolvedLetter,
[Description("Administrative Order")] AdministrativeOrder,
[Description("Administrative Order Resolved")] AdministrativeOrderResolved,
[Description("Letter")] Letter,
[Description("Administrative Order Resolved")] AoResolvedLetter,
[Description("Letter")] EnforcementLetter,
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

namespace AirWeb.Domain.EnforcementEntities.Actions;

public class Letter : EnforcementAction
public class EnforcementLetter : EnforcementAction
{
// Constructors
[UsedImplicitly] // Used by ORM.
private Letter() { }
private EnforcementLetter() { }

internal Letter(Guid id, EnforcementCase enforcementCase, ApplicationUser? user)
internal EnforcementLetter(Guid id, EnforcementCase enforcementCase, ApplicationUser? user)
: base(id, enforcementCase, user)
{
EnforcementActionType = EnforcementActionType.Letter;
EnforcementActionType = EnforcementActionType.EnforcementLetter;
}

public bool ResponseRequested { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace AirWeb.Domain.EnforcementEntities.Actions;

public class NoFurtherAction : EnforcementAction
public class NoFurtherActionLetter : EnforcementAction
{
// Constructors
[UsedImplicitly] // Used by ORM.
private NoFurtherAction() { }
private NoFurtherActionLetter() { }

internal NoFurtherAction(Guid id, NoticeOfViolation noticeOfViolation, ApplicationUser? user)
internal NoFurtherActionLetter(Guid id, NoticeOfViolation noticeOfViolation, ApplicationUser? user)
: base(id, noticeOfViolation.EnforcementCase, user)
{
EnforcementActionType = EnforcementActionType.NoFurtherAction;
Expand Down
4 changes: 3 additions & 1 deletion src/Domain/EnforcementEntities/Actions/NoticeOfViolation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ internal NoticeOfViolation(Guid id, EnforcementCase enforcementCase, Application
EnforcementActionType = EnforcementActionType.NoticeOfViolation;
}

public bool ResponseRequested { get; set; }
public bool ResponseRequested { get; set; } = true;
public DateOnly? ResponseReceived { get; set; }

public NoFurtherActionLetter? NoFurtherActionLetter { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

namespace AirWeb.Domain.EnforcementEntities.Actions;

public class NovNfa : EnforcementAction
public class NovNfaLetter : EnforcementAction
{
// Constructors
[UsedImplicitly] // Used by ORM.
private NovNfa() { }
private NovNfaLetter() { }

internal NovNfa(Guid id, EnforcementCase enforcementCase, ApplicationUser? user)
internal NovNfaLetter(Guid id, EnforcementCase enforcementCase, ApplicationUser? user)
: base(id, enforcementCase, user)
{
EnforcementActionType = EnforcementActionType.NovNfa;
EnforcementActionType = EnforcementActionType.NovNfaLetter;
}

public bool ResponseRequested { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal ProposedConsentOrder(Guid id, EnforcementCase enforcementCase, Applicat
EnforcementActionType = EnforcementActionType.ProposedConsentOrder;
}

public NoticeOfViolation NoticeOfViolation { get; set; } = null!;
public NoticeOfViolation? NoticeOfViolation { get; set; }

public DateOnly? ResponseReceived { get; set; }
}
Loading

0 comments on commit 7c5697b

Please sign in to comment.