Skip to content

Commit b0b8948

Browse files
authored
CC-153 Rename CustomerCompanyData (#142)
1 parent 4763d36 commit b0b8948

File tree

7 files changed

+46
-41
lines changed

7 files changed

+46
-41
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ Consists of internal refactorings and improvements.
1919
* Renamed `AbstractTransaction` -> `BaseTransaction`
2020
* Refactored `UrlUtil`: moved Resource URL construction logic to `Resource`-classes.
2121
* Every Unzer Payment Gateway resource implements `Resource` instead of `PaymentType`: `Customer`, `Basket`, `Payment`, etc.
22+
* Renamed `com.unzer.payment.CustomerCompanyData` to `CompanyInfo`
23+
* Renamed property and methods of `com.unzer.payment.Customer.Customer` to match class name:
24+
* property `companyData`-> `companyInfo`
25+
* method `getCompanyData()` -> `getCompanyInfo()`
26+
* method `setCompanyData()` -> `setCompanyInfo()`
2227

2328
### Removed
2429

src/main/java/com/unzer/payment/CustomerCompanyData.java renamed to src/main/java/com/unzer/payment/CompanyInfo.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.text.SimpleDateFormat;
77
import java.util.Date;
88

9-
public class CustomerCompanyData {
9+
public class CompanyInfo {
1010
private CompanyType companyType;
1111
private Owner owner;
1212
private RegistrationType registrationType;
@@ -17,7 +17,7 @@ public CompanyType getCompanyType() {
1717
return companyType;
1818
}
1919

20-
public CustomerCompanyData setCompanyType(CompanyType companyType) {
20+
public CompanyInfo setCompanyType(CompanyType companyType) {
2121
this.companyType = companyType;
2222
return this;
2323
}
@@ -26,7 +26,7 @@ public Owner getOwner() {
2626
return owner;
2727
}
2828

29-
public CustomerCompanyData setOwner(Owner owner) {
29+
public CompanyInfo setOwner(Owner owner) {
3030
this.owner = owner;
3131
return this;
3232
}
@@ -35,7 +35,7 @@ public RegistrationType getRegistrationType() {
3535
return registrationType;
3636
}
3737

38-
public CustomerCompanyData setRegistrationType(RegistrationType registrationType) {
38+
public CompanyInfo setRegistrationType(RegistrationType registrationType) {
3939
this.registrationType = registrationType;
4040
return this;
4141
}
@@ -44,7 +44,7 @@ public String getCommercialRegisterNumber() {
4444
return commercialRegisterNumber;
4545
}
4646

47-
public CustomerCompanyData setCommercialRegisterNumber(String commercialRegisterNumber) {
47+
public CompanyInfo setCommercialRegisterNumber(String commercialRegisterNumber) {
4848
this.commercialRegisterNumber = commercialRegisterNumber;
4949
return this;
5050
}
@@ -53,7 +53,7 @@ public CommercialSector getCommercialSector() {
5353
return commercialSector;
5454
}
5555

56-
public CustomerCompanyData setCommercialSector(CommercialSector commercialSector) {
56+
public CompanyInfo setCommercialSector(CommercialSector commercialSector) {
5757
this.commercialSector = commercialSector;
5858
return this;
5959
}

src/main/java/com/unzer/payment/Customer.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class Customer extends BaseResource {
3434
*/
3535
private Locale language;
3636

37-
private CustomerCompanyData companyData;
37+
private CompanyInfo companyInfo;
3838

3939
public Customer(String firstname, String lastname) {
4040
super();
@@ -146,12 +146,12 @@ public Customer setShippingAddress(Address shippingAddress) {
146146
return this;
147147
}
148148

149-
public CustomerCompanyData getCompanyData() {
150-
return companyData;
149+
public CompanyInfo getCompanyInfo() {
150+
return companyInfo;
151151
}
152152

153-
public void setCompanyData(CustomerCompanyData companyData) {
154-
this.companyData = companyData;
153+
public void setCompanyInfo(CompanyInfo companyInfo) {
154+
this.companyInfo = companyInfo;
155155
}
156156

157157
public String getCompany() {

src/main/java/com/unzer/payment/communication/json/JsonCompanyInfo.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.unzer.payment.communication.json;
22

3-
import com.unzer.payment.CustomerCompanyData;
3+
import com.unzer.payment.CompanyInfo;
44

55
public class JsonCompanyInfo {
66

77
private String registrationType;
88
private String commercialRegisterNumber;
99
private String function;
1010
private String commercialSector;
11-
private CustomerCompanyData.CompanyType companyType;
12-
private CustomerCompanyData.Owner owner;
11+
private CompanyInfo.CompanyType companyType;
12+
private CompanyInfo.Owner owner;
1313

1414
public String getRegistrationType() {
1515
return registrationType;
@@ -46,11 +46,11 @@ public void setCommercialSector(String commercialSector) {
4646
this.commercialSector = commercialSector;
4747
}
4848

49-
public CustomerCompanyData.CompanyType getCompanyType() {
49+
public CompanyInfo.CompanyType getCompanyType() {
5050
return companyType;
5151
}
5252

53-
public void setCompanyType(CustomerCompanyData.CompanyType companyType) {
53+
public void setCompanyType(CompanyInfo.CompanyType companyType) {
5454
this.companyType = companyType;
5555
}
5656
}

src/main/java/com/unzer/payment/communication/mapper/ApiToSdkConverter.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ public ApiCustomer map(Customer src) {
346346

347347
out.setBillingAddress(src.getBillingAddress());
348348
out.setShippingAddress(src.getShippingAddress());
349-
out.setCompanyInfo(getCompanyInfo(src.getCompanyData(), src.getCompany()));
349+
out.setCompanyInfo(getCompanyInfo(src.getCompanyInfo(), src.getCompany()));
350350
return out;
351351
}
352352

353-
private JsonCompanyInfo getCompanyInfo(CustomerCompanyData src, String company) {
353+
private JsonCompanyInfo getCompanyInfo(CompanyInfo src, String company) {
354354
if (src == null) {
355355
return null;
356356
}
@@ -363,12 +363,12 @@ private JsonCompanyInfo getCompanyInfo(CustomerCompanyData src, String company)
363363
return out;
364364
}
365365

366-
private void mapRegisteredCompany(CustomerCompanyData src, JsonCompanyInfo out) {
366+
private void mapRegisteredCompany(CompanyInfo src, JsonCompanyInfo out) {
367367
out.setRegistrationType("registered");
368368
out.setCommercialRegisterNumber(src.getCommercialRegisterNumber());
369369
}
370370

371-
private void mapUnregisteredCompany(CustomerCompanyData src, JsonCompanyInfo out) {
371+
private void mapUnregisteredCompany(CompanyInfo src, JsonCompanyInfo out) {
372372
out.setFunction("OWNER");
373373
out.setRegistrationType("not_registered");
374374
if (src.getCommercialSector() != null) {
@@ -395,25 +395,25 @@ public Customer mapToBusinessObject(ApiCustomer src, Customer out) {
395395

396396
out.setBillingAddress(src.getBillingAddress());
397397
out.setShippingAddress(src.getShippingAddress());
398-
out.setCompanyData(getCompanyInfo(src.getCompanyInfo()));
398+
out.setCompanyInfo(getCompanyInfo(src.getCompanyInfo()));
399399
return out;
400400
}
401401

402-
private CustomerCompanyData getCompanyInfo(JsonCompanyInfo src) {
402+
private CompanyInfo getCompanyInfo(JsonCompanyInfo src) {
403403
if (src == null) {
404404
return null;
405405
}
406406
if (allFieldsNull(src)) {
407407
return null;
408408
}
409-
CustomerCompanyData out = new CustomerCompanyData();
409+
CompanyInfo out = new CompanyInfo();
410410
out.setCommercialRegisterNumber(src.getCommercialRegisterNumber());
411411
if (src.getCommercialSector() != null) {
412412
out.setCommercialSector(CommercialSector.valueOf(src.getCommercialSector()));
413413
}
414414
if (src.getRegistrationType() != null) {
415415
out.setRegistrationType(
416-
CustomerCompanyData.RegistrationType.valueOf(src.getRegistrationType().toUpperCase()));
416+
CompanyInfo.RegistrationType.valueOf(src.getRegistrationType().toUpperCase()));
417417
}
418418
return out;
419419
}

src/test/java/com/unzer/payment/business/AbstractPaymentTest.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -290,42 +290,42 @@ protected Customer getMaximumUnknownCustomer(String customerId) {
290290
protected Customer getRegisterdMinimumBusinessCustomer() {
291291
Customer customer = getMinimumRegisteredCustomer();
292292
customer.setBillingAddress(getAddress());
293-
customer.setCompanyData(getRegisteredCompanyData());
293+
customer.setCompanyInfo(getRegisteredCompanyInfo());
294294
return customer;
295295
}
296296

297297
protected Customer getRegisterdMaximumBusinessCustomer(String customerId) throws ParseException {
298298
Customer customer = getMaximumCustomer(customerId);
299299
customer.setCompany("Unzer E-Com GmbH");
300-
getUnregisteredCompanyData();
301-
customer.setCompanyData(getRegisteredCompanyData());
300+
getUnregisteredCompanyInfo();
301+
customer.setCompanyInfo(getRegisteredCompanyInfo());
302302
return customer;
303303
}
304304

305305
protected Customer getUnRegisterdMinimumBusinessCustomer() throws ParseException {
306306
Customer customer = getMinimumCustomer();
307307
customer.setBillingAddress(getAddress());
308308

309-
customer.setCompanyData(getUnregisteredCompanyData());
309+
customer.setCompanyInfo(getUnregisteredCompanyInfo());
310310
return customer;
311311
}
312312

313313
protected Customer getUnRegisterdMaximumBusinessCustomer() throws ParseException {
314314
Customer customer = getMaximumCustomer(generateUuid());
315-
customer.setCompanyData(getUnregisteredCompanyData());
315+
customer.setCompanyInfo(getUnregisteredCompanyInfo());
316316
return customer;
317317
}
318318

319-
protected CustomerCompanyData getUnregisteredCompanyData() {
320-
CustomerCompanyData business = new CustomerCompanyData();
319+
protected CompanyInfo getUnregisteredCompanyInfo() {
320+
CompanyInfo business = new CompanyInfo();
321321
business.setCommercialRegisterNumber("HRB337681 MANNHEIM");
322322
return business;
323323
}
324324

325-
protected CustomerCompanyData getRegisteredCompanyData() {
326-
CustomerCompanyData customerBusinessData = new CustomerCompanyData();
327-
customerBusinessData.setCommercialRegisterNumber("HRB337681 MANNHEIM");
328-
return customerBusinessData;
325+
protected CompanyInfo getRegisteredCompanyInfo() {
326+
CompanyInfo companyInfo = new CompanyInfo();
327+
companyInfo.setCommercialRegisterNumber("HRB337681 MANNHEIM");
328+
return companyInfo;
329329
}
330330

331331
protected Customer getFactoringOKCustomer(String customerId) throws ParseException {
@@ -404,7 +404,7 @@ private void assertProcessingEquals(Processing initProcessing, Processing proces
404404
assertEquals(initProcessing.getUniqueId(), processing.getUniqueId());
405405
}
406406

407-
protected void assertBusinessCustomerEquals(CustomerCompanyData customerExpected, CustomerCompanyData customer) {
407+
protected void assertBusinessCustomerEquals(CompanyInfo customerExpected, CompanyInfo customer) {
408408
if (customerExpected == null && customer == null) return;
409409
assertEquals(customerExpected.getCommercialRegisterNumber(), customer.getCommercialRegisterNumber());
410410
assertEquals(customerExpected.getCommercialSector(), customer.getCommercialSector());
@@ -421,7 +421,7 @@ protected void assertCustomerEquals(Customer customerExpected, Customer customer
421421

422422
assertAddressEquals(customerExpected.getBillingAddress(), customer.getBillingAddress());
423423
assertAddressEquals(customerExpected.getShippingAddress(), customer.getShippingAddress());
424-
assertBusinessCustomerEquals(customerExpected.getCompanyData(), customer.getCompanyData());
424+
assertBusinessCustomerEquals(customerExpected.getCompanyInfo(), customer.getCompanyInfo());
425425
}
426426

427427
protected void assertAddressEquals(Address addressExpected, Address address) {

src/test/java/com/unzer/payment/business/BusinessCustomerTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
import com.unzer.payment.Customer;
5-
import com.unzer.payment.CustomerCompanyData;
5+
import com.unzer.payment.CompanyInfo;
66
import com.unzer.payment.PaymentException;
77
import com.unzer.payment.communication.HttpCommunicationException;
88
import org.junit.jupiter.api.Disabled;
@@ -81,14 +81,14 @@ public void testUpdateCustomer() throws HttpCommunicationException, ParseExcepti
8181
assertNotNull(customer);
8282
assertNotNull(customer.getId());
8383
Customer customerToUpdate = new Customer("Unzer E-Com GmbH");
84-
CustomerCompanyData company = getRegisteredCompanyData();
84+
CompanyInfo company = getRegisteredCompanyInfo();
8585
company.setCommercialRegisterNumber("ABC993448 DÜSSELDORF");
86-
customerToUpdate.setCompanyData(company);
86+
customerToUpdate.setCompanyInfo(company);
8787
Customer updatedCustomer = getUnzer().updateCustomer(customer.getId(), customerToUpdate);
8888
assertEquals("Unzer E-Com GmbH", updatedCustomer.getCompany());
8989
Customer fetchedCustomer = getUnzer().fetchCustomer(customer.getId());
9090
assertEquals("Unzer E-Com GmbH", fetchedCustomer.getCompany());
91-
assertEquals("ABC993448 DÜSSELDORF", fetchedCustomer.getCompanyData().getCommercialRegisterNumber());
91+
assertEquals("ABC993448 DÜSSELDORF", fetchedCustomer.getCompanyInfo().getCommercialRegisterNumber());
9292
}
9393

9494
@Test

0 commit comments

Comments
 (0)