public void makeCustomerPhoneDefault(Long customerPhoneId, Long customerId) { List<CustomerPhone> customerPhones = readActiveCustomerPhonesByCustomerId(customerId); for (CustomerPhone customerPhone : customerPhones) { customerPhone.getPhone().setDefault(customerPhone.getId().equals(customerPhoneId)); em.merge(customerPhone); } }
@DataProvider(name = "setupCustomerPhone") public static Object[][] createCustomerPhone() { CustomerPhone cp1 = new CustomerPhoneImpl(); Phone phone1 = new PhoneImpl(); phone1.setPhoneNumber("111-111-1111"); cp1.setPhone(phone1); cp1.setPhoneName("phone1"); CustomerPhone cp2 = new CustomerPhoneImpl(); Phone phone2 = new PhoneImpl(); phone1.setPhoneNumber("222-222-2222"); cp2.setPhone(phone2); cp2.setPhoneName("phone2"); return new Object[][] {new Object[] {cp1}, new Object[] {cp2}}; }