@@ -529,6 +529,121 @@ void buildChangeAddressUpdateActions_WithNullAddresses_ShouldNotReturnChangeAddr
529529 assertThat (updateActions ).isEmpty ();
530530 }
531531
532+ @ Test
533+ void buildChangeAddressUpdateActions_WithDifferentState_ShouldReturnChangeAddressAction () {
534+
535+ when (oldCustomer .getAddresses ())
536+ .thenReturn (
537+ singletonList (
538+ AddressBuilder .of ()
539+ .country (CountryCode .US .toString ())
540+ .key ("address-key-1" )
541+ .id ("address-id-1" )
542+ .state ("California" )
543+ .build ()));
544+
545+ final AddressDraft address1 =
546+ AddressDraftBuilder .of ()
547+ .country (CountryCode .US .toString ())
548+ .key ("address-key-1" )
549+ .state ("Texas" )
550+ .id ("address-id-new-1" )
551+ .build ();
552+
553+ final CustomerDraft newCustomer =
554+ CustomerDraftBuilder .of ()
555+ .email ("email" )
556+ .password ("pass" )
557+ .addresses (singletonList (address1 ))
558+ .build ();
559+
560+ final List <CustomerUpdateAction > updateActions =
561+ CustomerUpdateActionUtils .buildChangeAddressUpdateActions (oldCustomer , newCustomer );
562+
563+ assertThat (updateActions )
564+ .containsExactly (
565+ CustomerChangeAddressActionBuilder .of ()
566+ .addressId ("address-id-1" )
567+ .address (address1 )
568+ .build ());
569+ }
570+
571+ @ Test
572+ void
573+ buildChangeAddressUpdateActions_WithDifferentAdditionalStreetInfo_ShouldReturnChangeAddressAction () {
574+
575+ when (oldCustomer .getAddresses ())
576+ .thenReturn (
577+ singletonList (
578+ AddressBuilder .of ()
579+ .country (CountryCode .US .toString ())
580+ .key ("address-key-1" )
581+ .id ("address-id-1" )
582+ .additionalStreetInfo ("Suite 100" )
583+ .build ()));
584+
585+ final AddressDraft address1 =
586+ AddressDraftBuilder .of ()
587+ .country (CountryCode .US .toString ())
588+ .key ("address-key-1" )
589+ .additionalStreetInfo ("Suite 200" )
590+ .id ("address-id-new-1" )
591+ .build ();
592+
593+ final CustomerDraft newCustomer =
594+ CustomerDraftBuilder .of ()
595+ .email ("email" )
596+ .password ("pass" )
597+ .addresses (singletonList (address1 ))
598+ .build ();
599+
600+ final List <CustomerUpdateAction > updateActions =
601+ CustomerUpdateActionUtils .buildChangeAddressUpdateActions (oldCustomer , newCustomer );
602+
603+ assertThat (updateActions )
604+ .containsExactly (
605+ CustomerChangeAddressActionBuilder .of ()
606+ .addressId ("address-id-1" )
607+ .address (address1 )
608+ .build ());
609+ }
610+
611+ @ Test
612+ void
613+ buildChangeAddressUpdateActions_WithSameStateAndAdditionalStreetInfo_ShouldNotReturnAction () {
614+
615+ when (oldCustomer .getAddresses ())
616+ .thenReturn (
617+ singletonList (
618+ AddressBuilder .of ()
619+ .country (CountryCode .US .toString ())
620+ .key ("address-key-1" )
621+ .id ("address-id-1" )
622+ .state ("California" )
623+ .additionalStreetInfo ("Suite 100" )
624+ .build ()));
625+
626+ final CustomerDraft newCustomer =
627+ CustomerDraftBuilder .of ()
628+ .email ("email" )
629+ .password ("pass" )
630+ .addresses (
631+ singletonList (
632+ AddressBuilder .of ()
633+ .country (CountryCode .US .toString ())
634+ .key ("address-key-1" )
635+ .id ("address-id-new-1" )
636+ .state ("California" )
637+ .additionalStreetInfo ("Suite 100" )
638+ .build ()))
639+ .build ();
640+
641+ final List <CustomerUpdateAction > updateActions =
642+ CustomerUpdateActionUtils .buildChangeAddressUpdateActions (oldCustomer , newCustomer );
643+
644+ assertThat (updateActions ).isEmpty ();
645+ }
646+
532647 @ Test
533648 void
534649 buildChangeAddressUpdateActions_WithAddressesWithoutKeys_ShouldNotReturnChangeAddressActions () {
0 commit comments