-
Notifications
You must be signed in to change notification settings - Fork 0
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 #12 from DEFRA/feature/cdms-182
rearranged domain services, added decisions skeleton
- Loading branch information
Showing
30 changed files
with
260 additions
and
18 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
Btms.Business.Tests/Services/Decisions/DecisionServiceTests.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,19 @@ | ||
using Btms.Business.Services.Decisions; | ||
using Xunit; | ||
|
||
namespace Btms.Business.Tests.Services.Decisions; | ||
|
||
public class DecisionServiceTests | ||
{ | ||
[Fact] | ||
public async Task DeriveDecision() | ||
{ | ||
// Arrange | ||
var sut = new DecisionService(); | ||
|
||
// Act | ||
|
||
// Assert | ||
await Task.CompletedTask; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Btms.Business.Tests/Services/Decisions/Finders/ChedADecisionFinderTests.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,19 @@ | ||
using Btms.Business.Services.Decisions.Finders; | ||
using Xunit; | ||
|
||
namespace Btms.Business.Tests.Services.Decisions.Finders; | ||
|
||
public class ChedADecisionFinderTests | ||
{ | ||
[Fact] | ||
public async Task Find_Should_DoThings() | ||
{ | ||
// Arrange | ||
var sut = new ChedADecisionFinder(); | ||
|
||
// Act | ||
|
||
// Assert | ||
await Task.CompletedTask; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Btms.Business.Tests/Services/Decisions/Finders/ChedDDecisionFinderTests.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,19 @@ | ||
using Btms.Business.Services.Decisions.Finders; | ||
using Xunit; | ||
|
||
namespace Btms.Business.Tests.Services.Decisions.Finders; | ||
|
||
public class ChedDDecisionFinderTests | ||
{ | ||
[Fact] | ||
public async Task Find_Should_DoThings() | ||
{ | ||
// Arrange | ||
var sut = new ChedDDecisionFinder(); | ||
|
||
// Act | ||
|
||
// Assert | ||
await Task.CompletedTask; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Btms.Business.Tests/Services/Decisions/Finders/ChedPDecisionFinderTests.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,19 @@ | ||
using Btms.Business.Services.Decisions.Finders; | ||
using Xunit; | ||
|
||
namespace Btms.Business.Tests.Services.Decisions.Finders; | ||
|
||
public class ChedPDecisionFinderTests | ||
{ | ||
[Fact] | ||
public async Task Find_Should_DoThings() | ||
{ | ||
// Arrange | ||
var sut = new ChedPDecisionFinder(); | ||
|
||
// Act | ||
|
||
// Assert | ||
await Task.CompletedTask; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Btms.Business.Tests/Services/Decisions/Finders/ChedPPDecisionFinderTests.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,19 @@ | ||
using Btms.Business.Services.Decisions.Finders; | ||
using Xunit; | ||
|
||
namespace Btms.Business.Tests.Services.Decisions.Finders; | ||
|
||
public class ChedPPDecisionFinderTests | ||
{ | ||
[Fact] | ||
public async Task Find_Should_DoThings() | ||
{ | ||
// Arrange | ||
var sut = new ChedPPDecisionFinder(); | ||
|
||
// Act | ||
|
||
// Assert | ||
await Task.CompletedTask; | ||
} | ||
} |
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
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
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
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,15 @@ | ||
namespace Btms.Business.Services.Decisions; | ||
|
||
public enum DecisionCode | ||
{ | ||
E03, | ||
C03, | ||
C05, | ||
C06, | ||
C07, | ||
C08, | ||
N02, | ||
N03, | ||
N04, | ||
N07 | ||
} |
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,10 @@ | ||
using Btms.Model; | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Business.Services.Decisions; | ||
|
||
public class DecisionContext | ||
{ | ||
public List<ImportNotification> Notifications { get; set; } = new(); | ||
public List<Movement> Movements { get; set; } = new(); | ||
} |
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,3 @@ | ||
namespace Btms.Business.Services.Decisions; | ||
|
||
public record DecisionResult(DecisionCode DecisionCode); |
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,58 @@ | ||
using Btms.Business.Services.Decisions.Finders; | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Business.Services.Decisions; | ||
|
||
public class DecisionService : IDecisionService | ||
{ | ||
public async Task<DecisionResult> DeriveDecision(DecisionContext decisionContext) | ||
{ | ||
// Validate and prerequisite checks | ||
|
||
var decisions = decisionContext.Notifications.Select(x => (x.Id, GetDecision(x))).ToList(); | ||
|
||
foreach (var movement in decisionContext.Movements) | ||
{ | ||
// Generate list matched items -> decisions | ||
|
||
foreach (var item in movement.Items) | ||
{ | ||
// check decisions list for match reference, if no match then drop out with "no-match" | ||
|
||
} | ||
|
||
// Return decision based on prioritisation from confluence | ||
} | ||
|
||
await Task.CompletedTask; | ||
return new DecisionResult(DecisionCode.N02); | ||
} | ||
|
||
private DecisionResult GetDecision(ImportNotification notification) | ||
{ | ||
// get decision finder - fold IUU stuff into the decision finder for fish? | ||
IDecisionFinder finder; | ||
switch (notification.ImportNotificationType) | ||
{ | ||
case ImportNotificationTypeEnum.Ced: | ||
finder = new ChedDDecisionFinder(); | ||
break; | ||
|
||
case ImportNotificationTypeEnum.Cveda: | ||
finder = new ChedADecisionFinder(); | ||
break; | ||
|
||
case ImportNotificationTypeEnum.Cvedp: | ||
finder = new ChedPDecisionFinder(); | ||
break; | ||
|
||
case ImportNotificationTypeEnum.Chedpp: | ||
finder = new ChedPPDecisionFinder(); | ||
break; | ||
|
||
default: throw new InvalidOperationException("Invalid ImportNotificationType"); | ||
} | ||
|
||
return finder.FindDecision(notification); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Btms.Business/Services/Decisions/Finders/ChedADecisionFinder.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,11 @@ | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Business.Services.Decisions.Finders; | ||
|
||
public class ChedADecisionFinder : IDecisionFinder | ||
{ | ||
public DecisionResult FindDecision(ImportNotification notification) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Btms.Business/Services/Decisions/Finders/ChedDDecisionFinder.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,11 @@ | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Business.Services.Decisions.Finders; | ||
|
||
public class ChedDDecisionFinder : IDecisionFinder | ||
{ | ||
public DecisionResult FindDecision(ImportNotification notification) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Btms.Business/Services/Decisions/Finders/ChedPDecisionFinder.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,11 @@ | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Business.Services.Decisions.Finders; | ||
|
||
public class ChedPDecisionFinder : IDecisionFinder | ||
{ | ||
public DecisionResult FindDecision(ImportNotification notification) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Btms.Business/Services/Decisions/Finders/ChedPPDecisionFinder.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,11 @@ | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Business.Services.Decisions.Finders; | ||
|
||
public class ChedPPDecisionFinder : IDecisionFinder | ||
{ | ||
public DecisionResult FindDecision(ImportNotification notification) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
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,8 @@ | ||
using Btms.Model.Ipaffs; | ||
|
||
namespace Btms.Business.Services.Decisions.Finders; | ||
|
||
public interface IDecisionFinder | ||
{ | ||
DecisionResult FindDecision(ImportNotification notification); | ||
} |
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,6 @@ | ||
namespace Btms.Business.Services.Decisions; | ||
|
||
public interface IDecisionService | ||
{ | ||
public Task<DecisionResult> DeriveDecision(DecisionContext decisionContext); | ||
} |
2 changes: 1 addition & 1 deletion
2
Btms.Business/Services/ILinkingService.cs → ...iness/Services/Linking/ILinkingService.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
namespace Btms.Business.Services; | ||
namespace Btms.Business.Services.Linking; | ||
|
||
public interface ILinkingService | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
...Services/ImportNotificationLinkContext.cs → .../Linking/ImportNotificationLinkContext.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
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
2 changes: 1 addition & 1 deletion
2
Btms.Business/Services/LinkException.cs → ...usiness/Services/Linking/LinkException.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
namespace Btms.Business.Services; | ||
namespace Btms.Business.Services.Linking; | ||
|
||
public class LinkException(Exception inner) : Exception("Failed to link", inner); |
2 changes: 1 addition & 1 deletion
2
Btms.Business/Services/LinkOutcome.cs → ....Business/Services/Linking/LinkOutcome.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Btms.Business.Services; | ||
namespace Btms.Business.Services.Linking; | ||
|
||
public enum LinkOutcome | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
Btms.Business/Services/LinkResult.cs → Btms.Business/Services/Linking/LinkResult.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
4 changes: 1 addition & 3 deletions
4
Btms.Business/Services/LinkingService.cs → ...siness/Services/Linking/LinkingService.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
2 changes: 1 addition & 1 deletion
2
....Business/Services/MovementLinkContext.cs → ...s/Services/Linking/MovementLinkContext.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
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
Oops, something went wrong.