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

MAIN-B-21505 #14459

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
716a5b7
Merge remote-tracking branch 'origin/MAIN-B-21509-DB-Add-POE-and-POD'…
brianmanley-caci Nov 19, 2024
470bda3
B-21505 add ports to updateMTOShipment
brianmanley-caci Nov 20, 2024
9b41736
Merge remote-tracking branch 'origin/main' into MAIN-B-21505
brianmanley-caci Nov 20, 2024
f854d7b
Merge remote-tracking branch 'origin/MAIN-B-21509-DB-Add-POE-and-POD'…
brianmanley-caci Nov 20, 2024
435e5c4
Merge remote-tracking branch 'origin/main' into MAIN-B-21505
brianmanley-caci Nov 22, 2024
d7186ff
B-21505 prime update port functionality
brianmanley-caci Nov 25, 2024
c057cee
Merge main into MAIN-B-21505
brianmanley-caci Nov 25, 2024
21399ea
B-21505 return port information on getMoveTaskOrder
brianmanley-caci Nov 26, 2024
f0ec2eb
B-21505 service level tests for port locations
brianmanley-caci Nov 27, 2024
34b4a2a
B-21505 model to payload tests
brianmanley-caci Nov 27, 2024
bd2e294
B-21505 payload to model tests
brianmanley-caci Nov 27, 2024
9f57872
Merge remote-tracking branch 'origin/main' into MAIN-B-21505
brianmanley-caci Dec 2, 2024
a4f687b
B-21505 add port_locations to db-truncate
brianmanley-caci Dec 2, 2024
5f272bc
B-21505 add prime documentation
brianmanley-caci Dec 2, 2024
d616f5c
B-21505 generate api files
brianmanley-caci Dec 2, 2024
3fd80ae
B-21505 peer review improvements
brianmanley-caci Dec 2, 2024
45887c9
B-21505 server_generate
brianmanley-caci Dec 2, 2024
66c8d9c
B-21505 factories and more factories
brianmanley-caci Dec 3, 2024
c2e02e6
Merge main into B-21505
brianmanley-caci Dec 4, 2024
f633478
B-21505 peer review fixes
brianmanley-caci Dec 4, 2024
01fffbf
Merge main into B-21505
brianmanley-caci Dec 4, 2024
bda892d
Merge main into B-21505
brianmanley-caci Dec 10, 2024
02c8109
B-21505 improve if else logic
brianmanley-caci Dec 10, 2024
cb22643
Merge main into B-21505
brianmanley-caci Dec 11, 2024
d1fe817
B-21505 clean up copy/paste errors
brianmanley-caci Dec 11, 2024
14dad4c
B-21505 test coverage improvement
brianmanley-caci Dec 11, 2024
a209ed6
B-21505 improve port update api
brianmanley-caci Dec 12, 2024
6f3c0bc
Merge remote-tracking branch 'origin/main' into MAIN-B-21505
brianmanley-caci Dec 13, 2024
59ae5b7
Merge main into B-21505
brianmanley-caci Dec 16, 2024
548583f
B-21505 B instead of P
brianmanley-caci Dec 16, 2024
a585c9f
B-21505 another port type P to B
brianmanley-caci Dec 18, 2024
40251b2
Merge remote-tracking branch 'origin/main' into MAIN-B-21505
brianmanley-caci Dec 23, 2024
8da9bed
Merge branch 'main' into MAIN-B-21505
brianmanley-caci Dec 23, 2024
f88c10c
Merge branch 'main' into MAIN-B-21505
danieljordan-caci Dec 26, 2024
e3543b6
Merge branch 'main' into MAIN-B-21505
brianmanley-caci Dec 27, 2024
8624ada
Merge branch 'main' into MAIN-B-21505
brianmanley-caci Dec 27, 2024
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
Prev Previous commit
Next Next commit
B-21505 service level tests for port locations
  • Loading branch information
brianmanley-caci committed Nov 27, 2024
commit f0ec2ebb4e95fd073fe4c41aaa75a21c183952f0
200 changes: 200 additions & 0 deletions pkg/services/mto_service_item/mto_service_item_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,206 @@ func (suite *MTOServiceItemServiceSuite) TestValidateUpdateMTOServiceItem() {
suite.IsType(apperror.InvalidInputError{}, err)
})

// Test successful Prime validation for Port of Embarkation
suite.Run("UpdateMTOServiceItemPrimeValidator - Update Port of Embarkation - success", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePOEFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime
poeId := uuid.FromStringOrNil("b6e94f5b-33c0-43f3-b960-7c7b2a4ee5fc")
newServiceItemPrime.POELocationID = &poeId
newServiceItemPrime.POELocation = &models.PortLocation{}

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
updatedServiceItem, err := ValidateUpdateMTOServiceItem(suite.AppContextForTest(), &serviceItemData, UpdateMTOServiceItemPrimeValidator)

suite.NoError(err)
suite.NotNil(updatedServiceItem)
suite.IsType(models.MTOServiceItem{}, *updatedServiceItem)
suite.Equal(updatedServiceItem.POELocationID, newServiceItemPrime.POELocationID)
})

// Test failure Prime validation for Port of Embarkation
suite.Run("UpdateMTOServiceItemPrimeValidator - Update Port of Embarkation - Port not updated when new port ID is nil", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePOEFSC,
},
},
}, nil)
poeId := uuid.FromStringOrNil("b6e94f5b-33c0-43f3-b960-7c7b2a4ee5fc")
oldServiceItemPrime.POELocationID = &poeId

newServiceItemPrime := oldServiceItemPrime
newServiceItemPrime.POELocationID = nil
newServiceItemPrime.POELocation = &models.PortLocation{}

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
updatedServiceItem, err := ValidateUpdateMTOServiceItem(suite.AppContextForTest(), &serviceItemData, UpdateMTOServiceItemPrimeValidator)

suite.NoError(err)
suite.NotNil(updatedServiceItem)
suite.IsType(models.MTOServiceItem{}, *updatedServiceItem)
suite.NotEqual(oldServiceItemPrime.POELocationID, newServiceItemPrime.POELocationID)
suite.Equal(oldServiceItemPrime.POELocationID, updatedServiceItem.POELocationID)
})

// Test failure Prime validation for Port of Embarkation
suite.Run("UpdateMTOServiceItemPrimeValidator - Update Port of Embarkation - Port not updated wrong service code is supplied", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePODFSC,
},
},
}, nil)
poeId := uuid.FromStringOrNil("b6e94f5b-33c0-43f3-b960-7c7b2a4ee5fc")
oldServiceItemPrime.POELocationID = &poeId

newServiceItemPrime := oldServiceItemPrime
newServiceItemPrime.POELocationID = nil
newServiceItemPrime.POELocation = &models.PortLocation{}

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
updatedServiceItem, err := ValidateUpdateMTOServiceItem(suite.AppContextForTest(), &serviceItemData, UpdateMTOServiceItemPrimeValidator)

suite.Error(err)
suite.Empty(updatedServiceItem)
suite.Contains(err.Error(), "is in a conflicting state POE Location can only be updated for service item POEFSC")
})

// Test successful Prime validation for Port of Debarkation
suite.Run("UpdateMTOServiceItemPrimeValidator - Update Port of Debarkation - success", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePODFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime
podId := uuid.FromStringOrNil("b6e94f5b-33c0-43f3-b960-7c7b2a4ee5fc")
newServiceItemPrime.PODLocationID = &podId
newServiceItemPrime.PODLocation = &models.PortLocation{}

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
updatedServiceItem, err := ValidateUpdateMTOServiceItem(suite.AppContextForTest(), &serviceItemData, UpdateMTOServiceItemPrimeValidator)

suite.NoError(err)
suite.NotNil(updatedServiceItem)
suite.IsType(models.MTOServiceItem{}, *updatedServiceItem)
suite.Equal(updatedServiceItem.PODLocationID, newServiceItemPrime.PODLocationID)
})

// Test failure Prime validation for Port of Debarkation
suite.Run("UpdateMTOServiceItemPrimeValidator - Update Port of Debarkation - Port not updated when new port ID is nil", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePODFSC,
},
},
}, nil)
podId := uuid.FromStringOrNil("b6e94f5b-33c0-43f3-b960-7c7b2a4ee5fc")
oldServiceItemPrime.PODLocationID = &podId

newServiceItemPrime := oldServiceItemPrime
newServiceItemPrime.PODLocationID = nil
newServiceItemPrime.PODLocation = &models.PortLocation{}

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
updatedServiceItem, err := ValidateUpdateMTOServiceItem(suite.AppContextForTest(), &serviceItemData, UpdateMTOServiceItemPrimeValidator)

suite.NoError(err)
suite.NotNil(updatedServiceItem)
suite.IsType(models.MTOServiceItem{}, *updatedServiceItem)
suite.NotEqual(oldServiceItemPrime.PODLocationID, newServiceItemPrime.PODLocationID)
suite.Equal(oldServiceItemPrime.PODLocationID, updatedServiceItem.PODLocationID)
})

