当前位置: 首页>>代码示例>>Java>>正文


Java Employee类代码示例

本文整理汇总了Java中org.kuali.rice.krad.datadictionary.validation.Employee的典型用法代码示例。如果您正苦于以下问题:Java Employee类的具体用法?Java Employee怎么用?Java Employee使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Employee类属于org.kuali.rice.krad.datadictionary.validation包,在下文中一共展示了Employee类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.kuali.rice.krad.datadictionary.validation.Employee; //导入依赖的package包/类
@Before
public void setup() {

    richTable = new RichTable();

    group = new CollectionGroup();
    group.setCollectionObjectClass(Employee.class);
    TableLayoutManager layoutManager = new TableLayoutManager();
    layoutManager.setRenderSequenceField(true);
    group.setLayoutManager(layoutManager);
    group.setIncludeLineSelectionField(false);
    group.setRenderLineActions(false);

    List<Component> items = new ArrayList<Component>(1);
    DataField name = new DataField();
    name.setPropertyName("employeeId");
    items.add(name);
    DataField number = new DataField();
    number.setPropertyName("positionTitle");
    items.add(number);
    DataField contactEmail = new DataField();
    contactEmail.setPropertyName("contactEmail");
    items.add(contactEmail);

    group.setItems(items);

    mockView =  mock(View.class);
    ViewHelperService mockViewHelperService = mock(ViewHelperService.class);
    when(mockView.getViewHelperService()).thenReturn(mockViewHelperService);
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:31,代码来源:RichTableTest.java

示例2: 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));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:69,代码来源:DictionaryValidationServiceImplTest.java

示例3: 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));

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:73,代码来源:DictionaryValidationServiceImplTest.java

示例4: setup

import org.kuali.rice.krad.datadictionary.validation.Employee; //导入依赖的package包/类
@Before
public void setup() throws Throwable {
    richTable = new RichTable();

    richTable = spy(richTable);

    ConfigurationService configurationService = mock(ConfigurationService.class);
    doReturn(configurationService).when(richTable).getConfigurationService();

    group = new CollectionGroupBase();
    group.setCollectionObjectClass(Employee.class);

    TableLayoutManager layoutManager = new TableLayoutManagerBase();
    layoutManager.setRenderSequenceField(true);

    List<Component> items = new ArrayList<Component>(1);
    DataField name = new DataFieldBase();
    name.setPropertyName("employeeId");
    items.add(name);
    DataField number = new DataFieldBase();
    number.setPropertyName("positionTitle");
    items.add(number);
    DataField contactEmail = new DataFieldBase();
    contactEmail.setPropertyName("contactEmail");
    items.add(contactEmail);

    layoutManager = spy(layoutManager);
    doReturn(items).when(layoutManager).getFirstRowFields();
    doReturn(layoutManager).when(layoutManager).clone();

    group.setLayoutManager(layoutManager);
    group.setIncludeLineSelectionField(false);
    group.setRenderLineActions(false);

    group.setItems(items);

    mockView = mock(LookupView.class);
    ViewHelperService mockViewHelperService = mock(ViewHelperService.class);
    when(mockView.getViewHelperService()).thenReturn(mockViewHelperService);
    when(mockView.clone()).thenReturn(mockView);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:42,代码来源:RichTableTest.java


注:本文中的org.kuali.rice.krad.datadictionary.validation.Employee类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。