generated from LBHackney-IT/lbh-base-api
-
Notifications
You must be signed in to change notification settings - Fork 0
TS-2029: Disable block suspension/unsuspension #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
martapederiva
wants to merge
19
commits into
master
Choose a base branch
from
TS-2029
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a7e47b2
Add ContractManagement to track PH and parent Id if present
martapederiva b8872e6
Block suspension on blocks
martapederiva 36d5b84
Test suspension on blocks exception + typo
martapederiva 9a26c34
Test suspension on blocks exception
martapederiva 472ebf7
ContractManagement - make ParentAssetId optional
martapederiva 100122f
ContractManagement - rename property, not sure what I was thinking
martapederiva 84736c3
ContractManagement - rename
martapederiva 75d29fa
ContractManagement - check hierarchy on existing one and not incoming…
martapederiva 89e2a1b
ContractManagement - remove object from patch request
martapederiva 463a07f
ContractManagement - gateway changes
martapederiva a818e4b
ContractManagement - gateway changes
martapederiva 63bee7c
ContractHierarchy rename
martapederiva 432d665
ContractManagement - complete factory tests
martapederiva 8464882
Add skeleton boundary validation
martapederiva 3ea412f
Remove unnecessary interpolation
martapederiva ae99290
Expand boundary validation tests
martapederiva 9a45ff0
Better boundary validation and tests
martapederiva d054489
Add check on ParentContractId
martapederiva e1e9dd4
Better boundary validation - business logic
martapederiva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
ContractsApi.Tests/V1/Boundary/CreateContractRequestObjectValidatorTests.cs
This file contains hidden or 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,69 @@ | ||
| using ContractsApi.V1.Boundary.Requests; | ||
| using ContractsApi.V1.Boundary.Requests.Validation; | ||
| using AutoFixture; | ||
| using FluentAssertions; | ||
| using FluentValidation.TestHelper; | ||
| using System; | ||
| using System.Linq; | ||
| using Xunit; | ||
| using ContractsApi.V1.Domain; | ||
|
|
||
| namespace ContractsApi.Tests.V1.Boundary.Request.Validation | ||
| { | ||
| #nullable enable | ||
| public class CreateContractRequestObjectValidatorTests | ||
| { | ||
| private readonly CreateContractRequestObjectValidator _ccrov; | ||
| private readonly Fixture _fixture = new(); | ||
|
|
||
| public CreateContractRequestObjectValidatorTests() | ||
| { | ||
| _ccrov = new CreateContractRequestObjectValidator(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void RequestShouldErrorForInvalidEnumValue() | ||
| { | ||
| var model = new CreateContractRequestObject() | ||
| { | ||
| ContractManagement = new() | ||
| { | ||
| ContractHierarchy = (ContractHierarchy) 9 | ||
| } | ||
| }; | ||
| var result = _ccrov.TestValidate(model); | ||
| result.ShouldHaveValidationErrorFor(x => x.ContractManagement.ContractHierarchy) | ||
| .WithErrorMessage("The hierarchy provided is not valid"); | ||
| } | ||
| [Fact] | ||
| public void RequestShouldErrorIfHierarchyIsBlockOrStandaloneAndParentContractIdIsProvided() | ||
| { | ||
| var model = new CreateContractRequestObject() | ||
| { | ||
| ContractManagement = new() | ||
| { | ||
| ContractHierarchy = (ContractHierarchy) 1, | ||
| ParentContractId = new Guid() | ||
| } | ||
| }; | ||
| var result = _ccrov.TestValidate(model); | ||
| result.ShouldHaveValidationErrorFor(x => x.ContractManagement.ParentContractId) | ||
| .WithErrorMessage("ParentContractId must be empty for Blocks and Standalone Units"); | ||
| } | ||
| [Fact] | ||
| public void RequestShouldErrorIfHierarchyIsChildUnitAndParentContractIdIsNotProvided() | ||
| { | ||
| var model = new CreateContractRequestObject() | ||
| { | ||
| ContractManagement = new() | ||
| { | ||
| ContractHierarchy = (ContractHierarchy) 2, | ||
| ParentContractId = null | ||
| } | ||
| }; | ||
| var result = _ccrov.TestValidate(model); | ||
| result.ShouldHaveValidationErrorFor(x => x.ContractManagement.ParentContractId) | ||
| .WithErrorMessage("ParentContractId must be provided for Child Units"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
22 changes: 22 additions & 0 deletions
22
ContractsApi/V1/Boundary/Requests/Validation/CreateContractRequestObjectValidator.cs
This file contains hidden or 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,22 @@ | ||
| using ContractsApi.V1.Domain; | ||
| using FluentValidation; | ||
| using System; | ||
|
|
||
| namespace ContractsApi.V1.Boundary.Requests.Validation | ||
| { | ||
| public class CreateContractRequestObjectValidator : AbstractValidator<CreateContractRequestObject> | ||
| { | ||
| public CreateContractRequestObjectValidator() | ||
LBHTKarki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| RuleFor(x => x.ContractManagement.ContractHierarchy).IsInEnum() | ||
| .When(x => x.ContractManagement != null) | ||
| .WithMessage("The hierarchy provided is not valid"); | ||
| RuleFor(x => x.ContractManagement.ParentContractId).Empty() | ||
| .When(x => x.ContractManagement?.ContractHierarchy != ContractHierarchy.ChildUnit) | ||
| .WithMessage("ParentContractId must be empty for Blocks and Standalone Units"); | ||
| RuleFor(x => x.ContractManagement.ParentContractId).NotEmpty() | ||
| .When(x => x.ContractManagement?.ContractHierarchy == ContractHierarchy.ChildUnit) | ||
| .WithMessage("ParentContractId must be provided for Child Units"); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 System; | ||
|
|
||
| namespace ContractsApi.V1.Domain | ||
| { | ||
| public class ContractManagement | ||
| { | ||
| public ContractHierarchy ContractHierarchy { get; set; } | ||
| public Guid? ParentContractId { get; set; } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
12 changes: 12 additions & 0 deletions
12
ContractsApi/V1/Infrastructure/Exceptions/SuspendingBlockException.cs
This file contains hidden or 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,12 @@ | ||
| using System; | ||
|
|
||
| namespace ContractsApi.V1.Infrastructure.Exceptions | ||
| { | ||
| public class SuspendingBlockException : Exception | ||
| { | ||
| public SuspendingBlockException() | ||
| : base("It is not possible to add a suspension to blocks") | ||
| { | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.