// Test failure Prime validation for Port of Embarkation
suite.Run("UpdateMTOServiceItemPrimeValidator - Update Port of Debarkation - Port not updated wrong service code is supplied", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePOEFSC,
},
},
}, nil)
podId := uuid.FromStringOrNil("b6e94f5b-33c0-43f3-b960-7c7b2a4ee5fc")
oldServiceItemPrime.PODLocationID = &podId

newServiceItemPrime := oldServiceItemPrime
newServiceItemPrime.PODLocationID = nil
newServiceItemPrime.PODLocation = &models.PortLocation{}

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
updatedServiceItem, err := ValidateUpdateMTOServiceItem(suite.AppContextForTest(), &serviceItemData, UpdateMTOServiceItemPrimeValidator)

suite.Error(err)
suite.Empty(updatedServiceItem)
suite.Contains(err.Error(), "is in a conflicting state POD Location can only be updated for service item PODFSC")
})

// Test successful Prime validation
suite.Run("UpdateMTOServiceItemPrimeValidator - success", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
Expand Down
180 changes: 180 additions & 0 deletions pkg/services/mto_service_item/mto_service_item_validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,186 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() {
suite.Error(err)
suite.IsType(apperror.InvalidInputError{}, err)
})

suite.Run("checkPortLocation - updating poe location succeeds for POEFSC service item", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePOEFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime

// Try to update SITDestinationOriginalAddress
newPortLocation := models.PortLocation{}
newServiceItemPrime.POELocation = &newPortLocation

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
err := serviceItemData.checkPortLocation(suite.AppContextForTest())

suite.NoError(err)
})

suite.Run("checkPortLocation - updating poe location fails for PODFSC service item", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePODFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime

// Try to update SITDestinationOriginalAddress
newPortLocation := models.PortLocation{}
newServiceItemPrime.POELocation = &newPortLocation

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
err := serviceItemData.checkPortLocation(suite.AppContextForTest())

suite.Error(err)
suite.IsType(apperror.ConflictError{}, err)
})

suite.Run("checkPortLocation - updating poe location fails for other service items", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodeFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime

// Try to update SITDestinationOriginalAddress
newPortLocation := models.PortLocation{}
newServiceItemPrime.POELocation = &newPortLocation

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
err := serviceItemData.checkPortLocation(suite.AppContextForTest())

suite.Error(err)
suite.IsType(apperror.ConflictError{}, err)
suite.Contains(err.Error(), "- Port Location may only be manually updated for the following service items: PODFSC, POEFSC")
})

suite.Run("checkPortLocation - updating pod location succeeds for PODFSC service item", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePODFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime

// Try to update SITDestinationOriginalAddress
newPortLocation := models.PortLocation{}
newServiceItemPrime.PODLocation = &newPortLocation

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
err := serviceItemData.checkPortLocation(suite.AppContextForTest())

suite.NoError(err)
})

suite.Run("checkPortLocation - updating pod location fails for POEFSC service item", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePOEFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime

// Try to update SITDestinationOriginalAddress
newPortLocation := models.PortLocation{}
newServiceItemPrime.PODLocation = &newPortLocation

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
err := serviceItemData.checkPortLocation(suite.AppContextForTest())

suite.Error(err)
suite.IsType(apperror.ConflictError{}, err)
})

suite.Run("checkPortLocation - updating pod location fails for other service items", func() {
oldServiceItemPrime := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: factory.BuildAvailableToPrimeMove(suite.DB(), nil, nil),
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodeFSC,
},
},
}, nil)
newServiceItemPrime := oldServiceItemPrime

// Try to update SITDestinationOriginalAddress
newPortLocation := models.PortLocation{}
newServiceItemPrime.PODLocation = &newPortLocation

serviceItemData := updateMTOServiceItemData{
updatedServiceItem: newServiceItemPrime,
oldServiceItem: oldServiceItemPrime,
verrs: validate.NewErrors(),
availabilityChecker: checker,
}
err := serviceItemData.checkPortLocation(suite.AppContextForTest())

suite.Error(err)
suite.IsType(apperror.ConflictError{}, err)
suite.Contains(err.Error(), "- Port Location may only be manually updated for the following service items: PODFSC, POEFSC")
})
}

func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItemValidators() {
Expand Down
Loading