Skip to content

Commit

Permalink
Merge pull request #14467 from transcom/B-21170-Integration
Browse files Browse the repository at this point in the history
B 21170 INT 2 - Ensure USPostRegionsCitiesID populates in a scenarios
  • Loading branch information
ajlusk authored Jan 6, 2025
2 parents 751d15d + bc76751 commit 80acfae
Show file tree
Hide file tree
Showing 18 changed files with 254 additions and 87 deletions.
2 changes: 1 addition & 1 deletion pkg/handlers/primeapi/mto_shipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type DeleteMTOShipmentHandler struct {
services.ShipmentDeleter
}

// Handle handler that updates a mto shipment
// Handle handler that deletes a mto shipment
func (h DeleteMTOShipmentHandler) Handle(params mtoshipmentops.DeleteMTOShipmentParams) middleware.Responder {
return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest,
func(appCtx appcontext.AppContext) (middleware.Responder, error) {
Expand Down
9 changes: 8 additions & 1 deletion pkg/handlers/primeapi/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ func Address(address *models.Address) *primemessages.Address {
if address == nil {
return nil
}
return &primemessages.Address{

payloadAddress := &primemessages.Address{
ID: strfmt.UUID(address.ID.String()),
StreetAddress1: &address.StreetAddress1,
StreetAddress2: address.StreetAddress2,
Expand All @@ -301,6 +302,12 @@ func Address(address *models.Address) *primemessages.Address {
County: address.County,
ETag: etag.GenerateEtag(address.UpdatedAt),
}

if address.UsPostRegionCityID != nil && address.UsPostRegionCityID != &uuid.Nil {
payloadAddress.UsPostRegionCitiesID = strfmt.UUID(address.UsPostRegionCityID.String())
}

return payloadAddress
}

// StorageFacility payload
Expand Down
27 changes: 27 additions & 0 deletions pkg/handlers/primeapi/payloads/model_to_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,33 @@ func (suite *PayloadsSuite) TestShipmentAddressUpdate() {
suite.Equal(strfmt.UUID(shipmentAddressUpdate.ID.String()), result.ID)
}

func (suite *PayloadsSuite) TestAddress() {
usprcId := uuid.Must(uuid.NewV4())
shipmentAddress := &models.Address{
ID: uuid.Must(uuid.NewV4()),
StreetAddress1: "400 Drive St",
City: "Charleston",
County: models.StringPointer("Charleston"),
State: "SC",
PostalCode: "29404",
UsPostRegionCityID: &usprcId,
}

result := Address(shipmentAddress)
suite.NotNil(result)
suite.Equal(strfmt.UUID(shipmentAddress.ID.String()), result.ID)
suite.Equal(strfmt.UUID(usprcId.String()), result.UsPostRegionCitiesID)

result = Address(nil)
suite.Nil(result)

usprcId = uuid.Nil
shipmentAddress.UsPostRegionCityID = &uuid.Nil
result = Address(shipmentAddress)
suite.NotNil(result)
suite.Equal(strfmt.UUID(""), result.UsPostRegionCitiesID)
}

func (suite *PayloadsSuite) TestMTOServiceItemDCRTandDOFSITandDDFSIT() {
reServiceCode := models.ReServiceCodeDCRT
reServiceCodeSIT := models.ReServiceCodeDOFSIT
Expand Down
5 changes: 5 additions & 0 deletions pkg/handlers/primeapi/payloads/payload_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func AddressModel(address *primemessages.Address) *models.Address {
ID: uuid.FromStringOrNil(address.ID.String()),
StreetAddress2: address.StreetAddress2,
StreetAddress3: address.StreetAddress3,
County: address.County,
}
if address.StreetAddress1 != nil {
modelAddress.StreetAddress1 = *address.StreetAddress1
Expand All @@ -56,6 +57,10 @@ func AddressModel(address *primemessages.Address) *models.Address {
if address.Country != nil {
modelAddress.Country = CountryModel(address.Country)
}
usPostRegionCitiesID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String())
if usPostRegionCitiesID != uuid.Nil {
modelAddress.UsPostRegionCityID = &usPostRegionCitiesID
}
return modelAddress
}

Expand Down
24 changes: 15 additions & 9 deletions pkg/handlers/primeapi/payloads/payload_to_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
originPostalCode := "90210"
originStreet1 := "123 Rodeo Dr."
originCounty1 := "LOS ANGELES"
originUSPRCID := strfmt.UUID(uuid.Must(uuid.NewV4()).String())
sitHHGActualOriginAddress := primemessages.Address{
State: &originState,
City: &originCity,
PostalCode: &originPostalCode,
StreetAddress1: &originStreet1,
County: &originCounty1,
State: &originState,
City: &originCity,
PostalCode: &originPostalCode,
StreetAddress1: &originStreet1,
County: &originCounty1,
UsPostRegionCitiesID: originUSPRCID,
}

destReason := "service member will pick up from storage at destination"
Expand All @@ -83,11 +85,13 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
destPostalCode := "90210"
destCounty := "LOS ANGELES"
destStreet := "123 Rodeo Dr."
destUSPRCID := strfmt.UUID(uuid.Must(uuid.NewV4()).String())
sitFinalDestAddress := primemessages.Address{
City: &destCity,
PostalCode: &destPostalCode,
StreetAddress1: &destStreet,
County: &destCounty,
City: &destCity,
PostalCode: &destPostalCode,
StreetAddress1: &destStreet,
County: &destCounty,
UsPostRegionCitiesID: destUSPRCID,
}

destServiceItem := &primemessages.MTOServiceItemDestSIT{
Expand Down Expand Up @@ -333,6 +337,7 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
suite.Equal(models.ReServiceCodeDDFSIT, returnedModel.ReService.Code)
suite.Equal(destPostalCode, returnedModel.SITDestinationFinalAddress.PostalCode)
suite.Equal(destStreet, returnedModel.SITDestinationFinalAddress.StreetAddress1)
suite.Equal(destUSPRCID.String(), returnedModel.SITDestinationFinalAddress.UsPostRegionCityID.String())
})

suite.Run("Success - Returns SIT destination service item model without customer contact fields", func() {
Expand All @@ -352,6 +357,7 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
suite.Equal(models.ReServiceCodeDDFSIT, returnedModel.ReService.Code)
suite.Equal(destPostalCode, returnedModel.SITDestinationFinalAddress.PostalCode)
suite.Equal(destStreet, returnedModel.SITDestinationFinalAddress.StreetAddress1)
suite.Equal(destUSPRCID.String(), returnedModel.SITDestinationFinalAddress.UsPostRegionCityID.String())
suite.Equal(destReason, *returnedModel.Reason)
})
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/handlers/primeapiv2/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func Address(address *models.Address) *primev2messages.Address {
if address == nil {
return nil
}
return &primev2messages.Address{
payloadAddress := &primev2messages.Address{
ID: strfmt.UUID(address.ID.String()),
StreetAddress1: &address.StreetAddress1,
StreetAddress2: address.StreetAddress2,
Expand All @@ -232,6 +232,12 @@ func Address(address *models.Address) *primev2messages.Address {
County: address.County,
ETag: etag.GenerateEtag(address.UpdatedAt),
}

if address.UsPostRegionCityID != nil && address.UsPostRegionCityID != &uuid.Nil {
payloadAddress.UsPostRegionCitiesID = strfmt.UUID(address.UsPostRegionCityID.String())
}

return payloadAddress
}

// StorageFacility payload
Expand Down
27 changes: 27 additions & 0 deletions pkg/handlers/primeapiv2/payloads/model_to_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,3 +941,30 @@ func (suite *PayloadsSuite) TestMarketCode() {
suite.Equal("i", result, "Expected result to be 'i' for international market code")
})
}

func (suite *PayloadsSuite) TestAddress() {
usprcId := uuid.Must(uuid.NewV4())
shipmentAddress := &models.Address{
ID: uuid.Must(uuid.NewV4()),
StreetAddress1: "400 Drive St",
City: "Charleston",
County: models.StringPointer("Charleston"),
State: "SC",
PostalCode: "29404",
UsPostRegionCityID: &usprcId,
}

result := Address(shipmentAddress)
suite.NotNil(result)
suite.Equal(strfmt.UUID(shipmentAddress.ID.String()), result.ID)
suite.Equal(strfmt.UUID(usprcId.String()), result.UsPostRegionCitiesID)

result = Address(nil)
suite.Nil(result)

usprcId = uuid.Nil
shipmentAddress.UsPostRegionCityID = &uuid.Nil
result = Address(shipmentAddress)
suite.NotNil(result)
suite.Equal(strfmt.UUID(""), result.UsPostRegionCitiesID)
}
5 changes: 5 additions & 0 deletions pkg/handlers/primeapiv2/payloads/payload_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func AddressModel(address *primev2messages.Address) *models.Address {
ID: uuid.FromStringOrNil(address.ID.String()),
StreetAddress2: address.StreetAddress2,
StreetAddress3: address.StreetAddress3,
County: address.County,
}
if address.StreetAddress1 != nil {
modelAddress.StreetAddress1 = *address.StreetAddress1
Expand All @@ -56,6 +57,10 @@ func AddressModel(address *primev2messages.Address) *models.Address {
if address.Country != nil {
modelAddress.Country = CountryModel(address.Country)
}
usPostRegionCitiesID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String())
if usPostRegionCitiesID != uuid.Nil {
modelAddress.UsPostRegionCityID = &usPostRegionCitiesID
}
return modelAddress
}

Expand Down
10 changes: 7 additions & 3 deletions pkg/handlers/primeapiv2/payloads/payload_to_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
destCity := "Beverly Hills"
destPostalCode := "90210"
destStreet := "123 Rodeo Dr."
destUSPRCID := strfmt.UUID(uuid.Must(uuid.NewV4()).String())
sitFinalDestAddress := primev2messages.Address{
City: &destCity,
PostalCode: &destPostalCode,
StreetAddress1: &destStreet,
City: &destCity,
PostalCode: &destPostalCode,
StreetAddress1: &destStreet,
UsPostRegionCitiesID: destUSPRCID,
}

destServiceItem := &primev2messages.MTOServiceItemDestSIT{
Expand Down Expand Up @@ -291,6 +293,7 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
suite.Equal(models.ReServiceCodeDDFSIT, returnedModel.ReService.Code)
suite.Equal(destPostalCode, returnedModel.SITDestinationFinalAddress.PostalCode)
suite.Equal(destStreet, returnedModel.SITDestinationFinalAddress.StreetAddress1)
suite.Equal(destUSPRCID.String(), returnedModel.SITDestinationFinalAddress.UsPostRegionCityID.String())
})

suite.Run("Success - Returns SIT destination service item model without customer contact fields", func() {
Expand All @@ -310,6 +313,7 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
suite.Equal(models.ReServiceCodeDDFSIT, returnedModel.ReService.Code)
suite.Equal(destPostalCode, returnedModel.SITDestinationFinalAddress.PostalCode)
suite.Equal(destStreet, returnedModel.SITDestinationFinalAddress.StreetAddress1)
suite.Equal(destUSPRCID.String(), returnedModel.SITDestinationFinalAddress.UsPostRegionCityID.String())
suite.Equal(destReason, *returnedModel.Reason)
})
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/handlers/primeapiv3/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func Address(address *models.Address) *primev3messages.Address {
if address == nil {
return nil
}
return &primev3messages.Address{
payloadAddress := &primev3messages.Address{
ID: strfmt.UUID(address.ID.String()),
StreetAddress1: &address.StreetAddress1,
StreetAddress2: address.StreetAddress2,
Expand All @@ -260,6 +260,12 @@ func Address(address *models.Address) *primev3messages.Address {
County: address.County,
DestinationGbloc: address.DestinationGbloc,
}

if address.UsPostRegionCityID != nil && address.UsPostRegionCityID != &uuid.Nil {
payloadAddress.UsPostRegionCitiesID = strfmt.UUID(address.UsPostRegionCityID.String())
}

return payloadAddress
}

// PPM Destination payload
Expand Down
26 changes: 26 additions & 0 deletions pkg/handlers/primeapiv3/payloads/model_to_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,3 +1397,29 @@ func (suite *PayloadsSuite) TestMTOServiceItemPODFSC() {
suite.Equal(mtoPayload.MtoShipments[0].PortOfDebarkation.Zip, portLocation.UsPostRegionCity.UsprZipID)
suite.Equal(mtoPayload.MtoShipments[0].PortOfDebarkation.Country, portLocation.Country.CountryName)
}
func (suite *PayloadsSuite) TestAddress() {
usprcId := uuid.Must(uuid.NewV4())
shipmentAddress := &models.Address{
ID: uuid.Must(uuid.NewV4()),
StreetAddress1: "400 Drive St",
City: "Charleston",
County: models.StringPointer("Charleston"),
State: "SC",
PostalCode: "29404",
UsPostRegionCityID: &usprcId,
}

result := Address(shipmentAddress)
suite.NotNil(result)
suite.Equal(strfmt.UUID(shipmentAddress.ID.String()), result.ID)
suite.Equal(strfmt.UUID(usprcId.String()), result.UsPostRegionCitiesID)

result = Address(nil)
suite.Nil(result)

usprcId = uuid.Nil
shipmentAddress.UsPostRegionCityID = &uuid.Nil
result = Address(shipmentAddress)
suite.NotNil(result)
suite.Equal(strfmt.UUID(""), result.UsPostRegionCitiesID)
}
11 changes: 11 additions & 0 deletions pkg/handlers/primeapiv3/payloads/payload_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func AddressModel(address *primev3messages.Address) *models.Address {
ID: uuid.FromStringOrNil(address.ID.String()),
StreetAddress2: address.StreetAddress2,
StreetAddress3: address.StreetAddress3,
County: address.County,
}
if address.StreetAddress1 != nil {
modelAddress.StreetAddress1 = *address.StreetAddress1
Expand All @@ -57,6 +58,10 @@ func AddressModel(address *primev3messages.Address) *models.Address {
if address.Country != nil {
modelAddress.Country = CountryModel(address.Country)
}
usPostRegionCitiesID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String())
if usPostRegionCitiesID != uuid.Nil {
modelAddress.UsPostRegionCityID = &usPostRegionCitiesID
}
return modelAddress
}

Expand Down Expand Up @@ -94,6 +99,10 @@ func PPMDestinationAddressModel(address *primev3messages.PPMDestinationAddress)
if address.Country != nil {
modelAddress.Country = CountryModel(address.Country)
}
usPostRegionCitiesID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String())
if usPostRegionCitiesID != uuid.Nil {
modelAddress.UsPostRegionCityID = &usPostRegionCitiesID
}
return modelAddress
}

Expand Down Expand Up @@ -203,6 +212,8 @@ func MTOShipmentModelFromCreate(mtoShipment *primev3messages.CreateMTOShipment)
CounselorRemarks: mtoShipment.CounselorRemarks,
HasSecondaryPickupAddress: handlers.FmtBool(false),
HasSecondaryDeliveryAddress: handlers.FmtBool(false),
HasTertiaryPickupAddress: handlers.FmtBool(false),
HasTertiaryDeliveryAddress: handlers.FmtBool(false),
}

if mtoShipment.ShipmentType != nil {
Expand Down
Loading

0 comments on commit 80acfae

Please sign in to comment.