-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored two copies of populateCustomers into one
- Loading branch information
Showing
3 changed files
with
63 additions
and
100 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
cache-management/src/main/java/io/pivotal/bookshop/buslogic/CustomerLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.pivotal.bookshop.buslogic; | ||
|
||
import io.pivotal.bookshop.domain.Address; | ||
import io.pivotal.bookshop.domain.Customer; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.apache.geode.cache.Region; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Log4j2 | ||
class CustomerLoader { | ||
|
||
static void populateCustomerRegion(Region<Long, Customer> customerRegion) { | ||
Map<Long, Customer> customerMap = new HashMap<>(); | ||
Customer cust1 = Customer.builder().customerNumber(5540) | ||
.firstName("Lula").lastName("Wax") | ||
.address(Address.builder() | ||
.addressLine1("123 Main St") | ||
.city("Topeka").state("KS").postalCode("50505") | ||
.country("US").phoneNumber("423 555-3322").addressTag("HOME").build()) | ||
.bookOrder(17699L) | ||
.build(); | ||
customerMap.put(5540L, cust1); | ||
|
||
Customer cust2 = Customer.builder().customerNumber(5541) | ||
.firstName("Tom").lastName("Mcginns") | ||
.address(Address.builder() | ||
.addressLine1("123 Main St") | ||
.city("San Francisco").state("CA").postalCode("50505") | ||
.country("US").phoneNumber("423 555-3322").addressTag("HOME").build()) | ||
.bookOrder(17699L) | ||
.build(); | ||
customerMap.put(5541L, cust2); | ||
|
||
Customer cust3 = Customer.builder().customerNumber(5542) | ||
.firstName("Peter").lastName("Fernandez") | ||
.address(Address.builder() | ||
.addressLine1("123 Main St") | ||
.city("San Francisco").state("CA").postalCode("50505") | ||
.country("US").phoneNumber("423 555-3322").addressTag("HOME").build()) | ||
.bookOrder(17699L) | ||
.build(); | ||
customerMap.put(5542L, cust3); | ||
|
||
Customer cust4 = Customer.builder().customerNumber(5543) | ||
.firstName("Jenny").lastName("Tsai") | ||
.address(Address.builder() | ||
.addressLine1("123 Main St") | ||
.city("Topeka").state("CA").postalCode("50505") | ||
.country("US").phoneNumber("423 555-3322").addressTag("HOME").build()) | ||
.bookOrder(17699L) | ||
.build(); | ||
customerMap.put(5543L, cust4); | ||
|
||
customerRegion.putAll(customerMap); | ||
log.info("************ Loaded customers data ****************"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters