updates.
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
|
||||
package lodge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lodge.datamodel.Account;
|
||||
import lodge.datamodel.Address;
|
||||
import lodge.datamodel.EmailAddress;
|
||||
@@ -30,23 +33,42 @@ public final class TestAccountLoad {
|
||||
// memory
|
||||
mgr.UpdateAccount(acct);
|
||||
}
|
||||
|
||||
final static Address findIventory(List<Address> propertyIventory, String street) {
|
||||
Address inventory = propertyIventory
|
||||
.stream()
|
||||
.filter((Address inv) -> {
|
||||
return inv.getStreet().equals("10 wilco ave");
|
||||
}).findFirst().orElse(null);
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Configure data repository
|
||||
AccomodationManager mgr = new AccomodationManager(AccomodationManager.getRepositoryConfig.getPath());
|
||||
|
||||
List<Address> propertyIventory = new ArrayList<Address>();
|
||||
|
||||
propertyIventory.add(new Address("10 wilco ave", "wilco", "WY", "82801"));
|
||||
propertyIventory.add(new Address("30 Amstadam ave", "New York", "NY", "12010"));
|
||||
propertyIventory.add(new Address("400 hotel ave", "Maryland City", "MD", "20723"));
|
||||
|
||||
// 3. Add new account object to the list managed by Manager (if account object
|
||||
// already exists on add action with the same account number, it is considered
|
||||
// an error)
|
||||
Test_AddAccount(mgr, mgr.newAccount("701-456-7890",
|
||||
new Address("10 wilco ave", "wilco", "WY", "82801"),
|
||||
new EmailAddress("wilco@wyommin.net")));
|
||||
|
||||
Test_AddAccount(mgr, mgr.newAccount("701-456-7890",
|
||||
new Address("10 wilco ave", "wilco", "WY", "82801"),
|
||||
findIventory(propertyIventory, "10 wilco ave"),
|
||||
new EmailAddress("wilco@wyommin.net")));
|
||||
|
||||
System.out.println("Account already exists in list, so add attempt should fail:");
|
||||
mgr.showAccountList();
|
||||
|
||||
Test_AddAccount(mgr, mgr.newAccount("701-456-7890",
|
||||
findIventory(propertyIventory, "10 wilco ave"),
|
||||
new EmailAddress("wilco@wyommin.net")));
|
||||
|
||||
System.out.println("Program Completed.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{ "Account":{"account_number": "A45098176","phone_number": "701-456-7890","mailing_address": { "Address":{"street": "10 wilco ave","city": "wilco","state": "WY","zip": "82801"}},"email_address": { "EmailAddress":{"email": "wilco@wyommin.net"}},"reservations":[{"CabinReservation":{"reservation_number":"R0535276622"}},{"HouseReservation":{"reservation_number":"R0499811708"}}]}}
|
||||
{ "Account":{"account_number": "A45098176","phone_number": "701-456-7890","mailing_address": { "Address":{"street": "10 wilco ave","city": "wilco","state": "WY","zip": "82801"}},"email_address": { "EmailAddress":{"email": "wilco@wyommin.net"}},"reservations":[]}}
|
||||
Reference in New Issue
Block a user