Skip to content

Commit

Permalink
refactor:参照から値への変更
Browse files Browse the repository at this point in the history
Refactor Customer address fields into Address object

Replaced individual address fields (postal code, prefecture, etc.) in `Customer` with a structured `Address` object. Updated related test cases, mappers, and methods to align with the new `Address` structure for improved maintainability and encapsulation.
  • Loading branch information
k2works committed Jan 11, 2025
1 parent ec3238e commit d19dc24
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ public class Customer {
String companyRepresentativeCode; // 自社担当者コード
String customerRepresentativeName; // 顧客担当者名
String customerDepartmentName; // 顧客部門名
String customerPostalCode; // 顧客郵便番号
String customerPrefecture; // 顧客都道府県
String customerAddress1; // 顧客住所1
String customerAddress2; // 顧客住所2
Address customerAddress; // 顧客住所
String customerPhoneNumber; // 顧客電話番号
String customerFaxNumber; // 顧客fax番号
String customerEmailAddress; // 顧客メールアドレス
Expand Down Expand Up @@ -79,10 +76,12 @@ public static Customer of(
companyRepresentativeCode,
customerRepresentativeName,
customerDepartmentName,
customerPostalCode,
customerPrefecture,
customerAddress1,
customerAddress2,
Address.of(
customerPostalCode,
customerPrefecture,
customerAddress1,
customerAddress2
),
customerPhoneNumber,
customerFaxNumber,
customerEmailAddress,
Expand All @@ -109,10 +108,7 @@ public static Customer of(Customer customer, List<Shipping> shippings) {
customer.companyRepresentativeCode,
customer.customerRepresentativeName,
customer.customerDepartmentName,
customer.customerPostalCode,
customer.customerPrefecture,
customer.customerAddress1,
customer.customerAddress2,
customer.customerAddress,
customer.customerPhoneNumber,
customer.customerFaxNumber,
customer.customerEmailAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public Partner mapToDomainModel(PartnerCustomEntity partnerCustomEntity) {
customerEntity.set自社担当者コード(customer.getCompanyRepresentativeCode());
customerEntity.set顧客担当者名(customer.getCustomerRepresentativeName());
customerEntity.set顧客部門名(customer.getCustomerDepartmentName());
customerEntity.set顧客郵便番号(customer.getCustomerPostalCode());
customerEntity.set顧客都道府県(customer.getCustomerPrefecture());
customerEntity.set顧客住所1(customer.getCustomerAddress1());
customerEntity.set顧客住所2(customer.getCustomerAddress2());
customerEntity.set顧客郵便番号(customer.getCustomerAddress().getPostalCode().getValue());
customerEntity.set顧客都道府県(customer.getCustomerAddress().getPrefecture().toString());
customerEntity.set顧客住所1(customer.getCustomerAddress().getAddress1());
customerEntity.set顧客住所2(customer.getCustomerAddress().getAddress2());
customerEntity.set顧客電話番号(customer.getCustomerPhoneNumber());
customerEntity.set顧客fax番号(customer.getCustomerFaxNumber());
customerEntity.set顧客メールアドレス(customer.getCustomerEmailAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void shouldCreateCustomer() {
() -> assertEquals("RE001", customer.getCompanyRepresentativeCode()),
() -> assertEquals("花子", customer.getCustomerRepresentativeName()),
() -> assertEquals("営業部", customer.getCustomerDepartmentName()),
() -> assertEquals("123-4567", customer.getCustomerPostalCode()),
() -> assertEquals("東京都", customer.getCustomerPrefecture()),
() -> assertEquals("新宿区1-1-1", customer.getCustomerAddress1()),
() -> assertEquals("マンション101号室", customer.getCustomerAddress2()),
() -> assertEquals("1234567", customer.getCustomerAddress().getPostalCode().getValue()),
() -> assertEquals("東京都", customer.getCustomerAddress().getPrefecture().toString()),
() -> assertEquals("新宿区1-1-1", customer.getCustomerAddress().getAddress1()),
() -> assertEquals("マンション101号室", customer.getCustomerAddress().getAddress2()),
() -> assertEquals("03-1234-5678", customer.getCustomerPhoneNumber()),
() -> assertEquals("03-1234-5679", customer.getCustomerFaxNumber()),
() -> assertEquals("[email protected]", customer.getCustomerEmailAddress()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ void shouldUpdateCustomer() {
updatedCustomer.getCompanyRepresentativeCode(),
updatedCustomer.getCustomerRepresentativeName(),
updatedCustomer.getCustomerDepartmentName(),
updatedCustomer.getCustomerPostalCode(),
updatedCustomer.getCustomerPrefecture(),
updatedCustomer.getCustomerAddress1(),
updatedCustomer.getCustomerAddress2(),
updatedCustomer.getCustomerAddress().getPostalCode().getValue(),
updatedCustomer.getCustomerAddress().getPrefecture().toString(),
updatedCustomer.getCustomerAddress().getAddress1(),
updatedCustomer.getCustomerAddress().getAddress2(),
updatedCustomer.getCustomerPhoneNumber(),
updatedCustomer.getCustomerFaxNumber(),
updatedCustomer.getCustomerEmailAddress(),
Expand Down

0 comments on commit d19dc24

Please sign in to comment.