private void assertUser(User user, String... roles) {
assertUser(user, true, roles);
}
private void assertUser(User user, boolean checkUserId, String... roles) {
Account account = user.getAccount();
Profile profile = user.getProfile();
// user
if (checkUserId) {
assertTrue(arrayContains(new String[] { "j2ee", "admin" }, user.getUserId()));
}
assertEquals(null, user.getPassword()); // 密码不可查询
if (isEmptyArray(roles)) {
assertTrue(isEmptyArray(user.getRoles()));
} else {
assertArrayEquals(roles, user.getRoles());
}
// account
assertEquals("yourname@yourdomain.com", account.getEmail());
assertEquals("ABC", account.getFirstName());
assertEquals("XYX", account.getLastName());
assertEquals("OK", account.getStatus());
assertEquals("901 San Antonio Road", account.getAddress1());
assertEquals("MS UCUP02-206", account.getAddress2());
assertEquals("Palo Alto", account.getCity());
assertEquals("CA", account.getState());
assertEquals("94303", account.getZip());
assertEquals("US", account.getCountry());
assertEquals("555-555-5555", account.getPhone());
assertEquals("1234567", account.getCreditCardNumber());
assertEquals("Visa", account.getCreditCardType());
assertEquals("2005-12-15", new SimpleDateFormat("yyyy-MM-dd").format(account.getCreditCardExpiry()));
assertEquals(12, account.getCreditCardExpiryMonth());
assertEquals(2005, account.getCreditCardExpiryYear());
// profile
assertEquals("english", profile.getLanguagePreference());
assertEquals("DOGS", profile.getFavoriteCategoryId());
}