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


Java AccountExtension类代码示例

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


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

示例1: testObjectUtils_getPropertyType

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
@Test
   /**
    * tests that various properties of the business object extension are of the expected Java Class
    */
public void testObjectUtils_getPropertyType() throws Exception {
	Account ta = new Account();
assertEquals("physical property type mismatch", PersistableBusinessObjectExtension.class, PropertyUtils
	.getPropertyType(ta, "extension"));
assertEquals("DD property type mismatch", AccountExtension.class, ObjectUtils.getPropertyType(ta, "extension",
           KNSServiceLocator.getPersistenceStructureService()));
assertEquals("extension.accountType attribute class mismatch", AccountType.class, ObjectUtils.getPropertyType(
	ta, "extension.accountType", KNSServiceLocator.getPersistenceStructureService()));
assertEquals("extension.accountType.codeAndDescription attribute class mismatch", String.class, ObjectUtils
	.getPropertyType(ta, "extension.accountType.codeAndDescription", KNSServiceLocator
		.getPersistenceStructureService()));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:ExtensionAttributeTest.java

示例2: testLazyRefreshField

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
@Test
/**
 * tests that {@link PersistableBusinessObjectBase#refreshReferenceObject(String)} works for a lazy loaded reference when the foreign key is changed
 */
public void testLazyRefreshField() {
    final String number = "a1";
    AccountExtension accountExtension = KNSServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(AccountExtension.class, number);

    assertNotNull( "Unable to retrieve account extension a1", accountExtension );
    assertEquals("Retrieved account extension should have an account type of IAT", "IAT",
            accountExtension.getAccountType().getAccountTypeCode());
    assertEquals("Retrieved account extension should have an account type name of Income Account Type",
            "Income Account Type", accountExtension.getAccountType().getName());
    accountExtension.setAccountTypeCode("CAT");
    accountExtension.refreshReferenceObject("accountType");
    assertEquals("Account extension should now have an account type name of Clearing Account Type",
            "Clearing Account Type", accountExtension.getAccountType().getName());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:BusinessObjectRefreshTest.java

示例3: testLazyRefreshWholeObject

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
@Test
/**
 * tests that {@link PersistableBusinessObjectBase#refresh()} works for a lazy loaded reference when the foreign key is changed
 */
public void testLazyRefreshWholeObject() {
    final String number = "a1";
    AccountExtension accountExtension = KNSServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(AccountExtension.class, number);

    assertNotNull( "Unable to retrieve account extension a1", accountExtension );
    assertEquals("Retrieved account extension should have account type IAT", "IAT",
            accountExtension.getAccountType().getAccountTypeCode());
    assertEquals("Retrieved account extension should have an account type name of Income Account Type",
            "Income Account Type", accountExtension.getAccountType().getName());

    accountExtension.setAccountTypeCode("CAT");
    accountExtension.refresh();

    assertEquals("Account extension should now have an account type name of Clearing Account Type",
            "Clearing Account Type", accountExtension.getAccountType().getName());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:21,代码来源:BusinessObjectRefreshTest.java

示例4: testObjectUtils_getPropertyType

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
@Test
   /**
    * tests that various properties of the business object extension are of the expected Java Class
    */
public void testObjectUtils_getPropertyType() throws Exception {
	Account ta = new Account();
assertEquals("physical property type mismatch", PersistableBusinessObjectExtension.class, PropertyUtils
	.getPropertyType(ta, "extension"));
assertEquals("DD property type mismatch", AccountExtension.class, ObjectUtils.getPropertyType(ta, "extension",
	KRADServiceLocator.getPersistenceStructureService()));
assertEquals("extension.accountType attribute class mismatch", AccountType.class, ObjectUtils.getPropertyType(
	ta, "extension.accountType", KRADServiceLocator.getPersistenceStructureService()));
assertEquals("extension.accountType.codeAndDescription attribute class mismatch", String.class, ObjectUtils
	.getPropertyType(ta, "extension.accountType.codeAndDescription", KRADServiceLocator
		.getPersistenceStructureService()));
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:17,代码来源:ExtensionAttributeTest.java

示例5: testExistenceChecks

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
@Test
   /**
    * tests validation on the extension attribute
    *
    * <p>The values given for attributes that are foreign keys should represent existing objects when auto-update is set to false</p>
    */
   public void testExistenceChecks() throws Exception {
	Account account = new Account();
	((AccountExtension)account.getExtension()).setAccountTypeCode( "XYZ" ); // invalid account type
	account.setName("Test Name");
	account.setNumber("1234567");
       GlobalVariables.setUserSession(new UserSession("quickstart"));
MaintenanceDocument document = (MaintenanceDocument) KRADServiceLocatorWeb.getDocumentService().getNewDocument(
	"AccountMaintenanceDocument");
       assertNotNull( "new document must not be null", document );
       document.getDocumentHeader().setDocumentDescription( getClass().getSimpleName() + "test" );
       document.getOldMaintainableObject().setDataObject(null);
       document.getOldMaintainableObject().setDataObjectClass(account.getClass());
       document.getNewMaintainableObject().setDataObject(account);
       document.getNewMaintainableObject().setDataObjectClass(account.getClass());

       boolean failedAsExpected = false;
       try {
       	document.validateBusinessRules( new RouteDocumentEvent(document) );
       } catch ( ValidationException expected ) {
       	failedAsExpected = true;
       }
       assertTrue( "validation should have failed", failedAsExpected );
       System.out.println( "document errors: " + GlobalVariables.getMessageMap() );
       assertTrue( "there should be errors", GlobalVariables.getMessageMap().getErrorCount() > 0 );
assertTrue("should be an error on the account type code", GlobalVariables.getMessageMap().doesPropertyHaveError(
	"document.newMaintainableObject.dataObject.extension.accountTypeCode"));
assertTrue("account type code should have an existence error", GlobalVariables.getMessageMap().fieldHasMessage(
	"document.newMaintainableObject.dataObject.extension.accountTypeCode", "error.existence"));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:ExtensionAttributeTest.java

示例6: testExistsSubQueryCriteria

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
@Test
public void testExistsSubQueryCriteria() {

    Logger.getLogger(getClass()).info( "Adding Account" );
    Account acct = new Account();
    acct.setNumber("a1");
    acct.setName("a1 name");
    provider.save(acct, PersistenceOption.FLUSH);

    Logger.getLogger(getClass()).info( "Testing Account Saved" );
    acct = provider.find(Account.class, "a1");
    assertNotNull( "a1 SimpleAccount missing", acct );
    /*
     * Testing query of form:
     *
     * SELECT * FROM SimpleAccount WHERE EXISTS ( SELECT 'x' FROM SimpleAccountExtension WHERE SimpleAccountExtension.number = SimpleAccount.number )
     */
    Predicate subquery = PredicateFactory.existsSubquery(AccountExtension.class.getName(), PredicateFactory.equalsProperty("number", null, "parent.number"));
    QueryByCriteria q = QueryByCriteria.Builder.fromPredicates(subquery);
    Logger.getLogger(getClass()).info( "Performing Lookup with Exists Query: " + q );
    QueryResults<Account> results = provider.findMatching(Account.class, q);

    assertNotNull( "Results should not have been null", results );
    assertEquals( "Should have been no results in the default data", 0, results.getResults().size() );

    Logger.getLogger(getClass()).info( "Building extension object for retest" );
    AccountExtension ext = new AccountExtension();
    ext.setAccount(acct);
    ext.setAccountTypeCode("EAX");
    provider.save(ext, PersistenceOption.FLUSH);

    Logger.getLogger(getClass()).info( "Running query again to test results" );
    results = provider.findMatching(Account.class, q);
    assertNotNull( "Results should not have been null", results );
    assertEquals( "We added an extension record, so there should have been one result", 1, results.getResults().size() );
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:37,代码来源:JpaPersistenceProviderTest.java

示例7: testGetExtension

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
/**
 * Verifies that new instances of the extension object are created properly when using KRAD.
 * The {@link org.kuali.rice.krad.test.document.bo.Account} object has it's extension mapped both using the
 * legacy KNS and non-Legacy KRAD approaches and it extends from PersistableBusinessObjectBase.
 */
@Test
public void testGetExtension() throws Exception {
    Account account = new Account();
    Object extension = account.getExtension();
    assertNotNull(extension);
    assertTrue(extension instanceof AccountExtension);

    extension = legacyDataAdapter.getExtension(Account.class);
    assertNotNull(extension);
    assertTrue(extension instanceof AccountExtension);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:LegacyDataAdapterTest.java

示例8: testExistenceChecks

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
/**
    * tests validation on the extension attribute
    *
    * // TODO: test is currently failing because default existence checks are not implemented in KRAD
    * // see https://jira.kuali.org/browse/KULRICE-7666
    *
    * <p>The values given for attributes that are foreign keys should represent existing objects when auto-update is set to false</p>
    */
public void testExistenceChecks() throws Exception {
	Account account = new Account();
	((AccountExtension)account.getExtension()).setAccountTypeCode( "XYZ" ); // invalid account type
	account.setName("Test Name");
	account.setNumber("1234567");
       GlobalVariables.setUserSession(new UserSession("quickstart"));
MaintenanceDocument document = (MaintenanceDocument) KRADServiceLocatorWeb.getDocumentService().getNewDocument(
	"AccountMaintenanceDocument");
       assertNotNull( "new document must not be null", document );
       document.getDocumentHeader().setDocumentDescription( getClass().getSimpleName() + "test" );
       document.getOldMaintainableObject().setDataObject(null);
       document.getOldMaintainableObject().setDataObjectClass(account.getClass());
       document.getNewMaintainableObject().setDataObject(account);
       document.getNewMaintainableObject().setDataObjectClass(account.getClass());

       boolean failedAsExpected = false;
       try {
       	document.validateBusinessRules( new RouteDocumentEvent(document) );
       } catch ( ValidationException expected ) {
       	failedAsExpected = true;
       }
       assertTrue( "validation should have failed", failedAsExpected );
       System.out.println( "document errors: " + GlobalVariables.getMessageMap() );
       assertTrue( "there should be errors", GlobalVariables.getMessageMap().getErrorCount() > 0 );
assertTrue("should be an error on the account type code", GlobalVariables.getMessageMap().doesPropertyHaveError(
	"document.newMaintainableObject.dataObject.extension.accountTypeCode"));
assertTrue("account type code should have an existence error", GlobalVariables.getMessageMap().fieldHasMessage(
	"document.newMaintainableObject.dataObject.extension.accountTypeCode", "error.existence"));
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:38,代码来源:ExtensionAttributeTest.java

示例9: testPKObjectForExtension

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
/**
 * Tests that MetadataManager.getPersistableBusinessObjectPrimaryKeyObjectWithValuesForExtension works
 */
@Test
public void testPKObjectForExtension() {
	final Account account = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(Account.class, "b101");
	assertNotNull("Account should not be null", account);
	final AccountExtension accountExtension = (AccountExtension)account.getExtension();
	
	final Object pkValue = MetadataManager.getPersistableBusinessObjectPrimaryKeyObjectWithValuesForExtension(account, accountExtension);
	assertEquals("Single pkValue should be of class String", String.class, pkValue.getClass());
	assertEquals("Single pkValue should be \"b101\"", "b101", pkValue);
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:14,代码来源:MetadataManagerTest.java

示例10: testNotExistsSubQueryCriteria

import org.kuali.rice.krad.test.document.bo.AccountExtension; //导入依赖的package包/类
@Test
public void testNotExistsSubQueryCriteria() {

    Logger.getLogger(getClass()).info( "Adding Account1" );
    Account acct = new Account();
    acct.setNumber("a1");
    acct.setName("a1 name");
    provider.save(acct, PersistenceOption.FLUSH);

    Logger.getLogger(getClass()).info( "Adding Account2" );
    Account acct2 = new Account();
    acct.setNumber("a2");
    acct.setName("a2 name");
    provider.save(acct, PersistenceOption.FLUSH);

    acct = null;
    Logger.getLogger(getClass()).info( "Testing Account1 Saved" );
    acct = provider.find(Account.class, "a1");
    assertNotNull( "a1 SimpleAccount missing", acct );

    acct2 = null;
    Logger.getLogger(getClass()).info( "Testing Account2 Saved" );
    acct2 = provider.find(Account.class, "a2");
    assertNotNull( "a2 SimpleAccount missing", acct2 );

    // Just a1 has an AccountExtension
    Logger.getLogger(getClass()).info( "Building extension object for retest" );
    AccountExtension ext = new AccountExtension();
    ext.setAccount(acct);
    ext.setAccountTypeCode("EAX");
    provider.save(ext, PersistenceOption.FLUSH);


    /*
     * Testing query of form:
     *
     * SELECT * FROM SimpleAccount WHERE NOT EXISTS ( SELECT 'x' FROM SimpleAccountExtension WHERE SimpleAccountExtension.number = SimpleAccount.number )
     */
    Predicate subquery = PredicateFactory.notExistsSubquery(AccountExtension.class.getName(),
            PredicateFactory.equalsProperty("number", null, "parent.number"));
    QueryByCriteria q = QueryByCriteria.Builder.fromPredicates(subquery);
    Logger.getLogger(getClass()).info( "Performing Lookup with Exists Query: " + q );
    QueryResults<Account> results = provider.findMatching(Account.class, q);

    assertNotNull( "Results should not have been null", results );
    assertEquals( "Should have been one result in the default data", 1, results.getResults().size() );
    assertEquals(" A2 should be returned for not exists", results.getResults().get(0).getNumber(), "a2");


    // Now acct2 also has AccountExtension
    Logger.getLogger(getClass()).info( "Building extension object for retest" );
    AccountExtension ext2 = new AccountExtension();
    ext2.setAccount(acct2);
    ext2.setAccountTypeCode("EAX2");
    provider.save(ext2, PersistenceOption.FLUSH);

    Logger.getLogger(getClass()).info( "Running query again to test results" );
    results = provider.findMatching(Account.class, q);
    assertNotNull( "Results should not have been null", results );
    assertEquals( "We added an extension record, so there should have been no result", 0, results.getResults().size() );
}
 
开发者ID:kuali,项目名称:rice,代码行数:62,代码来源:JpaPersistenceProviderTest.java


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