本文整理汇总了Java中org.kuali.rice.krad.datadictionary.validation.Employee.setEmployeeId方法的典型用法代码示例。如果您正苦于以下问题:Java Employee.setEmployeeId方法的具体用法?Java Employee.setEmployeeId怎么用?Java Employee.setEmployeeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.datadictionary.validation.Employee
的用法示例。
在下文中一共展示了Employee.setEmployeeId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRequiredNestedAttribute
import org.kuali.rice.krad.datadictionary.validation.Employee; //导入方法依赖的package包/类
@Test
/**
* tests that nested attributes are validated as expected
*
* @see DictionaryValidationServiceImpl#validate(Object, String, String, boolean)
* @see DictionaryValidationResult
*/
public void testRequiredNestedAttribute() throws IOException {
DataDictionaryService dataDictionaryService = new DataDictionaryServiceImpl(dataDictionary);
service.setDataDictionaryService(dataDictionaryService);
//Get object entries from dictionary
DataObjectEntry addressEntry = dataDictionary.getDataObjectEntry(
"org.kuali.rice.krad.datadictionary.validation.Address");
DataObjectEntry companyEntry = dataDictionary.getDataObjectEntry(
"org.kuali.rice.krad.datadictionary.validation.Company");
//Validate object entries
addressEntry.completeValidation();
companyEntry.completeValidation();
Company acmeCompany = new Company();
//Validate empty Company object
DictionaryValidationResult dictionaryValidationResult;
dictionaryValidationResult = service.validate(acmeCompany,
"org.kuali.rice.krad.datadictionary.validation.Company", companyEntry, true);
//Main address is required this should result in error
Assert.assertEquals(1, dictionaryValidationResult.getNumberOfErrors());
Assert.assertTrue(hasError(dictionaryValidationResult, "mainAddress", RiceKeyConstants.ERROR_REQUIRED));
//Adding an invalid mainAddress for company
Address acmeMainAddress = new Address();
acmeCompany.setMainAddress(acmeMainAddress);
dictionaryValidationResult = service.validate(acmeCompany,
"org.kuali.rice.krad.datadictionary.validation.Company", companyEntry, true);
//This should result in missing country error
Assert.assertEquals(2, dictionaryValidationResult.getNumberOfErrors());
Assert.assertTrue(hasError(dictionaryValidationResult, "mainAddress.country", RiceKeyConstants.ERROR_REQUIRED));
Assert.assertTrue(hasError(dictionaryValidationResult, "mainAddress", RiceKeyConstants.ERROR_OCCURS));
//Set items to valid address
acmeMainAddress.setCountry("US");
acmeMainAddress.setPostalCode("11111");
dictionaryValidationResult = service.validate(acmeCompany,
"org.kuali.rice.krad.datadictionary.validation.Company", companyEntry, true);
//This should result in no error
Assert.assertEquals(0, dictionaryValidationResult.getNumberOfErrors());
//Test Nested Attribute Within Nested Attribute, and nested property override
Employee companyContact = new Employee();
acmeCompany.setMainContact(companyContact);
Person mainContactPerson = new Person();
companyContact.setEmployeeDetails(mainContactPerson);
companyContact.setEmployeeId("companyContact");
dictionaryValidationResult = service.validate(acmeCompany,
"org.kuali.rice.krad.datadictionary.validation.Company", companyEntry, true);
Assert.assertEquals(1, dictionaryValidationResult.getNumberOfErrors());
Assert.assertTrue(hasError(dictionaryValidationResult, "mainContact.employeeDetails.gender",
RiceKeyConstants.ERROR_REQUIRED));
}
示例2: testCollectionConstraints
import org.kuali.rice.krad.datadictionary.validation.Employee; //导入方法依赖的package包/类
@Test
/**
* tests the collection definition as defined in org/kuali/rice/krad/test/datadictionary/validation/Company.xml
*
* @see org.kuali.rice.krad.datadictionary.CollectionDefinition
* @see DictionaryValidationServiceImpl#validate(Object, String, String, boolean)
*/
public void testCollectionConstraints() throws IOException {
DataDictionaryService dataDictionaryService = new DataDictionaryServiceImpl(dataDictionary);
service.setDataDictionaryService(dataDictionaryService);
DataObjectEntry companyEntry = dataDictionary.getDataObjectEntry(
"org.kuali.rice.krad.datadictionary.validation.Company");
//Add collection constraint provider so constraints on collections get processed
service.getConstraintProviders().add(new CollectionDefinitionConstraintProvider());
Company acmeCompany = new Company();
Address acmeMainAddress = new Address();
acmeMainAddress.setCountry("US");
acmeMainAddress.setPostalCode("11111");
acmeCompany.setMainAddress(acmeMainAddress);
DictionaryValidationResult dictionaryValidationResult = service.validate(acmeCompany,
"org.kuali.rice.krad.datadictionary.validation.Company", companyEntry, true);
//Company requires at least two employees
Assert.assertEquals(2, dictionaryValidationResult.getNumberOfErrors());
Assert.assertTrue(hasError(dictionaryValidationResult, "employees", RiceKeyConstants.ERROR_QUANTITY_RANGE));
Assert.assertTrue(hasError(dictionaryValidationResult, "slogans", RiceKeyConstants.ERROR_MIN_OCCURS));
//Add required employes and revalidate
Employee employee1 = new Employee();
Person person = new Person();
person.setBirthDate(new Date());
person.setGender("M");
employee1.setEmployeeDetails(person);
employee1.setEmployeeId("123456789");
List<Employee> employees = new ArrayList<Employee>();
employees.add(employee1);
acmeCompany.setEmployees(employees);
List<String> slogans = new ArrayList<String>();
slogans.add("Slogan One");
acmeCompany.setSlogans(slogans);
dictionaryValidationResult = service.validate(acmeCompany,
"org.kuali.rice.krad.datadictionary.validation.Company", companyEntry, true);
Assert.assertEquals(2, dictionaryValidationResult.getNumberOfErrors());
Assert.assertTrue(hasError(dictionaryValidationResult, "employees", RiceKeyConstants.ERROR_QUANTITY_RANGE));
Assert.assertTrue(hasError(dictionaryValidationResult, "slogans", RiceKeyConstants.ERROR_MIN_OCCURS));
//Add two invalid employees, this should result in size constraint, and invalid employee errors
employees.add(new Employee());
employees.add(new Employee());
slogans.add("Slogan Two");
dictionaryValidationResult = service.validate(acmeCompany,
"org.kuali.rice.krad.datadictionary.validation.Company", companyEntry, true);
Assert.assertEquals(5, dictionaryValidationResult.getNumberOfErrors());
Assert.assertTrue(hasError(dictionaryValidationResult, "employees[1].employeeId",
RiceKeyConstants.ERROR_REQUIRED));
Assert.assertTrue(hasError(dictionaryValidationResult, "employees[1].employeeDetails",
RiceKeyConstants.ERROR_REQUIRED));
Assert.assertTrue(hasError(dictionaryValidationResult, "employees[2].employeeId",
RiceKeyConstants.ERROR_REQUIRED));
Assert.assertTrue(hasError(dictionaryValidationResult, "employees[2].employeeDetails",
RiceKeyConstants.ERROR_REQUIRED));
}