Skip to content
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

psp-7085 update acknowledgement dialog box. #3591

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,6 @@ private void TransferPropertiesOfInterest(PimsAcquisitionFile acquisitionFile, b
foreach (var acquisitionProperty in propertiesOfInterest)
{
var property = acquisitionProperty.Property;
if (!userOverride)
{
throw new UserOverrideException(UserOverrideCode.PoiToInventory, "The properties of interest will be added to the inventory as acquired properties.");
}
var takes = _takeRepository.GetAllByPropertyAcquisitionFileId(acquisitionProperty.Internal_Id);

var activeTakes = takes.Where(t =>
Expand All @@ -733,6 +729,11 @@ private void TransferPropertiesOfInterest(PimsAcquisitionFile acquisitionFile, b
isPropertyOfInterest = true;
}

if (!userOverride && (isOwned || (!isOwned && !isPropertyOfInterest)))
{
throw new UserOverrideException(UserOverrideCode.PoiToInventory, "You have one or more take(s) that will be added to MoTI Inventory. Do you want to acknowledge and proceed?");
}

_propertyRepository.TransferFileProperty(property, isOwned, isPropertyOfInterest);
}

Expand Down
2 changes: 1 addition & 1 deletion source/backend/api/appsettings.Test.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"Pims": {
"Environment": {
"Uri": "https://tst-pims.th.gov.bc.ca",
"Uri": "https://pims-app-test-3cd915-dev.apps.silver.devops.gov.bc.ca",
"Name": "Testing"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public void Update_Success_Region_UserOverride()
}

[Fact]
public void Update_PropertyOfInterest_Violation()
public void Update_PropertyOfInterest_Violation_Owned()
{
// Arrange
var service = this.CreateAcquisitionServiceWithPermissions(Permissions.AcquisitionFileEdit);
Expand All @@ -456,6 +456,46 @@ public void Update_PropertyOfInterest_Violation()
var userRepository = this._helper.GetService<Mock<IUserRepository>>();
userRepository.Setup(x => x.GetUserInfoByKeycloakUserId(It.IsAny<Guid>())).Returns(EntityHelper.CreateUser("Test"));

var takeRepository = this._helper.GetService<Mock<ITakeRepository>>();
takeRepository.Setup(x => x.GetAllByPropertyAcquisitionFileId(It.IsAny<long>())).Returns(new List<PimsTake>() { new PimsTake() { IsNewHighwayDedication = true } });

// Act
Action act = () => service.Update(acqFile, new List<UserOverrideCode>() { UserOverrideCode.UpdateRegion });

// Assert
var ex = act.Should().Throw<UserOverrideException>();
ex.Which.UserOverride.Should().Be(UserOverrideCode.PoiToInventory);
repository.Verify(x => x.Update(It.IsAny<PimsAcquisitionFile>()), Times.Never);
}

[Fact]
public void Update_PropertyOfInterest_Violation_Other()
{
// Arrange
var service = this.CreateAcquisitionServiceWithPermissions(Permissions.AcquisitionFileEdit);

var acqFile = EntityHelper.CreateAcquisitionFile();
acqFile.AcquisitionFileStatusTypeCode = "COMPLT";
acqFile.ConcurrencyControlNumber = 1;

var property = EntityHelper.CreateProperty(12345);
property.IsPropertyOfInterest = true;
var propertyAcqFile = new PimsPropertyAcquisitionFile() { Property = property };
acqFile.PimsPropertyAcquisitionFiles = new List<PimsPropertyAcquisitionFile>() { propertyAcqFile };

var repository = this._helper.GetService<Mock<IAcquisitionFileRepository>>();
repository.Setup(x => x.GetRowVersion(It.IsAny<long>())).Returns(1);
repository.Setup(x => x.GetById(It.IsAny<long>())).Returns(acqFile);

var filePropertyRepository = this._helper.GetService<Mock<IAcquisitionFilePropertyRepository>>();
filePropertyRepository.Setup(x => x.GetPropertiesByAcquisitionFileId(It.IsAny<long>())).Returns(acqFile.PimsPropertyAcquisitionFiles.ToList());

var userRepository = this._helper.GetService<Mock<IUserRepository>>();
userRepository.Setup(x => x.GetUserInfoByKeycloakUserId(It.IsAny<Guid>())).Returns(EntityHelper.CreateUser("Test"));

var takeRepository = this._helper.GetService<Mock<ITakeRepository>>();
takeRepository.Setup(x => x.GetAllByPropertyAcquisitionFileId(It.IsAny<long>())).Returns(new List<PimsTake>() { new PimsTake() { IsNewInterestInSrw = true } });

// Act
Action act = () => service.Update(acqFile, new List<UserOverrideCode>() { UserOverrideCode.UpdateRegion });

Expand Down
Loading