This commit is contained in:
2025-10-02 15:28:53 -04:00
parent 980c1dc049
commit 1e078ef500
15 changed files with 35 additions and 6 deletions

View File

@@ -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.");
}
}